instruction set - jcboseust.ac.in
TRANSCRIPT
Instruction Set
Mid Range PIC Microcontroller
Instruction Set Summary• Only 35 Instructions.• PIC16CXX instruction is a 14-bit word divided.• divided into an OPCODE & one or more OPERANDS.• OPCODE specifies instruction type• OPERANDS specify the operation of instruction.• All instruction are executed in 1 Cycle except Conditional
branch, its 2 Cycle.
Instruction Set Summary
• 4 Oscillator Pulse = 1 Instruction CycleIf using Oscillator = 4 MHz 1 Instruction Cycle = 1µsConditional branching = 2 µs
Word List : • f – any memory location or SPR.• W – Working Register• b – Bit position in ‘f’ register.• TOS – Top of Stack.• [ ] – Option• < > - Bit position inside register.
• Byte-oriented instruction
• Bit-oriented instruction
• Literal and Control operations instruction
Data Memory Map
Register File Map
Byte – Oriented Instructions
Byte – Oriented Instructions‘ f ’ – file register
(0x00 to 0x7F)‘ d ’ – destination register
file register – which register is to be used by instruction.
destination register - where the result of the operation to be placed.d = 0; result placed in W register.d = 1; result placed in file register
specified in instruction.
Bit – Oriented Instructions‘ b ’ – bit field ‘ f ’ – destination register
Ex : btfsc PORT A, 4
Literal and Control Instructions
Classification of Instructions
All 35 Instructions are broadly classified into categories:1. Single bit manipulation2. Clear/ Move 3. Increment/Decrement/Complement 4. Multiple Bit Manipulation 5. Addition /Subtraction6. Rotate7. Conditional Branch8. Go to/call/return9. Miscellaneous
Single bit manipulation
• bcf f,b• Bsf f,b
Examples:bcf portB,0bsf status,5 (carry)
Examples of Single Bit Manipulation Instruction
Clear/ Move
• Clr w (w=0)• Clrf f (f=0)• Movlw k (k W) (Data to working register)• Movwf f (W f) (Working Register to given
location or SPR)• Movf f, W (f W)• Swapf f, F(W)
Examples of Clear Instructions
Examples of Data transfer Instructions
Examples of Data transfer Instructions
Examples of Swap Instruction
Increment/Decrement/Complement
• Incf f, F(W)• Decf f, F(W)• Compf f, F(W)
Example of Inc/Dec Instructions
Examples of Complement Instruction
Multiple Bit Manipulation
• Andlw k (W and K W)• Andwf f, F(W) (W and f f or W)• Iorlw k (W or K W)• iorwf f, F(W) (W or f f or W)• xorlw k (W or K W)• xorwf f, F(W) (W or f f or W)
Examples of Multiple Bit Manipulation Instructions
Examples of Multiple Bit Manipulation Instructions
Examples of Multiple Bit Manipulation Instructions
Addition /Subtraction
• Addlw k (W + K W)• Addwf f, F(W) (f +W f or W)• Sublw (k – W W)• subwf f, F(W) (f -W f or W)
Examples of addition Instruction
Examples of Subtraction Instructions
Rotate
• Rlf f, F(W)• Rrf f, F(W)
Examples of Rotate Instructions
Conditional Branch
• Btfsc f , b• Btfss f , b• Decfsz f , F(W)• Incfsz f , F(W)
Examples of Conditional Branch Instructions
Examples of Conditional Branch Instructions
Go to/call/return
• Go to label• Call label• Return• Retlw k• retie
Examples of go to/ call Instructions
Examples of Return Instructions
Examples of Return Instruction
Miscellaneous
• Clrwdt• Sleep• Nop
Miscellaneous Instructions
Miscellaneous Instructions