Desafio das aulas ao vivo 7 e 8 #8
Owner
```asm
%define EOL 0x0a
section .bss
buf_argc resq 1 ; 8 bytes inicializados com 0x00
section .text
global _start
_start:
xor rcx, rcx ; rcx (contador) = 0
mov rax, [rsp] ; rax = valor de ARGC
; Imprimir a quantidade de argumentos com quebra de linha...
call print_argc
args_loop:
inc rcx ; incrementa contador
lea rax, [rsp + 8 * rcx] ; avança 8*contador na pilha
mov rbx, [rax] ; endereço de ARGV[rcx - 1]
test rbx, rbx ; testa se endereço é NULL
jz _exit ; se for, termina
; Imprimir a string do argumento com quebra de linha...
call print_args
jmp args_loop
_exit:
mov rax, 60
xor rdi, rdi
syscall
; ----------------------------------------------------------
; print_argc: Imprime a quantidade de argumentos com \n...
; ----------------------------------------------------------
print_argc:
; ----------------------------------------------------------
; rdi => ARGC
; ----------------------------------------------------------
ret
; ----------------------------------------------------------
; print_args: Imprme a string do argumento com \n...
; ----------------------------------------------------------
print_args:
; ----------------------------------------------------------
; rsi => *BUF
; rdx => SIZE
; ----------------------------------------------------------
ret
; ----------------------------------------------------------
; Syscall write (altera RCX e R11)
; ----------------------------------------------------------
; mov rax, SYS_WRITE (1)
; mov rdi, FD (1 = STDOUT)
; mov rsi, *BUF
; mov rdx, SIZE
; syscall
; ----------------------------------------------------------
```
Descrição e implementação do exercício da aula #7 e #8 #9
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?