Skip to content

Instantly share code, notes, and snippets.

@pinglunliao
Created January 14, 2016 10:30
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/2ddd0427365802e619b3 to your computer and use it in GitHub Desktop.
Save pinglunliao/2ddd0427365802e619b3 to your computer and use it in GitHub Desktop.
//----------------------------------------------------------------
// Holan.s: print the 'Holan' in ascii code
//
// compile using: $ as Holan.s -o Holan.o
// link using: $ ld Holan.o -o Holan
// execute using: $ ./Holan
//
//----------------------------------------------------------------
.text # this section is program
.global _start # entry point
_start:
# write our string to stdout
movl $len,%edx # third argument: message length
movl $msg,%ecx # second: pointer to message
movl $1,%ebx # Holan: file handle (stdout)
movl $4,%eax # system call number (sys_write)
int $0x80 # call kernel
# and exit
movl $0,%ebx # Holan argument: exit code
movl $1,%eax # system call number (sys_exit)
int $0x80 # call kernel
.data # this section is data
msg:
.byte 72,111,108,97,110,10
len = . - msg # the length of the message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment