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

1

5

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?

Holladay answered 13/3, 2019 at 17:32 Comment(2)
That's absolutely not normal. Where are you executing this?Rendition
I use a VirtualBox virtual machine with Win98 and MASM 6.11 installed. The screenshots are from the ProgrammersWorkBench (PWB) that is included in the distribution of MASM, as well as the CodeView debugger. This happens only to EBX, all other GP-registers hold 32-bit values. Firstly I thought that this might happen due to the segment word size, that is set to 16-bit, as I use .MODEL before the .386 directive. But now I do not see any dependence.Holladay
R
6

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.

Rie answered 13/3, 2019 at 18:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.