0

I wrote a simple block of code to address windows virtual memory

push %eax
movl %ebx, %eax
and $0FFFFFFFFh, %eax
pop %eax

I get a few different errors regarding the expression 0FFFFFFFFh in that it is unable to interpret it as a memory address

Error: junk `FFFFFFFh' after expression
Error: missing or invalid immediate expression `0FFFFFFFFh'

I don't know what I could do to fix this, the code looks right, any help would be appreciated.

  • 2
    Your assembler does not support that hex format with the `h` suffix. You can do `0xFFFFFFFF` instead. Note that `and $0xFFFFFFFF, %eax` will not do anything of course. Also it's not referencing any memory as it is an immediate. – Jester May 07 '20 at 18:53
  • `and $0xFFFFFFFF, %eax` is a no-op (except for setting flags) because the mask has all bits set to `1`. **You can optimize that entire sequence of instructions to `test %ebx,%ebx`** (assuming the copy of EAX in memory below ESP is not valuable, because no standard 32-bit has a red-zone). `push %eax` rules out this being 64-bit code, but if it were 64-bit then `mov %ebx, %eax` would already have zero-extended into the full RAX. – Peter Cordes May 07 '20 at 19:35

0 Answers0