6.2在代码段中使用栈 出现不可思议的的结果,求高手指点
assume cs:codesgcodesg segment
dw 0123h,0456h,0789h,0abch,0defh,0fedh,0cbah,0987h
dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
start: mov ax,cs
mov ss,ax
mov sp,32
mov bx,0
mov cx,8
s: push cs:
add bx,2
loop s
mov bx,0
mov cx,8
s0: pop cs:
add bx,2
loop s0
mov ax,4c00h
int 21h
codesg ends
end start
程序单步运行到CX=0002H时 cs:000c=0000按理应该是cs000c=0cbah啊 首先你看好 你的是 mov sp,32
然后再看 dw 0123h,0456h,0789h,0abch,0defh,0fedh,0cbah,0987h
db 是字节为单位 dw 字为单位 dd 双字为单位
dw 0123h,0456h,0789h,0abch,0defh,0fedh,0cbah,0987h ;你这么有了 32个字节了而你sp又是32所以结果那样
小熊猫party 发表于 2011-12-27 11:16 static/image/common/back.gif
首先你看好 你的是 mov sp,32
然后再看 dw 0123h,0456h,0789h,0abch,0defh,0fedh,0cbah,0987h
32应该改为多少? 你的不就是书上的代码吗?? 书上不是30H吗 照改就可以了啊 MASM要注意进制问题哦 sp 改成 64吧! mov sp,64 应该是sp=32h吧你是dw以字形定义数据的一个逗号前就是两个偏移地址,从0开始到49(31h)栈顶指针就应该是32h吧
页:
[1]