asm

x86 Assembly programs.
git clone git://code.dwrz.net/asm
Log | Files | Refs

hello.s (731B)


      1 # PURPOSE: Print "Hello, World!", then exit.
      2 # INPUT: None.
      3 # OUTPUT:    Prints a string to stdout.
      4 #           Returns a status code of 0.
      5 # VARIABLES:
      6 #           %rax holds the system call number
      7 #           %rbx holds the return status
      8 .section .data
      9 hw:
     10         .ascii "Hello, World!"
     11 
     12 .section .text
     13         .globl _start
     14 
     15 _exit:
     16         mov $1, %rax # System call number for exit.
     17         mov $0, %rbx # Exit code.
     18         int $0x80    # Call the kernel.
     19 
     20 _start:
     21         mov $4, %rax  # System call number for write.
     22         mov $1, %rbx  # stdout.
     23         mov $hw, %rcx # Address of the buffer.
     24         mov $15, %rdx # Number of bytes to write.
     25         int $0x80     # Call the kernel.
     26 
     27 call _exit # Call the _exit macro.