Getting the error "signed byte value exceeds bounds" for code that should be valid.
USE64
and eax, 0xFFFFFFF0
NASM compiles this as '83 E0 F0' where 0x83 is the opcode for doing an AND with an IMM8
YASM compiles this as '25 F0 FF FF FF' where 0x25 is the opcode for doing an AND EAX, IMM32
Is this a bug in NASM? Tested with "NASM version 2.09.08 compiled on Apr 6 2011"
Thanks,
-Ian
Well, you may add -O0 so nasm would not optimize sources.
Meanwhile it's incorrect I believe to inform a user with such warning, I'll take a look as only time permits. Thanks for report!
The real bug is in the reporters code: the directive is called "bits 64", not "use64".
Weird ... I posted a correction but it looks like Sourceforge ate it.
This is indeed an invalid warning. It's a perfectly valid representation of a 32-bit instruction in 64-bit mode.
I can't reproduce this in latest git version. I believe it has been fixed in 6dfbddb6, which always sets P_O32 thus closing the hole in 41f1f2ba.
Maybe it's time to get 2.10 out?
Yes, that warning is gone in 2.10rc... and that is actually a real NASM bug!
The user wants 64-bit code -- so imm[8|16|32] gets sign-extended to imm64.
The user also wants 0xFFFFFFF0 -- which is imm64=0x00000000FFFFFFF0.
That value cannot be expressed with the imm8 encoding.
So the assembler either needs to avoid that encoding, or emit the warning.
That value cannot be expressed with the imm32 encoding either.
However, because 32-bit operations zero-extend the upper 32 bits, the end
result (RAX = 0x00000000???????0) will resemble what the user asked for.
So emitting the 32-bit encoding without warning is acceptable.
It's a 32-bit operation... there is no "approximation" involved. If there is no warning for the same instruction with rax, that would be a bug.
Related to this I also get the error "warning: signed dword immediate exceeds bounds" for the code below (1 warning for each):
and rdx, 0xFFFFFFF0
and rsi, 0xFFFFFFF0
I got this warning with "NASM version 2.10rc4 compiled on Feb 28 2011" as well as 2.09.
you can use following combination:
mov rax, 0x123456789abcdef0 ; 64-bit constant
and rcx, rax ; AND rcx with constant