I have the following simple program written in MASM for an i386 processor:
TITLE BLA
.MODEL SMALL
.386
.STACK
.DATA
.CODE
MAIN PROC FAR
.STARTUP
MOV EBX,0FFFFFFFFH; (1)
MOV EAX,0EEEEEEEEH; (2)
.EXIT
MAIN ENDP
END
I am confused about the behavior of the EBX register. After the (1) instruction the EBX is set to 1-s:
Executing the (2) instruction not only loads the value into EAX, but also zero outs the upper half of EBX:
Why does it actually happen?
According to Microsoft this is a known bug in Codeview. See Knowledge Base article Q87548:
SYMPTOMS
When single-stepping or tracing through code in Microsoft CodeView versions 4.0, 4.01, and 4.05, the lower half of the 32-bit registers (eax, ebx, edi, etc.) is always preserved, but the upper half may be corrupted. Other 386- specific registers, such as the gs and fs registers, may also be corrupted. This problem also occurs when animating. This problem does not occur if the instructions are not executed one at a time.
STATUS
Microsoft has confirmed this to be a problem in CodeView version 4.0, 4.01, and 4.05. This problem was corrected in CodeView version 4.1.
According to this article the fix is to get a hold of Codeview 4.1 or greater.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With