atualização da aula 2

This commit is contained in:
Blau Araujo 2025-05-16 11:09:46 -03:00
parent a9d9819ac0
commit 4321a16da0
4 changed files with 717 additions and 37 deletions

8
curso/exemplos/02/ok.txt Normal file
View file

@ -0,0 +1,8 @@
7f 45 4c 46 01 01 01 00 00 00 00 00
00 00 00 00 02 00 03 00 01 00 00 00
54 80 04 08 34 00 00 00 00 00 00 00
00 00 00 00 34 00 20 00 01 00 28 00
00 00 00 00 01 00 00 00 54 00 00 00
54 80 04 08 00 00 00 00 0c 00 00 00
0c 00 00 00 05 00 00 00 00 10 00 00
b8 01 00 00 00 bb 00 00 00 00 cd 80

View file

@ -1,4 +1,4 @@
section .data
section .rodata
msg db "Salve, simpatia!", 10
len equ $ - msg
@ -13,5 +13,5 @@ _start:
syscall
mov rax, 60 ; syscall exit
xor rdi, rdi ; código de saída 0
mov rdi, 0 ; código de saída 0
syscall

View file

@ -1,7 +1,25 @@
#include <unistd.h>
int main() {
const char *msg = "Salve, simpatia!\n";
write(1, msg, 14);
return 0;
// msg db "Salve, simpatia!", 10
const char msg[] = "Salve, simpatia!\n";
// len equ $ - msg
#define LEN sizeof(msg) - 1
int main(void) {
/*
mov rax, 1 ; syscall write
mov rdi, 1 ; stdout
mov rsi, msg
mov rdx, len
syscall
*/
write(1, msg, LEN);
/*
mov rax, 60 ; syscall exit
mov rdi, 0 ; código de saída 0
syscall
*/
_exit(0);
}