-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.asm
More file actions
64 lines (54 loc) · 1.06 KB
/
Copy pathmain.asm
File metadata and controls
64 lines (54 loc) · 1.06 KB
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
%define red(a) 0x1B, "[91m", a, 0x1B, "[0m"
section .data
_version_msg_pre db "💩 Assembly Game v", 0
_version db "0.1.0a", 0
_print_version_flag db "-v", 0
_exit_message db red("BYE!"), 10, 0
global _start
section .text
; arrays.asm
extern arrays_equal_zero_term
; game.asm
extern bootstrap_game
; printing.asm
extern print_newline
extern print_c_string
_start:
pop r12
dec r12
pop rsi
_next_arg:
cmp r12, 0 ; exit if no arguments left
jz _args_checked
dec r12
pop rsi
push r12
call _check_print_version_flag
pop r12
jmp _next_arg
_args_checked:
call bootstrap_game
mov rdi, _exit_message
call print_c_string
jmp exit_group
_check_print_version_flag:
mov rdi, _print_version_flag
call arrays_equal_zero_term
cmp rax, 0
jz _do_not_print_version
call _print_version
_do_not_print_version:
ret
_print_version:
mov rdi, _version_msg_pre
call print_c_string
mov rdi, _version
call print_c_string
call print_newline
ret
exit_group:
mov rdi, 0 ; result
mov rax, EXIT_GROUP ; exit(2)
syscall
; syscalls
EXIT_GROUP EQU 231