Вы находитесь на странице: 1из 1

Indirect addressing

Oprnd = Mem[Mem[OprndSpec]]
With indirect addressing, the operand specifier is the address in
memory of the address of the operand. The compiler translates the
assignment statement as
0012 C00005 LDWA 5,i ;*a = 5
0015 E20003 STWA a,n

where n in the store word instruction indicates indirect addressing. At


this point in the execution, the operand is computed as

Mem[Mem[OprndSpec]]
Mem[Mem[0003]]
Mem[007F]

which is the first cell in the heap. The store word instruction stores 5 in
main memory at address 007F.
The compiler translates the assignment of global pointers the same
as it would translate the assignment of any other type of global
variable. It translates
c = a;

as
0027 C10003 LDWA a,d ;c = a
002A E10007 STWA c,d

using direct addressing. At this point in the program, a contains 007F,


the address of the first cell in the heap. The assignment gives c the
same value, the address of the first cell in the heap, so that c points to
the same cell to which a points.
Contrast the access of a global pointer to the access of the cell to
which it points. The compiler translates
*a = 2 + *c;

as
0033 C00002 LDWA 2,i ;*a = 2 + *c

492

Вам также может понравиться