8

The "warning: signed dword immediate exceeds bounds" is the bane of my existence at the moment as it appears to be inconsistent or I am just not seeing an obvious fact.

I have the following structure declared:

struc   FRTType        
        .class    resq  1   ; Class
        .type     resq  1   ; Type
endstruc 

I have the following assigns:

%assign TYPE_SCALAR     0xfffffffffffffff1
%assign INTEGER         0xffffffff1000a8a9

And in a function I have:

cmp     qword [rdi+FRTType.class], TYPE_SCALAR  ; This works fine
jne     .exception
cmp     qword [rdi+FRTType.type], INTEGER       ; THIS PRODUCES WARNING

I know I can mov rax, INTEGER and then do the compare but that seems unneeded given the first compare has no problem.

Frank C.
  • 7,758
  • 4
  • 35
  • 45

1 Answers1

11

There's no CMP r/m64,imm64.
There's CMP r/m64,imm32, where imm32 is sign-extended to 64 bits. Which works fine for 0xfffffffffffffff1, because 0xfffffff1 sign-extended to 64 bits is 0xfffffffffffffff1. But 0x1000a8a9 sign-extended to 64 bits is 0x000000001000a8a9, which differs from the value you wanted to compare against.

You could overcome this e.g. by loading the immediate into a register first:

mov rax, INTEGER
cmp     qword [rdi+FRTType.type], rax
Michael
  • 57,169
  • 9
  • 80
  • 125
  • Ipso facto, I missed an obvious fact. Staring at the Intel instruction guide it is clear that "sometimes you have to step away from the vehicle". Thank you Michael! – Frank C. Oct 29 '16 at 10:25