0

For a program I'm writing in assembly %eax points to a memory address which contains a value that I want to move into %rdi. To do this I implemented the following: mov (%eax), %rdi However, this gives a segmentation fault. How come this gives a seg fault? And what can I do to fix it?

Jester
  • 56,577
  • 4
  • 81
  • 125
  • 6
    In 64 bit mode your address should be 64 bits. Use `rax` not `eax` and make sure it's loaded with the full 64 bits of the address. `eax` may work if you know your address is in the 32 bit range, but given the segfault, that seems not to be the case. – Jester Oct 07 '21 at 13:34
  • Also a duplicate of [Segmentation fault when writing assembly version of reference operator](https://stackoverflow.com/q/66272685) which is unanswered. Looking for a simple canonical Q&A that explains that pointers are 64-bit. – Peter Cordes Oct 07 '21 at 22:41

0 Answers0