mov [register]
and similar are not system calls, but assembler instructions.
System calls are basically a user-space program calling specific sub-routines in the kernel, using a mechanism built into the processor and set up by the kernel, that allows the called sub-routine to have a higher privilege level than regular user-space program code.
Assembler instructions are basically a human-friendly representation of actual bytes of machine code. And the machine code is not interpreted nor compiled, but implemented inside the processor either with the processor microcode, or directly at the hardware level, using large groups of logic gates.
A single system call invocation in assembler language is usually multiple lines of code. First the parameters for the system call are loaded in appropriate processor registers and/or to the stack, and then a special instruction like int 0x80
or syscall
is used to actually make the system call.
In the 32-bit x86 architecture, the int 0x80
is used as the system call instruction. The kernel has prepared a table of software interrupt handler routines for the processor. This table is not directly accessible by regular user-space code, but using the int
instruction the userspace code can trigger one of the routines pointed to by the table. int 0x80
simply tells the processor to switch into kernel mode and jump into the routine whose address is in slot #128 of that table. That routine is Linux's system call interface for 32-bit x86 architecture: it checks the parameters specified, identifies which process made the call and then jumps to the appropriate sub-routine.
In the 64-bit version of the x86 architecture, there is a dedicated syscall
instruction for the same purpose. Actually the 32-bit x86 architecture now has it too, but either it did not exist yet when the 32-bit Linux system call convention was designed by Linus Torvalds, or the instruction had a hardware bug in some processor models, so it did not get used. But since all 64-bit x86 processors have the syscall
instruction and it definitely works, it is used.
mov
are not system calls. On linux, the system calls are implemented via instruction such asint 0x80
(on i386) or the surprisingly namedsyscall
(on x86-64). – May 17 '19 at 12:13