Fujitsu MB89202 Computer Hardware User Manual


 
389
XCHW A, PC
This instruction replaces the contents of A and the contents of PC, resulting in a branch to the address
indicated by the contents of A before execution. The contents of A after execution become the value of the
address next to the address holding the operation code, XCHW A, PC. This instruction is useful especially
when a table is specified in the main routine and a subroutine uses it.
Figure B.2-5 shows an overview.
Figure B.2-5 XCHW A, PC
After execution of this instruction, the contents of A do not become the address holding the operation code
of this instruction. Instead, they are the same as the address holding the next instruction. In Figure B.2-5 ,
therefore, the value stored in A is 1235
H
, agreeing with the address holding the operation code next to
XCHW A, PC. Note that it is not 1234
H
but 1235
H
.
Figure B.2-6 shows an example of assembler coding.
Figure B.2-6 Usage Example of XCHW A, PC
A
PC
A
PC
(Before execution) (After execution)
1234
H
5678
H
1235
H
5678
H
MOVW
XCHW
DB
MOVW
A, #PUTSUB
A, PC
'PUT OUT DATA', EOL
A, 1234H
XCHW A, EP
PUSHW A
MOV A, @EP
INCW EP
MOV IO, A
CMP A, #EOL
BNE PTS1
POPW A
XCHW A, EP
JMP @A
PUTSUB
PTS1
(Main routine)
(Subroutine)
Outputs a
table data
unit.
.
.
.
.
.
.