Difference between revisions of "PM Opc CALL"
From SublabWiki
m (→CALL = Call routine) |
m |
||
Line 74: | Line 74: | ||
|None | |None | ||
|- | |- | ||
− | |FC | + | |FC nn |
|CINT #nn | |CINT #nn | ||
|20 | |20 | ||
Line 261: | Line 261: | ||
; A = 0x10 | ; A = 0x10 | ||
; B = 0x10 | ; B = 0x10 | ||
− | CALL somefunction | + | '''CALL somefunction''' |
; A = 0x11 | ; A = 0x11 | ||
; B = 0x0F | ; B = 0x0F | ||
[[PM_Opc_TST|TST B, #0x10]] | [[PM_Opc_TST|TST B, #0x10]] | ||
; F = (Zero=0):(Sign=0) | ; F = (Zero=0):(Sign=0) | ||
− | CALLZ somefunction ; Condition fail, call not taken | + | '''CALLZ somefunction''' ; Condition fail, call not taken |
; A = 0x11 | ; A = 0x11 | ||
; B = 0x0F | ; B = 0x0F | ||
; F = (Zero=0):(Sign=0) | ; F = (Zero=0):(Sign=0) | ||
− | CALLP somefunction ; Condition succeed | + | '''CALLP somefunction''' ; Condition succeed |
; A = 0x12 | ; A = 0x12 | ||
; B = 0x0E | ; B = 0x0E | ||
Line 283: | Line 283: | ||
; Calling a subroutine at different bank | ; Calling a subroutine at different bank | ||
[[PM_Opc_MOV8|MOV U, $0F]] | [[PM_Opc_MOV8|MOV U, $0F]] | ||
− | CALL function_at_bank_16 | + | '''CALL function_at_bank_16''' |
[[PM_InstructionList|'''« Back to Instruction set''']] | [[PM_InstructionList|'''« Back to Instruction set''']] |
Revision as of 00:11, 21 April 2009
CALL = Call routine
Hex | Mnemonic | Cycles,True | or False | Condition |
---|---|---|---|---|
E0 ss | CALLC short #ss | 20 | 8 | Carry=1 |
E1 ss | CALLNC short #ss | 20 | 8 | Carry=0 |
E2 ss | CALLZ short #ss | 20 | 8 | Zero=1 |
E3 ss | CALLNZ short #ss | 20 | 8 | Zero=0 |
E8 ss ss | CALLC long #ssss | 24 | 12 | Carry=1 |
E9 ss ss | CALLNC long #ssss | 24 | 12 | Carry=0 |
EA ss ss | CALLZ long #ssss | 24 | 12 | Zero=1 |
EB ss ss | CALLNZ long #ssss | 24 | 12 | Zero=0 |
F0 ss | CALL short #ss | 20 | None | None |
F2 ss ss | CALL long #ssss | 24 | None | None |
FB nn nn | CALL [#nnnn] | 20 | None | None |
FC nn | CINT #nn | 20 | None | None |
CE F0 ss | CALLL #ss | 24 | 12 | Overflow != Sign |
CE F1 ss | CALLLE #ss | 24 | 12 | (Overflow != Sign) OR (Zero=1) |
CE F2 ss | CALLG #ss | 24 | 12 | (Overflow == Sign) OR (Zero=0) |
CE F3 ss | CALLGE #ss | 24 | 12 | Overflow == Sign |
CE F4 ss | CALLO #ss | 24 | 12 | Overflow=1 |
CE F5 ss | CALLNO #ss | 24 | 12 | Overflow=0 |
CE F6 ss | CALLP #ss | 24 | 12 | Sign=0 |
CE F7 ss | CALLNP #ss | 24 | 12 | Sign=1 |
CE F8 ss | CALLNX0 #ss | 24 | 12 | ?? |
CE F9 ss | CALLNX1 #ss | 24 | 12 | ?? |
CE FA ss | CALLNX2 #ss | 24 | 12 | ?? |
CE FB ss | CALLNX3 #ss | 24 | 12 | ?? |
CE FC ss | CALLX0 #ss | 24 | 12 | ?? |
CE FD ss | CALLX1 #ss | 24 | 12 | ?? |
CE FE ss | CALLX2 #ss | 24 | 12 | ?? |
CE FF ss | CALLX3 #ss | 24 | 12 | ?? |
Execute
#nn = Immediate unsigned 8-Bits #ss = Immediate signed 8-Bits #ssss = Immediate signed 16-Bits U/V = Register U or V SP = Register SP (Stack Pointer) [#nnnn] = Memory: (I shl 16) or #nnnn
; CALL* #ss IF (Condition) THEN SP = SP - 3 Memory[SP+2] = V Memory[SP+1] = PC SHR 8 Memory[SP] = PC AND 0x00FF V = U PC = PC + #ss - 1 ENDIF
; CALL* #ssss IF (Condition) THEN SP = SP - 3 Memory[SP+2] = V Memory[SP+1] = PC SHR 8 Memory[SP] = PC AND 0x00FF V = U PC = PC + #ssss - 1 ENDIF
; CALL #ss SP = SP - 3 Memory[SP+2] = V Memory[SP+1] = PC SHR 8 Memory[SP] = PC AND 0x00FF V = U PC = PC + #ss - 1
; CALL #ssss SP = SP - 3 Memory[SP+2] = V Memory[SP+1] = PC SHR 8 Memory[SP] = PC AND 0x00FF V = U PC = PC + #ssss - 1
; CALL [#nnnn] SP = SP - 3 Memory[SP+2] = V Memory[SP+1] = PC SHR 8 Memory[SP] = PC AND 0x00FF V = U PC = Memory16[(I SHL 16) + #nnnn]
; CINT #nn (not fully tested) SP = SP - 4 Memory[SP+3] = V Memory[SP+2] = PC SHR 8 Memory[SP+1] = PC AND 0x00FF Memory[SP] = F V = U PC = Memory16[#nn SHL 1]
Description
Call a subroutine (CALL or CALL*) or a interrupt vector (CINT).
Use RET to return from a subroutine and RETI from a interrupt.
NOTE: All non-branch instructions does "U = V" causing U to be restored, any branch that require banking needs "MOV U, A" or "MOV U, #nn" before it...
Conditions
None
Examples
; A = 0x10 ; B = 0x10 CALL somefunction ; A = 0x11 ; B = 0x0F TST B, #0x10 ; F = (Zero=0):(Sign=0) CALLZ somefunction ; Condition fail, call not taken ; A = 0x11 ; B = 0x0F ; F = (Zero=0):(Sign=0) CALLP somefunction ; Condition succeed ; A = 0x12 ; B = 0x0E (...) somefunction: INC A DEC B RET ; Return from the call
; Calling a subroutine at different bank MOV U, $0F CALL function_at_bank_16