[Nasm-devel] Question about Build warning with a 32bits value

Henrik Gramner henrik at gramner.com
Sat Jul 2 11:53:15 PDT 2022


An immediate operand for an x86 instruction operating on 64-bit
integers cannot exceed the range of a signed 32-bit integer which will
be implicitly sign-extended to 64-bit (except for movabs which
explicitly takes a 64-bit immediate).

Some possible alternatives:

a) with 32-bit wrapping, zeroing the upper 32 bits:
add ecx, 0xFFFFF000 (add ecx, -4096)

b) with sign-extension to 64-bit:
add rcx, 0xFFFFFFFFFFFFF000 (add rcx, -4096)

Henrik

On Sat, Jul 2, 2022 at 8:09 PM Li, SteveX <stevex.li at intel.com> wrote:
> Hi,
>
> I got some build warning by using NASM ver2.15.05 to compile the nasm file.
> The warning messages are “warning: signed dword immediate exceeds bounds [-w+number-overflow]”  and “warning: dword data exceeds bounds [-w+number-overflow]”.
> In the source code, it is “add rcx 0xFFFFF000”.
>
> I have test two trials which could make the warning messages disappear.
>
> Change the value from 0xFFFFF000 to 0x0, 0xFF, 0x7FFFF000 …… etc.
> Replace it by
> mov rbx 0xFFFFF000
> add rcx rbx
>
> In the first trial, I just want to make sure the value is the root cause for these warning messages.
>
> Do I have any other way to avoid the warning?
>
> Best Regards,
>
> SteveX Li



More information about the Nasm-devel mailing list