FUJITSU Semiconductor Controller MB89950/950A User Manual

Page 290

Advertising
background image

276

APPENDIX

XCHW A, PC

This instruction swaps the contents of A and PC, resulting in a branch to the address contained in A before

execution of the instruction. After the instruction is executed, A contains the address that follows the

address of the operation code of MOVW A, PC. This instruction is effective especially when it is used in

the main routine to specify a table for use in a subroutine.

Figure B.3-5 "XCHW A, PC" shows a summary of the instruction.

Figure B.3-5 XCHW A, PC

After the XCHW A, PC instruction is executed, A contains the address of the operation code of the next

instruction, rather than the address of the operation code of XCHW A, PC. Accordingly, Figure B.3-5

"XCHW A, PC" shows that A contains 1235

H

, which is the address of the operation code of the instruction

that follows XCHW A, PC. This is why 1235

H

is stored instead of 1234

H.

Figure B.3-6 "Example of using XCHW A, PC" shows an assembly language example.

Figure B.3-6 Example of using XCHW A, PC

1 2 3 4

H

A

PC

1 2 3 5

H

A

PC

(Before execution)

(After execution)

5 6 7 8

H

5 6 7 8

H

MOVW

XCHW

DB

MOVW

A, #PUTSUB

A, PC

'PUT OUT DATA', EOL

A, 1234

H

(Main routine)

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

(Subroutine)

Output table
data here

Advertising