-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy paththree.asm
More file actions
61 lines (47 loc) · 855 Bytes
/
three.asm
File metadata and controls
61 lines (47 loc) · 855 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
toggle_verbose 0
mov 0, $0
mov 3, $3
mov -1, $10
mov @prompt, $arg_c
strlen @prompt, $arg_d
call .print_syscall
rdint $1
cmp $1, $0
jge .gte_zero
jmp .else
halt
gte_zero:
ld $1, $5
sub $5, $3
mov @minus, $arg_c
strlen @minus, $arg_d
call .print_syscall
print_int $5
mov @isthree, $arg_c
strlen @isthree, $arg_d
call .print_syscall
line_br
halt
else:
ld $1, $5
mul $5, $10
add $5, $3
mov @plus, $arg_c
strlen @plus, $arg_d
call .print_syscall
print_int $5
mov @isthree, $arg_c
strlen @isthree, $arg_d
call .print_syscall
line_br
halt
print_syscall:
mov write_syscall, $arg_a
mov stdout, $arg_b
syscall
ret
.data
prompt: "Type a number: "
isthree: " is 3!"
minus: "Your number minus "
plus: "Your number plus "