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?
Asked
Active
Viewed 42 times
0

Jester
- 56,577
- 4
- 81
- 125

user16806508
- 41
- 2
-
6In 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