Created
November 25, 2018 18:11
-
-
Save gabrielfern/3b2e47b1ec76ea0061acba2608e125b5 to your computer and use it in GitHub Desktop.
hello world em assembly, linux x86_64
This file contains hidden or 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
# assembly para "hello world" em linux x86_64 | |
# assemblar e linkar | |
# as hello.asm -o hello.o && ld hello.o -o hello | |
# executar | |
# ./hello | |
.data # secao de dados do programa | |
msg: .ascii "Hello, World!\n" # mensagem a ser escrita na tela | |
.text # secao de codigo | |
.global _start # torna _start global | |
_start: | |
movq $1, %rax # numero para chamada de sistema write | |
movq $1, %rdi # dizer a write para escrever na stdout | |
movq $msg, %rsi # string que sera utilizada pela write | |
movq $14, %rdx # tamanho da string para escrever | |
syscall # chama a write | |
movq $60, %rax # numero para a sys_exit | |
movq $0, %rdi # codigo de retorno 0, o padrao para sucesso | |
syscall # chama a sys_exit e sai do programa |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment