IP2022 Data Sheet
www.ubicom.com
37
The following code example uses indirect mode.
4.1.4
Indirect-with-Offset Modes
The indirect-with-offset addressing mode is used when bit
8 of the fr field is set. The location of the operand is
specified by a 7-bit unsigned immediate from the fr field
added to a 12-bit base address in a pointer register.
Addresses from 0x000 to 0x01F cannot be accessed
reliably with this addressing mode, therefore it must not
be used for this purpose. (Direct mode should be used
instead.)
When bit 7 of the fr field is clear, the DPH/DPL register
is selected as the pointer register. This register is
accessed using the loadh and loadl instructions,
which load its high and low bytes, respectively. The upper
four bits of the DPH register are not used. Figure 4-5
shows indirect-with-offset addressing using the DPH/DPL
register as the pointer register.
Figure 4-5 Indirect-with-Offset Mode, Data Pointer
The following code example uses indirect-with-offset
mode.
When bit 7 of the fr field is set, the SPH/SPL register is
selected as the pointer register. The upper four bits of the
SPH register are not used. Figure 4-6 shows indirect-with-
offset mode using the SPH/SPL register. In addition to this
indirect-with-offset addressing mode, there are also
push and pop instructions which automatically
increment and decrement the SPH/SPL register while
performing a data transfer between the top of stack and a
data memory location specified by the fr field. Stacks
grow down from higher addresses to lower addresses.
mov
w,#0x03
;load W with 0x03
mov
iph,w
;load the high byte of the
;indirect pointer from W
mov
w,#0x85
;load W with 0x85
mov
ipl,w
;load the low byte of the
;indirect pointer from W
mov
w,(ip)
;load W with the contents of
;the memory location at
;effective address 0x0385
MyStuff= 0x038D
;define address MyStuff
loadh
MyStuff ;load the high byte of the
;DPH/DPL pointer register
;with 0x03
loadl
MyStuff ;load the low byte of the
;DPH/DPL pointer register
;with 0x8D
mov
w,8(dp) ;load W with the contents of
;the memory location at
;effective address 0x038D
;(i.e. 0x0385 + 0x0008)
515-026.eps
128
Special-Purpose
Registers
DPH Register
DPL Register
7
0
n
0
n
7
n n n n n n n
X
3
4
7
X X X n n n
0
9-Bit "fr" Field
from Instruction
1
8
0 mmmmmmm
0
+
7
6
3840 Bytes
Data Memory
128
Global Registers