-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions_testing_stub.asm
executable file
·164 lines (143 loc) · 3.25 KB
/
functions_testing_stub.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
.data
theArray:
.word 0 33 123 -66 332 -1 -223 453 9 45 -78
sp_sanity_check_prompt_1:
.asciiz "\nSP ENTER VALUE: "
sp_sanity_check_prompt_2:
.asciiz "\nSP EXIT VALUE: "
print_s_register_prompt:
.asciiz "\nS REGISTERS: "
convention:
.asciiz "\nMy Convention Check\n"
space:
.asciiz " "
newline:
.asciiz "\n"
.text
ConventionCheck:
addi $t0, $0, -1
addi $t1, $0, -1
addi $t2, $0, -1
addi $t3, $0, -1
addi $t4, $0, -1
addi $t5, $0, -1
addi $t6, $0, -1
addi $t7, $0, -1
ori $v0, $0, 4
la $a0, convention
syscall
addi $v0, $zero, -1
addi $v1, $zero, -1
addi $a0, $zero, -1
addi $a1, $zero, -1
addi $a2, $zero, -1
addi $a3, $zero, -1
addi $k0, $zero, -1
addi $k1, $zero, -1
jr $ra
print_s_registers:
la $a0, print_s_register_prompt
li $v0, 4
syscall
# print s0, followed by a space
move $a0, $s0
li $v0, 1
syscall
la $a0, space
li $v0, 4
syscall
# print s1, followed by a space
move $a0, $s1
li $v0, 1
syscall
la $a0, space
li $v0, 4
syscall
# print s2, followed by a space
move $a0, $s2
li $v0, 1
syscall
la $a0, space
li $v0, 4
syscall
# print s3, followed by a space
move $a0, $s3
li $v0, 1
syscall
la $a0, space
li $v0, 4
syscall
# print s4, followed by a space
move $a0, $s4
li $v0, 1
syscall
la $a0, space
li $v0, 4
syscall
# print s5, followed by a space
move $a0, $s5
li $v0, 1
syscall
la $a0, space
li $v0, 4
syscall
# print s6, followed by a space
move $a0, $s6
li $v0, 1
syscall
la $a0, space
li $v0, 4
syscall
# print s7, followed by a newline
move $a0, $s7
li $v0, 1
syscall
la $a0, newline
li $v0, 4
syscall
jr $ra
# Doesn't take any parameters
sp_sanity_check_1:
la $a0, sp_sanity_check_prompt_1
li $v0, 4
syscall
move $a0, $sp
li $v0, 1
syscall
jr $ra
sp_sanity_check_2:
la $a0, sp_sanity_check_prompt_2
li $v0, 4
syscall
move $a0, $sp
li $v0, 1
syscall
jr $ra
sanity_check_end:
# save ra
addi $sp, $sp, -4
sw $ra, 0($sp)
jal sp_sanity_check_2
jal print_s_registers
# restore $ra and return
lw $ra, 0($sp)
addi $sp, $sp, 4
jr $ra
sanity_check_start:
# save ra
addi $sp, $sp, -4
sw $ra, 0($sp)
jal sp_sanity_check_1
jal print_s_registers
# restore $ra and return
lw $ra, 0($sp)
addi $sp, $sp, 4
jr $ra
main:
jal sanity_check_start
la $a0, theArray
li $a1, 11
jal PrintReverse
jal sanity_check_end
li $v0, 10
syscall