I am new to nasm and have written this code:
section .text
global _start
; just experimenting with functions
do_something:
mov DWORD [esp+0], 1;
mov DWORD [esp+4], 1;
mov DWORD [esp+0],0;
mov DWORD [esp+4],0;
ret ;
_start:
mov ecx,.Const.0;
mov edx,.Const.0.length;
call log ;
xor ecx, ecx ;
xor edx, edx ;
call do_something
xor ebx,ebx
mov eax, 1
int 0x80
.Const.0:
DB "Hello world!", 0xA
.Const.0.length equ $-.Const.0
But when calling the "hello_world" function, I get a segmentation fault, it looks like the esp register is causing the problem when put in the function. Any help would be greatly appreciated :D