Variable in memory not updated by a store to that symbol

妖精的绣舞 提交于 2020-04-07 07:49:50

问题


When I run the emu8086, this result(ans) return to me 0 ..Why ?

data segment
ans dw ? 
ends

stack segment
    dw   128  dup(0)
ends

code segment
start:
mov ax,@data
mov dx,ax
mov ax,2
mov bl,2
mul bl
mov ans,ax
mov ax, 4c00h
int 21h  
ends
end start

回答1:


mov ax,@data
mov dx,ax

This part of the code must setup the DS segment register.
You made a typo and wrote DX instead!

mov ax, @data
mov ds, ax

Because of this error, the result of your AL * BL multiplication (4) was still written in memory by mov ans,ax but it didn't make it to the data segment. It overwrote the first word of the ProgramSegmentPrefix because that was where DS was pointing at.



来源:https://stackoverflow.com/questions/46875195/variable-in-memory-not-updated-by-a-store-to-that-symbol

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!