Ubuntu 16.04, intel core i5
I'm experementing with assembly language and wrote the following simple program:
section .text
global _start
_start:
mov eax, 0x04
mov ebx, 0x01
mov ecx, text
mov edx, 0x03
syscall
mov eax, 0x01
syscall
segment .data
text db 'The text'
When I compile it as follows:
nasm -f elf64 main.asm
ld -o bin main.o
and then run I got Segmentation fault
. But when I replace syscall
with int 0x80
and compile 64-bit binary :
section .text
global _start
_start:
mov eax, 0x04
mov ebx, 0x01
mov ecx, text
mov edx, 0x03
int 0x80
mov eax, 0x01
int 0x80
segment .data
text db 'The text'
It works fine and prints what I want.
If we replace only one syscall:
section .text
global _start
_start:
mov eax, 0x04
mov ebx, 0x01
mov ecx, text
mov edx, 0x03
syscall
mov eax, 0x01
int 0x80
segment .data
text db 'The text'
It does not Segfault, but it does not print anything as well. What did I do wrong? Why doesn't syscall work as I expect?