SubClass 011: Branching 111 011 pq1 ccc ; Conditional jump, call or return
111 011 pq0 000 ; Unconditional jump, call or return
p=0 => jump
p=1 => call
q=1 => return
ccc (condition) can be: mnemonic
---------------------------------------------------------------
000 flag Z=1; zero jz addr { or cz, or rz }
001 flag C=1; carry jc addr { similar to above }
010 flag N=1; negative jn addr ...
011 flag V=1; overflow jv addr
100 flag Z=0; non zero jnz addr
101 flag C=0; non carry jnc addr
110 flag N=0; positive jnn addr
111 flag V=0; no overflow jnv addr
---------------------------------------------------------------
Mnemonics for unconditional branching are:
jp addr
call addr
ret
Call instructions save registers PC, F and S to the stack before branching.
Return instructions pops registers S, F and PC from the stack before branching back.
NOTE:
Conditional branching is always immediate (address in second word operand).
You can implement unconditional jump with other addressing modes by simply
transferring an address to the PC, as in the following examples:
ldr PC, A ; PC:=A, useful for computed branching.
ldix PC, ptr ; PC:=[IX + ptr ], say that 'ptr' is a pointer to function
; stored as member of a structure being pointed by register IX.
|