instruction set - jcboseust.ac.in

1

Upload: others

Post on 06-Jan-2022

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Instruction Set - jcboseust.ac.in

Instruction Set

Mid Range PIC Microcontroller

Page 2: Instruction Set - jcboseust.ac.in

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.

Page 3: Instruction Set - jcboseust.ac.in

Instruction Set Summary

• 4 Oscillator Pulse = 1 Instruction CycleIf using Oscillator = 4 MHz 1 Instruction Cycle = 1µsConditional branching = 2 µs

Page 4: Instruction Set - jcboseust.ac.in

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

Page 5: Instruction Set - jcboseust.ac.in

Data Memory Map

Page 6: Instruction Set - jcboseust.ac.in

Register File Map

Page 7: Instruction Set - jcboseust.ac.in

Byte – Oriented Instructions

Page 8: Instruction Set - jcboseust.ac.in

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.

Page 9: Instruction Set - jcboseust.ac.in

Bit – Oriented Instructions‘ b ’ – bit field ‘ f ’ – destination register

Ex : btfsc PORT A, 4

Page 10: Instruction Set - jcboseust.ac.in

Literal and Control Instructions

Page 11: Instruction Set - jcboseust.ac.in

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

Page 12: Instruction Set - jcboseust.ac.in

Single bit manipulation

• bcf f,b• Bsf f,b

Examples:bcf portB,0bsf status,5 (carry)

Page 13: Instruction Set - jcboseust.ac.in

Examples of Single Bit Manipulation Instruction

Page 14: Instruction Set - jcboseust.ac.in

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)

Page 15: Instruction Set - jcboseust.ac.in

Examples of Clear Instructions

Page 16: Instruction Set - jcboseust.ac.in

Examples of Data transfer Instructions

Page 17: Instruction Set - jcboseust.ac.in

Examples of Data transfer Instructions

Page 18: Instruction Set - jcboseust.ac.in

Examples of Swap Instruction

Page 19: Instruction Set - jcboseust.ac.in

Increment/Decrement/Complement

• Incf f, F(W)• Decf f, F(W)• Compf f, F(W)

Page 20: Instruction Set - jcboseust.ac.in

Example of Inc/Dec Instructions

Page 21: Instruction Set - jcboseust.ac.in

Examples of Complement Instruction

Page 22: Instruction Set - jcboseust.ac.in

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)

Page 23: Instruction Set - jcboseust.ac.in

Examples of Multiple Bit Manipulation Instructions

Page 24: Instruction Set - jcboseust.ac.in

Examples of Multiple Bit Manipulation Instructions

Page 25: Instruction Set - jcboseust.ac.in

Examples of Multiple Bit Manipulation Instructions

Page 26: Instruction Set - jcboseust.ac.in

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)

Page 27: Instruction Set - jcboseust.ac.in

Examples of addition Instruction

Page 28: Instruction Set - jcboseust.ac.in

Examples of Subtraction Instructions

Page 29: Instruction Set - jcboseust.ac.in

Rotate

• Rlf f, F(W)• Rrf f, F(W)

Page 30: Instruction Set - jcboseust.ac.in

Examples of Rotate Instructions

Page 31: Instruction Set - jcboseust.ac.in

Conditional Branch

• Btfsc f , b• Btfss f , b• Decfsz f , F(W)• Incfsz f , F(W)

Page 32: Instruction Set - jcboseust.ac.in

Examples of Conditional Branch Instructions

Page 33: Instruction Set - jcboseust.ac.in

Examples of Conditional Branch Instructions

Page 34: Instruction Set - jcboseust.ac.in

Go to/call/return

• Go to label• Call label• Return• Retlw k• retie

Page 35: Instruction Set - jcboseust.ac.in

Examples of go to/ call Instructions

Page 36: Instruction Set - jcboseust.ac.in

Examples of Return Instructions

Page 37: Instruction Set - jcboseust.ac.in

Examples of Return Instruction

Page 38: Instruction Set - jcboseust.ac.in

Miscellaneous

• Clrwdt• Sleep• Nop

Page 39: Instruction Set - jcboseust.ac.in

Miscellaneous Instructions

Page 40: Instruction Set - jcboseust.ac.in

Miscellaneous Instructions