Direct Addressing Mode
6-6
6.2.1
Using Direct Addressing Mode
When you use direct addressing mode, the processor uses the DP to find the
data page and uses the seven LSBs of the instruction register to find a particu-
lar address on that page. Always do the following:
1) Set the data page. Load the appropriate value (from 0 to 511) into the DP.
The DP register can be loaded by the LDP instruction or by any instruction
that can load a value to ST0. The LDP instruction loads the DP directly
without affecting the other bits of ST0, and it clearly indicates the value
loaded into the DP. For example, to set the current data page to 32 (ad-
dresses 1000h–107Fh), you can use:
LDP #32
;Initialize data page pointer
2) Specify the offset. Supply the 7-bit offset as an operand of the instruction.
For example, if you want the ADD instruction to use the value at the second
address of the current data page, you would write:
ADD 1h
;Add to accumulator the value in the current
;data page, offset of 1.
You do not have to set the data page prior to every instruction that uses direct
addressing. If all the instructions in a block of code access the same data page,
you can simply load the DP at the front of the block. However, if various data
pages are being accessed throughout the block of code, be sure the DP is
changed whenever a new data page should be accessed.
6.2.2
Examples of Direct Addressing
In Example 6–3, the first instruction loads the DP with 000000100
2
(4) to set
the current data page to 4. The ADD instruction then references a data
memory address that is generated as shown following the program code. Be-
fore the ADD instruction is executed, the opcode is loaded into the instruction
register. Together, the DP and the seven LSBs of the instruction register form
the complete 16-bit address, 0000001000001001
2
(0209h).