46
µ
PD17062
6.4 NOTES ON USING THE GENERAL-PURPOSE REGISTER
This section provides notes on using the general-purpose register, referring to the following example:
Example
AND RPL, #000B ; RP ← 0000010B
OR RPL, #0100B ;
MOV BANK, #0000B ; BANK0
LD 04H, 32H
Executing the above instructions loads the contents of address 32H of BANK0 data memory into address
24H in the general-purpose register of BANK0.
In the above example, the general-purpose register is allocated in row address 2H of BANK0, so that the
address of the general-purpose register specified in r in instruction LD r, m is address 24H of BANK0. The
data memory address specified in m is address 32H of BANK0. (See Fig. 6-5.)
Note that it is necessary to code an actual data memory address, for example, 24H, as the value specified
in r when using the assembler. In this case, only the low-order four bits are needed as the value for r, so the
assembler ignores value 2H, which is a row address. Thus, executing instruction LD 24H, 32H produces the
same result as executing the instruction in the above example.
If, when using the assembler, the address of the general-purpose register is specified directly in an operand
of an instruction, as shown below, an error occurs.
Instruction that causes an error
LD 04H, 32H ; The address of the general-purpose register is coded as 04.
Most commonly used method
R1 MEM 0.04H ;
M1 MEM 0.32H ; R1 and M1 are defined as memory-type addresses, and are
LD R1, M1 ; assigned addresses 04H and 32H of BANK0, respectively.
Executing the following instructions produces the same result as executing the instructions in because
R1 and R2 are assigned the same column address.
R2 MEM 0.34H
M1 MEM 0.32H
LD R2, M1