Assembly keep getting seg fault when working with stack [migrated]
- by user973917
I'm trying to learn assembly and have found that I keep getting segfaults when trying to push/pop data off of the stack. I've read a few guides and know how the stack works and how to work with the stack; but don't know why I keep getting the error.
Can someone help?
segment .data
myvar: db "hello world", 0xA0, 0
myvarL: equ $-myvar
segment .text
global _start
_start:
push ebp
mov ebp, esp
push myvarL
push myvar
call _hworld
_hworld:
mov eax, 4
mov ebx, 1
mov ecx, [ebp+4]
mov edx, [ebp+8]
pop ebp
int 0x80
ret
I'm assuming that the +4 is 32 bits, then +8 is 64 bits. It isn't really clear to me why this way is being done on some of the guides I've read. I would assume that myvar is 13 bits?