Figure B.2-5 Xchw A,Pc; Figure B.2-6 Example Using Xchw A,Pc - Fujitsu F2MC-8L Series Hardware Manual

8-bit microcontroller
Hide thumbs Also See for F2MC-8L Series:
Table of Contents

Advertisement

Figure B.2-5 shows an outline of the instruction operation.
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 "1235
in A in the example shown in Figure B.2-5 is the address of the next operation code after
"XCHW A,PC". Therefore, the value of A is "1235
Figure B.2-6 shows an assembly language example.
(Main routine)
MOVW A,#PUTSUB
XCHW A,PC
DB
'PUT OUT DATA',EOL
MOVW A,1234
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 the PC) to the address corresponding to the
SP (stack pointer) and 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.2-5 XCHW A,PC

(Before execution)
5678
A
H
PC
1234
H

Figure B.2-6 Example Using XCHW A,PC

H
APPENDIX B Overview of Instructions
(After execution)
1235
A
H
5678
PC
H
", not "1234
".
H
H
(Subroutine)
PUTSUB XCHW A,EP
PUSHW A
PTS1
MOV A,@EP
INCW EP
MOV IO,A
CMP A,#EOL
BNE PTS1
POPW A
XCHW A,EP
JMP @A
" stored
H
Table data
output here.
315

Advertisement

Table of Contents
loading

Table of Contents