I wrote a simple ASM Programm but sys_write is not giving any output. I guess that I did a mistake with the pointer into %ecx and sys_write can not access the string - but I do not find my mistake so far. Return code after sys_write is stored in %eax and is less 0.
There are a lot of "Hello World"-Examples but I like to understand what I am doing wrong and not the fact that there is other working code :-)
I use Intel-syntax with prefix.
the gdb output looks like this:
gdb ./testsasm GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1 ... Reading symbols from ./testsasm...done. (gdb) break main Breakpoint 1 at 0x4004d6: file t.asm, line 13. (gdb) n The program is not being run. (gdb) run Starting program: ...src/gnu_asm/testsasm Breakpoint 1, main () at t.asm:13 13 mov %ebx,0x1 # file handle stdout (gdb) n 14 mov %eax,0x4 # systemcall sys_write (gdb) n 15 mov %ecx,string # pointer of the string const (gdb) n 16 mov %edx,slen # string lenght (gdb) n 17 int 0x80 # call write (gdb) print $ecx $1 = 1819043144 (gdb) print $edx $2 = 7 (gdb) print *$ecx Cannot access memory at address 0x6c6c6548 (gdb)
Makefile and source can be found here: http://paste.ubuntu.com/23115239