; * P = 5
LDC 5;
Push
Ld p; load P's Value
STI; save 5 to Mem [P's value]
LDI; get the value
Dout
LDC '/N'
Aout
; *** Q = 10
LDC 10
Push
Ld q; AC = 17 * q's ADDR
LDI; AC = 18 ** Q's ADDR
LDI; AC = 19 *** Q's ADDR
STI; Save 10 to *** Q, this address is result
; X = *** Q
LDI; LD result, *** Q's Value
St X; X = *** Q;
Ld x;
Dout
LDC '/N'
Aout
; * (P + 1) = 6
LDC 6
Push
LD p + 1; load (p + 1)'s value, shocould be 81
STI; save 6 to * (p + 1)
LDI; * (p + 1). Value, get the value
Dout; check the value if 6
LDC '/N'
Aout
; * P = * p + 1
Ld p; 80
LDI; ADDR 80 value: shocould be 5
Add @ 1
Push
LD P
STI; save * p + 1 to * P
LD P
LDI; ADDR 80 value: shocould be 6
Dout
LDC '/N'
Aout
; R = P
Ld p; AC = P's ADDR
St R
LD R
Dout
Halt
P: DW 80
DW 81
Q: DW * + 1; * q is next address. (* + 1)
DW * + 1; ** Q is next address. (* + 1)
DW * + 1; *** Q is next address. (* + 1 = Result)
Result: DW 0
X: DW 0
R: DW 0
@ 1: DW 1