IP2022 Users ManualInstruction Set Architecture
www.ubicom.com
69
The following code example uses indirect-with-offset addressing.
When bit 7 of the fr field is set, the SPH/SPL register (i.e. the
stack pointer) is selected as the pointer register. The upper four
bits of the SPH register are not used. Figure 3-6 shows indirect-
with-offset addressing using the SPH/SPL register as the pointer
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. This stack addressing mechanism
is independent from the hardware stack used for subroutine call
and return.
When a pop instruction is used with the indirect-with-offset
addressing mode, the address calculation for the fr operand is
made using the value in the SPH/SPL register before the
automatic increment, even though the stack operand itself is
addressed using the value after the automatic increment.
MyStuff= 0x0385
;define address MyStuff
loadh
MyStuff
;load the high byte of the
;DPH/DPL register with 0x03
loadl
MyStuff
;load the low byte of the
;DPH/DPL register with 0x85
mov
w,8(dp)
;load W with the contents of
;the memory location at
;address 0x38D
;(i.e. 0x385 + 0x008)