Why this assembly code assemble and link fine but show segment fault in runtime. Commented after the instruction to give a idea what I wanted to do.
jmp short init
action:
pop esi
xor eax, eax
mov byte [esi+24], al ;null terminating the string.
mov dword [esi+25],24 ;length of the string
mov al,4 ;syscall write
mov ebx,1 ;standard out
lea ecx,[esi] ;<<---------- Unsure about this. probably load the address of the string to ecx
mov edx,[esi+25] ;<<-- load edx with string length
int 80h
init:
call action
db "what a pity! not working#LLLL"
I am using NASM to assemble and ld to link. This program will run on a 64-bit machine but I want it to be 32-bit compatible.
section .text(which Nasm will default to, if you don't say) which is read-only memory. Attempting to alter it will segfault. If it ran, it would loop forever. I don't see asys_exitin there...