Skip to content

Instantly share code, notes, and snippets.

@pinglunliao
Created January 14, 2016 10:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pinglunliao/2491461c8ac073a0b271 to your computer and use it in GitHub Desktop.
Save pinglunliao/2491461c8ac073a0b271 to your computer and use it in GitHub Desktop.
//----------------------------------------------------------------
// first.s: Output "Welcome to Assembly World."
//
// compile using: $ as first.s -o first.o
// link using: $ ld first.o -o first
// execute using: $ ./first
//
//----------------------------------------------------------------
.section .data
msg: .string "Welcome to Assembly World.\n" # the output message
len = . - msg # the length of the message
.section .text
_start: movl $4, %eax # system-call number for sys_write
movl $1, %ebx # device-file id-number for stdout
movl $msg, %ecx # address of the message string
movl $len, %edx # length of the message string
int $0x80 # trap-instruction for system-call
movl $1, %eax # system-call number for sys_exit
movl $0, %ebx # value for the exit-code
int $0x80 # trap-instruction for system-call
.globl _start # makes entry-point visible (can omit this)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment