-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.asm
41 lines (29 loc) · 732 Bytes
/
main.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
%include "sys.asm"
%macro cout 2
sys.write FD_STDOUT, %1, %2
%endmacro
%macro cerr 2
sys.write FD_STDERR, %1, %2
%endmacro
%macro cin 2
sys.read FD_STDIN, %1, %2
%endmacro
section .bss
bufferMaxSize equ 120
buffer resb bufferMaxSize
section .text
global _start
_start:
cout greeting, greeting_len
cout enter_num, enter_num_len
cin buffer, bufferMaxSize
cout print_num, print_num_len
cout buffer, bufferMaxSize
sys.exit 0
section .data
greeting: db 'Hello world!', 0xA
greeting_len: equ $-greeting
enter_num: db 'Please enter your string (max 119 chars): '
enter_num_len: equ $-enter_num
print_num: db 'Your string: '
print_num_len: equ $-print_num