-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.asm
More file actions
42 lines (35 loc) · 710 Bytes
/
main.asm
File metadata and controls
42 lines (35 loc) · 710 Bytes
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
%include "colon.inc"
section .data
%include "words.inc"
error_msg: db "Error: key not found in dictionary.", 0
target_str: db "second word", 0
section .text
global _start
extern find_word
extern print_string
extern print_error
extern string_equals
extern print_uint
extern read_word
_start:
mov rbp, rsp
sub rsp, 256
mov rdi, rsp
mov rsi, 256
call read_word
mov rdi, rsp
mov rsp, rbp
mov rsi, last_item
call find_word
test rax, rax
jz .invalid
mov rdi, rax
call print_string
jmp .end
.invalid:
mov rdi, error_msg
call print_error
.end:
mov rax, 60 ; use exit system call to shut down correctly
xor rdi, rdi
syscall