2

I am currently trying to learn Assembly programming with an x86 architecture with ArchLinux. I am just getting started on this journey and understand the inner-workings of the following program to print Hello World.

; Jon Webb
; December 31, 2021
; ==============================================================================
; ==============================================================================
; Data Section

section .data

; Message to be printed
msg: db "Hello World", 10
; Length of message
len: equ $ - msg
; ==============================================================================
; Code section

section .text

; Define entry point
global _start
_start:
        ; 4 is equivalent to sys_write(std_output, msg, len)
        mov eax, 4   ; Calls sys_write function from syscall
        mov ebx, 1   ; File descriptor (1 standard output)
        mov ecx, msg ; Message to be printed
        mov edx, len ; Length of message to be printed
        int 0x80     ; Make syscall

        ; 1 is equivalent to sys_exit(status)
        mov eax, 1   ; Specify exit syscall
        mov eab, 0   ; Pass a status code of zero which indicates successful conclusion
        int 0x80     ; Make syscall
; ==============================================================================
; ==============================================================================
; end of file

I understand how this code works. The code is calling two Linux syscall functions sys_write() and sys_exit() that are defined by the integers 4 and 1 respectively. In each function I call the function by passing its defining integer to eax, and then I pass the successive variables to ebx, ecx, edx, and so on. In this case I know the two functions because the book I am reading tells me that 4 represents sys_write and 1 represents sys_exit; however, I suspect their are other similar functions. Where can I get a list of all Linux syscall functions. I thought this would be a simple answer answered by a simple google search, but so far I have come up with very little. This is such a fundamental aspect to x86 Assembly programming that I would have though these functions would be listed in tutorials, but so far I have not found this to be true.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Jon
  • 1,621
  • 5
  • 23
  • 46

1 Answers1

0

strace has tables where these are listed. You can find the x86_64 calls here.

gameshack_
  • 122
  • 9