2

I am writing a self modifying code.

movq      $TARGET_CIA, 0x550(%rax)

This symbol TARGET_CIA is undefined initially and at run time I try to copy a 64 bit immediate value to this location. But at compile time this instruction takes the value of this undefined immediate value as 32 bit and when i try to copy the 64 bits, I see the signed extended 32 bits at its place. Is there a way to get this undefined symbol treated as 64 bit value?

skaffman
  • 398,947
  • 96
  • 818
  • 769
user403219
  • 121
  • 2
  • 8
  • 1
    Possible same: http://stackoverflow.com/questions/19415184/load-from-a-64-bit-address-into-other-register-than-rax – Ciro Santilli OurBigBook.com May 24 '15 at 21:05
  • Possible duplicate of [Difference between movq and movabsq in x86-64](https://stackoverflow.com/questions/40315803/difference-between-movq-and-movabsq-in-x86-64) – phuclv Jul 04 '18 at 04:24

2 Answers2

12

You need

movabs $0x1234567890abcdef, 0x550(%rax)

The movabs instruction is required for 64 bit immediates.

Gunther Piez
  • 29,760
  • 6
  • 71
  • 103
0

I'd simply run another instruction to grab the second 32 bits. May not be the best way as I haven't done any ASM for a while, however it WILL work. :)

Good Luck Luke Peterson

Luke Peterson
  • 8,584
  • 8
  • 45
  • 46