马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 NWm 于 2011-6-4 17:19 编辑
按照书本上的意思,应该是指pop之后只是改变了栈的栈顶指针,并没有对原栈顶进行修改,但是我在做实验五习题一的时候发现了如下情况:
-t
AX=141B BX=0000 CX=0042 DX=0000 SP=0010 BP=0000 SI=0000 DI=0000
DS=141B ES=140B SS=141C CS=141D IP=000D NV UP EI PL NZ NA PO NC
141D:000D FF360000 PUSH [0000] DS:0000=0123
-d ss:0
141C:0000 00 00 00 00 00 00 1B 14-00 00 0D 00 1D 14 0D 0E ................
141C:0010 B8 1C 14 8E D0 BC 10 00-B8 1B 14 8E D8 FF 36 00 ..............6.
141C:0020 00 FF 36 02 00 8F 06 02-00 8F 06 00 00 B8 00 4C ..6............L
141C:0030 CD 21 36 03 17 B8 1D 14-8E D8 8B C2 89 07 E2 E3 .!6.............
141C:0040 B8 00 4C CD 21 00 00 00-00 00 00 00 00 00 00 00 ..L.!...........
141C:0050 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
141C:0060 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
141C:0070 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
可以看到,栈底为1D 14 0D 0E,运行连续两步入栈操作后:
-t
AX=141B BX=0000 CX=0042 DX=0000 SP=000C BP=0000 SI=0000 DI=0000
DS=141B ES=140B SS=141C CS=141D IP=0015 NV UP EI PL NZ NA PO NC
141D:0015 8F060200 POP [0002] DS:0002=0456
-d ss:0
141C:0000 00 00 1B 14 00 00 15 00-1D 14 0D 0E 56 04 23 01 ............V.#.
141C:0010 B8 1C 14 8E D0 BC 10 00-B8 1B 14 8E D8 FF 36 00 ..............6.
141C:0020 00 FF 36 02 00 8F 06 02-00 8F 06 00 00 B8 00 4C ..6............L
141C:0030 CD 21 36 03 17 B8 1D 14-8E D8 8B C2 89 07 E2 E3 .!6.............
141C:0040 B8 00 4C CD 21 00 00 00-00 00 00 00 00 00 00 00 ..L.!...........
141C:0050 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
141C:0060 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
141C:0070 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
可以看到,0123,0456已经成功入栈,接下来是连着两步出栈:
-t
AX=141B BX=0000 CX=0042 DX=0000 SP=0010 BP=0000 SI=0000 DI=0000
DS=141B ES=140B SS=141C CS=141D IP=001D NV UP EI PL NZ NA PO NC
141D:001D B8004C MOV AX,4C00
-d ss:0
141C:0000 00 00 1B 14 1B 14 1B 14-00 00 1D 00 1D 14 0D 0E ................
141C:0010 B8 1C 14 8E D0 BC 10 00-B8 1B 14 8E D8 FF 36 00 ..............6.
141C:0020 00 FF 36 02 00 8F 06 02-00 8F 06 00 00 B8 00 4C ..6............L
141C:0030 CD 21 36 03 17 B8 1D 14-8E D8 8B C2 89 07 E2 E3 .!6.............
141C:0040 B8 00 4C CD 21 00 00 00-00 00 00 00 00 00 00 00 ..L.!...........
141C:0050 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
141C:0060 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
141C:0070 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
仅出栈,并没有做任何其他的动作,出栈之后原来栈中的数据变化了,求解,何故?
代码如下:assume cs:code,ds:data,ss:stack
data segment
dw 0123h,0456h,0789h,0abch,0defh,0fedh,0cbah,0987h
data ends
stack segment
dw 0,0,0,0,0,0,0,0
stack ends
code segment
start: mov ax,stack
mov ss,ax
mov sp,10h
mov ax,data
mov ds,ax
push ds:[0]
push ds:[2]
pop ds:[2]
pop ds:[0]
mov ax,4c00h
int 21h
code ends
end start
|