Created
January 14, 2016 10:27
-
-
Save pinglunliao/2491461c8ac073a0b271 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
//---------------------------------------------------------------- | |
// 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