Where are the system codes included in the x86-64 assembly?
I go through some build demos (using NASM on Mac, I'm new to build) and see things like this:
; read a byte from stdin
mov eax, 3 ; 3 is recognized by the system as meaning "read"
mov ebx, 0 ; read from standard input
mov ecx, variable ; address to pass to
mov edx, 1 ; input length (one byte)
int 0x80 ; call the kernel
I'm starting to understand that eax
, ebx
etc. are "general registers" in which you store common things. There is still a lot to learn, but I get the gist of it.
But I'm confused as to where the values ββcome from, such as 3
(recognized by the system as meaning "read") and 0
(read from standard input). How do you know what 0
"standard input" means? Is there a list of such integer values, or some book or standard reference?
source to share
You are concatenating system call numbers with system call arguments.
System call numbers (for example, "3 = read") are OS dependent (well, kernel dependent) and sometimes version as well. For example see System Call Numbers for Linux on x86 here and on x86_64 here . How the arguments are passed, how the system call is called, and what the system call numbers mean are all architecture and kernel dependent.
The number "0" to "standard input", on the other hand, is a standardized UNIX value STDIN_FILENO
.
source to share