Created
March 3, 2012 15:55
-
-
Save gandaro/1966795 to your computer and use it in GitHub Desktop.
“Hello world” written using AT&T assembly
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
.data | |
hello: | |
.string "Hello world!\n" | |
.text | |
.globl _start | |
_start: | |
movl $4, %eax # write(1, hello, strlen(hello)) | |
movl $1, %ebx | |
movl $hello, %ecx | |
movl $13, %edx | |
int $0x80 | |
movl $1, %eax # exit(0) | |
movl $0, %ebx | |
int $0x80 |
use gcc
as hello.s -o hello.o && ld hello.o -hello
I'm trying to write fizzbuzz in assembly! This was helpful, thank you!
You need to move 14 to edx to include the newline.
You need to move 14 to edx to include the newline.
This is better than counting with your fingers.
hello:
.string "Hello world!\n"
hello_end:
.equ len, hello - hello_end
.text
.globl _start
_start:
movq $1, %rax
movq $1, %rdi
movq $string, %rsi
movq $len, %rdx
syscall
movq $60, %rax
movq $0, %rdi
syscall
`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How do you compile this?