Reputation: 209
I just started learning linux 64bit assembly and was trying to really understand the differences between lea and mov.
But when creating a test file I get a segmentation fault of which I just do not understand why. The fault arises with the mov r10,[rax]
in the sample code. But when I change the place of mov r10,[rax]
with lea r11,[rax]
I get the fault when the lea is executed.
My program:
global _start
section .text
_start:
mov rax,16
lea r11,[rax]
mov r10,[rax]
mov r9,rax
mov rax,60
xor edi,edi
syscall
Upvotes: 0
Views: 61
Reputation: 9954
What do you expect at the memory location 16(0x10)?
Your code is
mov rax,16
mov r10,[rax]
which means that you try to load the 64bit value from memory address RAX
into R10
. The address 16 is normally not mapped into your program space.
Upvotes: 2