Advertisement
BaSs_HaXoR

Hello World ia32 Assembly

Oct 18th, 2014
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #credits: http://www.ibm.com/developerworks/library/l-ppc/
  2. .data                   # section declaration
  3.  
  4. msg:
  5.     .string "Hello, world!\n"
  6.     len = . - msg   # length of our dear string
  7.  
  8. .text                   # section declaration
  9.  
  10.                         # we must export the entry point to the ELF linker or
  11.     .global _start      # loader. They conventionally recognize _start as their
  12.                         # entry point. Use ld -e foo to override the default.
  13.  
  14. _start:
  15.  
  16. # write our string to stdout
  17.  
  18.     movl    $len,%edx   # third argument: message length
  19.     movl    $msg,%ecx   # second argument: pointer to message to write
  20.     movl    $1,%ebx     # first argument: file handle (stdout)
  21.     movl    $4,%eax     # system call number (sys_write)
  22.     int     $0x80       # call kernel
  23.  
  24. # and exit
  25.  
  26.     movl    $0,%ebx     # first argument: exit code
  27.     movl    $1,%eax     # system call number (sys_exit)
  28.     int     $0x80       # call kernel
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement