I have a very basic assembly program that runs in Linux userland:
section .text
global _start
_start:
mov edx, 14
mov ecx, msg
mov ebx, 1
mov eax, 4
syscall
mov eax, 1
syscall
section .data
msg db "Hello, World!", 0xA
However, this doesn’t work as it is, but only if I replace the syscalls with int 0x80. Don’t these do the same thing? I know that syscall was designed to be lower-latency, but other than that, I didn’t think there was a difference. Why doesn’t it work?
Advertisement
Answer
syscall works only in x86-64 operating systems and you should put the system call number in rax register instead of eax.
See this website for more information.