简体   繁体   English

NASM是不一致还是我只是错过了即时CMP的明显事实?

[英]Is NASM inconsistent or am I just missing an obvious fact with CMP of immediate?

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. “警告:签名的dword立即超出界限”是我现在存在祸害,因为它似乎不一致或者我只是没有看到明显的事实。

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. 我知道我可以移动mov rax, INTEGER然后进行比较,但这似乎不需要,因为第一次比较没有问题。

There's no CMP r/m64,imm64 . 没有CMP r/m64,imm64
There's CMP r/m64,imm32 , where imm32 is sign-extended to 64 bits. CMP r/m64,imm32 ,其中imm32符号扩展为64位。 Which works fine for 0xfffffffffffffff1 , because 0xfffffff1 sign-extended to 64 bits is 0xfffffffffffffff1 . 这适用于0xfffffffffffffff1 ,因为0xfffffff1符号扩展为64位是0xfffffffffffffff1 But 0x1000a8a9 sign-extended to 64 bits is 0x000000001000a8a9 , which differs from the value you wanted to compare against. 0x1000a8a9符号扩展为64位是0x000000001000a8a9 ,它与您想要比较的值不同。

You could overcome this eg by loading the immediate into a register first: 您可以通过首先将立即加载到寄存器中来克服此问题:

mov rax, INTEGER
cmp     qword [rdi+FRTType.type], rax

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM