NASM

Comprehensive study of nasm covering fundamental concepts and advanced applications.

Advanced Topics

System Calls and Interfacing with Operating Systems

Communicating with the OS

Assembly programs often need to perform actions like reading files or printing output. This is done by making system calls to the operating system.

How System Calls Work

You load specific values into registers (like eax, ebx) to tell the OS what you want, then trigger a software interrupt (like int 0x80 on Linux).

mov eax, 1      ; syscall number for exit
xor ebx, ebx    ; exit code 0
int 0x80        ; invoke syscall

Common System Calls

  • write: Output to console or file
  • read: Input from console or file
  • exit: End the program

Real-World Impact

System calls are the foundation for all applications, from simple scripts to complex browsers, as they allow software to interact with hardware safely.

Examples

  • Using int 0x80 to print a message in Linux.

  • Reading user input by calling the appropriate system call.

In a Nutshell

System calls let assembly programs interact with the OS to perform useful tasks like reading input or writing output.