[Nasm-bugs] [Bug 3392655] "mov al, var" does not cause warning when "var" evaluates to 7C10h (in-section offset 10h within org 7C00h section)

noreply-nasm at dev.nasm.us noreply-nasm at dev.nasm.us
Tue Mar 31 10:57:01 PDT 2020


https://bugzilla.nasm.us/show_bug.cgi?id=3392655

H. Peter Anvin <hpa at zytor.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|Medium                      |MediumLow
           Severity|normal                      |minor
             Status|OPEN                        |CONFIRMED

--- Comment #2 from H. Peter Anvin <hpa at zytor.com> ---
Unfortunately, this isn't actually an in-section offset, because it is
dependent on the offset of the section. "org 7C00h" is a linker directive (just
because in the case of bin/ihex/srec formats the linker is built into NASM
doesn't change that it is still a linker.) A true in-section offset either is
PC-relative (like a JMP, or in 64-bit mode a "rel" memory reference) or of the
form address-address, usually address-$$.

The problem, thus, is that NASM at assembly time has no idea if this is a valid
instruction or not, and the linker can't know if you have specified:

mov al,var & 0xff

... to intentionally extract the low 8 bits of the offset.

That being said, it probably would make sense for the bin linker to warn in
this case; most other linkers would.

NASM 2.12.02 was buggy and would always warn in this case, but that is not
correct as this is the responsibility of the linker.

I have checked in your test case as test/binoverflow.bin. I don't think this
will be addressed for 2.15.00, but at least it is recorded and should be fixed
in the future.

With an *actual* in-section offset, NASM will warn as expected:

        bits 16
        org 7C00h

start:
        mov al,foo-$$
        mov dl,bar-$$

bar:    db 0
        align 256
foo:    db 0


../nasm -Ox -I../misc -L+  -f bin -o insection.bin -MD insection.bin.dep -l
insection.bin.lst insection.asm
insection.asm:5: warning: byte data exceeds bounds [-w+number-overflow]

-- 
You are receiving this mail because:
You are watching all bug changes.
You are on the CC list for the bug.


More information about the Nasm-bugs mailing list