-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuselibio.asm
65 lines (53 loc) · 1.1 KB
/
uselibio.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
; -----------------------------------------------------------------------------
; name:
; uselibio.asm
; author:
; zxsvrx
; copyright:
; Copyright (c) 2024 zxsvrx
; license:
; MIT License (see LICENSE in /master)
; platform:
; macOS
; architecture:
; x86_64
; syntax:
; nasm
; compiler:
; nasm 2.16.01
; build tool:
; gcc (Apple clang version 15.0.0)
;
; build with:
; nasm -f macho64 -o uselibio.o uselibio.asm && gcc -nostdlib -o uselibio uselibio.o libio.o
; (libio needs to be build first)
;
; A program that uses and demonstrates the functions provided by libio.asm
; -----------------------------------------------------------------------------
section .text
extern io_print
extern io_println
extern io_getc
extern io_getline
extern io_strlen
global _main
_main:
push rbp
mov rbp, rsp
lea rdi, [rel msg0]
call io_println
call io_getc
lea rdi, [rel msg1]
call io_print
lea rdi, [rel input]
mov rsi, input.len
call io_getline
mov rax, 0x2000001
mov rdi, 0x0
syscall
section .text
msg0: db "Hello, world!", 0
msg1: db "Your name: ", 0
section .bss
input: resb 256
input.len: equ 256