Created
January 14, 2016 10:30
-
-
Save pinglunliao/2ddd0427365802e619b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//---------------------------------------------------------------- | |
// 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