Advertisement
Guest User

Untitled

a guest
May 4th, 2019
3,785
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; ----------------------------------------------------------------------------------------
  2. ; Writes "Hello, World" to the console using only system calls. Runs on 64-bit macOS only.
  3. ; ----------------------------------------------------------------------------------------
  4.  
  5.         global    start
  6.  
  7.         section   .text
  8. start:
  9.         mov       rax, 0x02000004         ; system call for write
  10.         mov       rdi, 1                  ; file handle 1 is stdout
  11.         mov       rsi, message            ; address of string to output
  12.         mov       rdx, 13                 ; number of bytes
  13.         syscall                           ; invoke operating system to do the write
  14.         mov       rax, 0x02000001         ; system call for exit
  15.         xor       rdi, rdi                ; exit code 0
  16.         syscall                           ; invoke operating system to exit
  17.  
  18.           section   .data
  19. message:  db        "Hello, World", 10      ; note the newline at the end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement