7. Calculating the short branch address
• Target address = 2nd byte of instruction X 2 +PC
• Second byte value -127 to +128 (2s complement method)
• Verify the calculation of backward jump
FDH = -3
-3 X 2 =-6
-6 + 0000CH = 06H
6H address of the label again
8. Unconditional branch instruction
• There are two unconditional branches in PIC 18
• GOTO
• BRA
• GOTO
• This can go to any memory location in 2M address space
• 4 byte (32 bits) 12(opcode) + 20(address of the target location)
• BRA (branch)
• 2 byte (16 bits) 5(opcode) + 11(relative address)[forward + backward]
• -1024 to +1023
11. CALL instruction
• This is used to call subroutine
• PIC 18
• CALL (long call)
• RCALL (relative call)
• A stack is used
• PIC 18 has 5-bit stack pointer
32 locations (actually 31)
13. CALL instruction
• RCALL
• 2 byte instruction
• Subroutine must be within 2K (only 11 bits, 5bits for opcode)
(CALL 2M space)
• Can save ROM space
14. Time delay and instruction pipeline
• Two factors that can affect the accuracy of the delay
• The crystal frequency
• The PIC design: Harvard architecture, RISC architecture features and
pipelining
• Pipelining
15. Instruction cycle time for the PIC
• In PIC 18 one instruction cycle 4 oscillator periods.