Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upper bits of EBX are zeroed out when single-stepping in CodeView

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:

enter image description here

Executing the (2) instruction not only loads the value into EAX, but also zero outs the upper half of EBX:

enter image description here

Why does it actually happen?

like image 826
jupiter_jazz Avatar asked Mar 13 '19 17:03

jupiter_jazz


1 Answers

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.

like image 79
Michael Petch Avatar answered Sep 22 '22 22:09

Michael Petch