flat assembler
Message board for the users of flat assembler.
  
|  Index
      > Compiler Internals > cmp rax, 0xffffffff | 
| Author | 
 | 
| l_inc 10 Jun 2015, 23:39 RIxRIpt
 Quote: It's possible to assemble this in x64 dbg and the hexcode is x64dbg assembles this incorrectly. The immediate is sign-extended and the comparison is therefore made with 0xffffffffffffffff, not with 0xffffffff. _________________ Faith is a superposition of knowledge and fallacy | |||
|  10 Jun 2015, 23:39 | 
 | 
| revolution 11 Jun 2015, 00:56 Values between -2^31 (0xffffffff80000000, stored as 0x80000000) and +2^31-1 (0x000000007fffffff, stored as 0x7fffffff) are encodable. Your number is 2^32-1 (0x00000000ffffffff) and cannot be encoded, because, as l_inc says, sign extending a stored value of 0xffffffff gives an absolute value 2^64-1 (0xffffffffffffffff). | |||
|  11 Jun 2015, 00:56 | 
 | 
| shutdownall 11 Jun 2015, 08:44 When you use explicitly declaration you will get a more detailed error message.     Code: cmp rax, qword 0xffffffff throws "Error: not encodable with long immediate" instead of just "Error: value out of range" It is possible to use Code: mov rbx,0xffffffff cmp rax,rbx instead. | |||
|  11 Jun 2015, 08:44 | 
 | 
| revolution 11 Jun 2015, 08:48 shutdownall wrote: When you use explicitly declaration you will get a more detailed error message. Code: cmp rax,qword 0 error: not encodable with long immediate. | |||
|  11 Jun 2015, 08:48 | 
 | 
| shutdownall 11 Jun 2015, 08:50 revolution wrote: Well actually that error is for all values: Yes, but if you omit the manual type conversion it is just "value out of range" for all values. I think the "not encodable" message is more clear.  | |||
|  11 Jun 2015, 08:50 | 
 | 
| revolution 11 Jun 2015, 08:53 shutdownall wrote: Yes, but if you omit the manual type conversion it is just "value out of range" for all values. | |||
|  11 Jun 2015, 08:53 | 
 | 
| RIxRIpt 11 Jun 2015, 10:24 Thanks for the answers, I think I got it.
 That's what I've found: Code: ;page 622 of Intel's manual Opcode Instruction Op/ 64-Bit Compat/ Description En Mode Leg Mode REX.W + 3D id CMP RAX, imm32 I Valid N.E. Compare imm32 sign-extended to 64-bits with RAX. and there's no cmp instruction with imm64 operand  . | |||
|  11 Jun 2015, 10:24 | 
 | 
| revolution 11 Jun 2015, 10:42 RIxRIpt wrote: and there's no cmp instruction with imm64 operand | |||
|  11 Jun 2015, 10:42 | 
 | 
| < Last Thread | Next Thread > | 
| Forum Rules: 
 | 
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.