汇编程序编写:
assume cs:code
code segment
mov ax,2000h
mov ss,ax
mov sp,0
add sp,10
pop ax
pop bx
push ax
push bx
pop ax
pop bx
mov ax,4c00h
int 21h
code ends
寄存器:ax bx ss sp
ax, bx, ss, sp, 2000:10 x, 2000:12 y
step0:mov ax,2000h
ax=2000h, bx, ss, sp, 2000:10 x, 2000:12 y
step1:mov ss,ax
ax=2000h, bx, ss=2000h, sp, 2000:10 x, 2000:12 y
step2:mov sp,0
ax=2000h, bx, ss=2000h, sp=0, 2000:10 x, 2000:12 y
step3:add sp,10
ax=2000h, bx, ss=2000h, sp=10, 2000:10 x, 2000:12 y
step4:pop ax
ax=x, bx, ss=2000h, sp=12, 2000:10 x, 2000:12 y
step5:pop bx
ax=x, bx=y, ss=2000h, sp=14, 2000:10 x, 2000:12 y
step6:push ax
ax=x, bx=y, ss=2000h, sp=12, 2000:10 x, 2000:12 x
step7:push bx
ax=x, bx=y, ss=2000h, sp=10, 2000:10 y, 2000:12 x
step8:pop ax
ax=y, bx=y, ss=2000h, sp=12, 2000:10 x, 2000:12 y
step9:pop bx
ax=y, bx=x, ss=2000h, sp=14, 2000:10 x, 2000:12 y