forked from blau_araujo/pbn
exemplos da aula 4
This commit is contained in:
parent
194e25f9de
commit
ccc9eda285
2 changed files with 63 additions and 0 deletions
29
curso/exemplos/04/mappings.asm
Normal file
29
curso/exemplos/04/mappings.asm
Normal file
|
@ -0,0 +1,29 @@
|
|||
section .rodata
|
||||
msg db `Salve, simpatia!\n`
|
||||
len equ $ - msg
|
||||
|
||||
section .data
|
||||
global_data dq 42
|
||||
|
||||
section .bss
|
||||
uninit_data resq 1
|
||||
|
||||
section .text
|
||||
global _start
|
||||
|
||||
_start:
|
||||
; Fazer algo com os dados em .data e .bss
|
||||
mov rax, [rel global_data] ; acessando .data
|
||||
mov rcx, [rel uninit_data] ; acessando .bss
|
||||
|
||||
; Imprimir a mensagem em .rodata
|
||||
mov rax, 1 ; syscall: write
|
||||
mov rdi, 1 ; fd 1 = stdout
|
||||
mov rsi, msg ; endereço da mensagem
|
||||
mov rdx, len ; tamanho da mensagem
|
||||
syscall
|
||||
|
||||
; Encerrar processo
|
||||
mov rax, 60 ; syscall: exit
|
||||
xor rdi, rdi ; status 0
|
||||
syscall
|
Loading…
Add table
Add a link
Reference in a new issue