几个c++语句的汇编实现(H1指令)

;*p = 5
ldc 5 ;
push
ldp;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;ldresult,***q's value
stx;x = ***q;
ld x;
dout
ldc '\n'
aout
;*(p+1) = 6
ldc 6
push
ld p + 1;load (p+1)'s value,should 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: should be 5
add @1
push
ld p
sti;save *p+1 to *p
ld p
ldi;addr 80 value: should be 6
dout
ldc '\n'
aout
;r = p
ld p;ac = p's addr
st r
ld r
dout
halt
p:dw80
dw81
q:dw * + 1;*q is next address.(* + 1)
dw* + 1;**q is next address.(* + 1)
dw * + 1;***q is next address.(* + 1 = result)
result:dw0
x:dw 0
r:dw 0
@1:dw 1

你可能感兴趣的:(C++,c,C#)