APPENDIX C Instruction Overview
(Main routine)
MOVW
XCHW
DB
MOVW
CALLV #vct
This instruction is used to branch to a subroutine address stored in the vector table. The instruction saves
the return address (contents of PC) in the location at the address contained in SP (stack pointer), and uses
vector addressing to cause a branch to the address stored in the vector table. Because CALLV #vct is a 1-
byte instruction, the use of this instruction for frequently used subroutines can reduce the entire program
size.
Figure C.2-7 shows a summary of the instruction.
After the CALLV #vct instruction is executed, the contents of PC saved on the stack area are the address of
the operation code of the next instruction, rather than the address of the operation code of CALLV #vct.
Accordingly, Figure C.2-7 shows that the value saved in the stack (1232
the address of the operation code of the instruction that follows "CALLV #vct" (return address).
568
Figure C.2-6 Example of Using "XCHW A, PC"
A, #PUTSUB
A, PC
'PUT OUT DATA', EOL
A, 1234H
Figure C.2-7 Example of Executing CALLV #3
(Before executing)
PC
5 6 7 8
H
SP
(-2)
1 2 3 4
H
1 2 3 2
X X
H
H
1 2 3 3
X X
H
H
F F C 6
F E
H
H
F F C 7
D C
H
H
(Subroutine)
PUTSUB
PUSHW A
PTS1
MOV A, @EP
INCW EP
MOV IO, A
CMP A, #EOL
BNE PTS1
POPW A
XCHW A, EP
JMP @A
(After executing)
PC
F E D C
H
SP
1 2 3 2
H
1 2 3 2
5 6
H
H
1 2 3 3
7 9
H
H
F F C 6
F E
H
H
F F C 7
D C
H
H
Output table
data here
and 1233
) is 5679
, which is
H
H
H