-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanus.asm
112 lines (91 loc) · 1.93 KB
/
anus.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# compiler for the ANUS programming language
# based on the HQ9+ joke language
# written by anusO1
.data
a: .byte 'A'
n: .byte 'N'
u: .byte 'U'
s: .byte 'S'
AW: .asciiz "Hello World\n"
s1: .asciiz " bottles of beer on the wall, "
s2: .asciiz " bottles of beer.\n"
s3: .asciiz "Take one down, pass it around, "
s4: .asciiz " bottles of beer on the wall.\n"
s5: .asciiz "1 bottle of beer on the wall, 1 bottle of beer.\n\nTake one down, pass it around, no more bottles of beer on the wall." # there's only one beer left
# sc: .space 1000
.text
li, $s6, 0 # accumulator
li $v0, 8
li $a0, 1000
li $a1, 1000
syscall
move $s0, $a0
move $s1, $s0
la $s2, a
la $s3, n
la $s4, u
la $s5, s
While:
sub $t0, $s1, $s0
beq $t0, 1000, End
lb $t1, ($s1) # load byte from current array element
# 4 functions
lb $t0, ($s2) # load 'a' byte
beq $t0, $t1, A
lb $t0, ($s3) # load 'n' byte
beq $t0, $t1, N
lb $t0, ($s4) # load 'u' byte
beq $t0, $t1, U
lb $t0, ($s5) # load 's' byte
beq $t0, $t1, S
j End
Return:
addi $s1, $s1, 1
j While
End:
li $v0, 10
syscall
A:
la $a0, AW
li $v0, 4
syscall
j Return
N:
la $a0, 1000
li $v0, 4
syscall
j Return
U:
li $t2, 99
For:
beq $t2, 0, ExitF
li $v0, 1
move $a0, $t2
syscall
li $v0, 4
la $a0, s1
syscall
li $v0, 1
move $a0, $t2
syscall
li $v0, 4
la $a0, s2
syscall
addi $t2, $t2, -1 # i added negative one instead of subtracting 1 lmaooo
li $v0, 4
la $a0, s3
syscall
li $v0, 1
move $a0, $t2
syscall
li $v0, 4
la $a0, s4
syscall
j For
ExitF:
la $a0, s5
syscall
j Return
S:
addi $s6, $s6, 1
j Return