[英]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.