394
APPENDIX B Instructions
The content of A after executing this instruction is the address of the next instruction (not the
address containing the operation code of this instruction). Accordingly, the value "1235H" stored
in A in the example shown in Figure B.3-5 "XCHW A,PC" is the address of the next operation
code after "XCHW A,PC". Therefore, the value of A is "1235H" not "1234H".
Figure B.3-6 "Example Using XCHW A, PC" shows an assembly language example.
Figure B.3-6 Example Using XCHW A, PC
r CALLV #vct
This instruction is used to branch to a subroutine address in the vector table. The instruction
saves the return address (contents of the PC) to the address corresponding to the SP (stack
pointer) branches to the address stored in the vector table using vector addressing. As "CALLV
#vct" is a single-byte instruction, using this instruction for commonly used subroutines reduces
the overall program size.
Figure B.3-7 "Execution example of CALLV #3" shows an outline of the instruction operation.
Figure B.3-7 Execution example of CALLV #3
The content of PC saved to stack area after executing this instruction is the address of next
instruction (not the address containing the operation code of this instruction). Accordingly, the
value "5679H" saved to stack (1232H, 1233H) in the example shown in Figure B.3-7 "Execution
example of CALLV #3" is the address (return address) of the next operation code after "MOVW
A,PC".
(Main routine)
(Subroutine)
MOVW
A, #PUTSUB
PUTSUB
XCHW A, EP
XCHW
A, PC
PUSHW A
DB
'PUT OUT DATA',EOL
PTS1
MOV A, @EP
MOVW
A, 1234H
INCW EP
MOV IO, A
CMP A, #EOL
BNE PTS1
POPW A
XCHW A, EP
JMP @A
Table d ata
output here
(Before execution)
(After execution)
PC
SP
5 6 7 8H
1 2 3 4H
PC
SP
F E D CH
1 2 3 2H
X XH
F EH
D CH
1 2 3 2H
1 2 3 3H
F F C 6H
F F C 7H
5 6H
7 9H
F EH
D CH
1 2 3 2H
1 2 3 3H
F F C 6H
F F C H
(-2)
7