Since MS‑DOS, I know system invocation using interrupts. In old papers, I saw reference to int 80h
to invoke system functions on Linux. Since a rather long time now, I know int 80h
is deprecated in favour of the syscall
instruction. But I can't get it working on my 32 bits machine.
The question
Is the syscall
instruction to be used on 64 bits platform only? Doesn't 32 bits Linux makes use of syscall
?
A sample test
On my 32 bits Linux (Ubuntu Precise), this program terminates with a core dump:
global _start
_start:
mov eax, 4 ; 4 is write
mov ebx, 1 ; 1 is stdout
mov ecx, message ; address of string
mov edx, length ; number of bytes
syscall
mov eax, 1 ; 1 is exit
xor ebx, ebx ; return code 0
syscall
message:
db 10,"Hello, World",10,10
length equ $ - message
I've tried with sysenter
instead of syscall
, but it crashes the same way.