Reputation: 11
i am trying to implement a for-loop using assembler coding and in each iteration the value of the register edi should be printed. When I try to execute my code, I get an Error "Segmentation fault(core dumped)". Can somebody please tell me what does this error mean and are there any mistakes in my code?
section .text
global _start
_start:
xor edi,edi
loop:
add edi,'0'
;print i
mov edi,1
mov esi,1
mov ecx,[edi]
mov edx,1
syscall
sub edi,'0'
inc edi
cmp edi,5
jl loop
Upvotes: 1
Views: 739
Reputation: 162269
It means that you attempted to access address space in a way that's not permitted. For example:
you might have tried to write to a read only location
you might have tried to read from a write only location
you might have tried to execute code from a location without execute permissions set
you might have tried to read or write from an address either not mapped at all, or mapped with all kinds of access disallowed
And there are a few more conditions that cause this signal to trip. Have a look at the man pages of mmap
and mprotect
to get an idea of what's possible.
Upvotes: 2