-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4.printf.asm
20 lines (18 loc) · 973 Bytes
/
4.printf.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
; ----------------------------------------------------------------------------------------
; Writes "Hola, mundo" to the console using a C library. Runs on Linux.
;
; nasm -felf64 printf.asm && gcc printf.o && ./a.out
; ----------------------------------------------------------------------------------------
global main
extern printf
section .text
main:
push rbx ; alinear stack a 16 bytes
mov rdi, message ; First integer (or pointer) argument in rdi
mov eax, 1 ; ABI fig 3.4: Register Usage
mov esi, 42 ; ABI fig 3.36: vector argument
call printf WRT ..plt ; puts(message)
pop rbx
ret ; Return from main back into C library wrapper
message:
db "holis %d", 0 ; Note strings must be terminated with 0 in C