I have a problem with calling a function, which uses stack. The output of the program contains a lot of trash, it's like length of the string is wrong:
.code32
.equ kernel, 0x80
.equ stdout, 0x01
.equ write, 0x04
.equ exit, 0x01
.section .data
sum:
.ascii "text"
.equ lensum, . - sum
.section .text
.type writetxt, @function
writetxt:
movl $write, %eax
movl $stdout, %ebx
popl %ecx
pop %edx
int kernel
ret
.global _start
_start:
pushl $lensum
pushl $sum
call writetxt
movl $exit, %eax
movl $0, %ebx
int $kernel
I know that it is something with the function return address residing on stack, but i have no clue how to fix it