forked from blau_araujo/pbn
exemplos da aula 6
This commit is contained in:
parent
ee62511898
commit
4d701d4461
5 changed files with 304 additions and 0 deletions
20
curso/exemplos/06/prog.asm
Normal file
20
curso/exemplos/06/prog.asm
Normal file
|
@ -0,0 +1,20 @@
|
|||
section .data
|
||||
fmt db "Programa: %s", 10, 0
|
||||
|
||||
global main ; símbolo chamado por _start de crt0.o
|
||||
extern printf ; (opcional) usar funções da libc
|
||||
|
||||
section .text
|
||||
main:
|
||||
; argc → rdi
|
||||
; argv → rsi
|
||||
; envp → rdx (não obrigatório)
|
||||
|
||||
; Exemplo: imprimir argv[0]
|
||||
mov rdi, fmt
|
||||
mov rsi, [rsi] ; argv[0]
|
||||
xor rax, rax ; terminação de argumentos (printf é variádica)
|
||||
call printf
|
||||
|
||||
mov eax, 0 ; retorno de 'main' = (int)0
|
||||
ret
|
Loading…
Add table
Add a link
Reference in a new issue