Instruction Set ArchitectureIP2022 Users Manual
78
www.ubicom.com
Returning from a subroutine restores the saved program counter
contents, which causes program to resume execution with the
instruction immediately following the call instruction (a nop
instruction, in the above example)
A program memory address is a 16-bit word address. The jmp
and call instructions specify only the lowest thirteen bits of the
jump/call address. The upper 3 bits come from the PA2:0 bits of
the STATUS register. An indirect relative jump can be
accomplished by adding the contents of the W register to the PCL
register (i.e. an add pcl,w instruction).
Program control instructions such as jmp, call, and ret alter
the normal program sequence. When one of these instructions is
executed, the execution pipeline is automatically cleared of
pending instructions and refilled with new instructions, starting at
the new program address. Because the pipeline must be cleared,
three clock cycles are required for execution, one to execute the
instruction and two to reload the pipeline.
call
add_2bytes
;call subroutine
;add_2bytes
nop
;execution returns to here
;after subroutine is finished
...
add_2bytes:
;subroutine label
...
;subroutine code goes here
ret
;return from subroutine