-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab2_asm_custom_test2.txt
43 lines (28 loc) · 1.11 KB
/
lab2_asm_custom_test2.txt
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
.data
ROK: .word 2, 3, 4, 5, 6, 2, 3, 4, 5, 6
R0: .word 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
V0: .word 1, 2, 3, 4, 5, 1, 2, 3, 4, 5
V1: .word 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.text
main:
jal addv_2_test1
b finish
addv_2_test1: li $s0 100 # Loop limit
li $s1 0 # Counter for loop (i)
li $s2 1 # Step for the counter
li $s3 4 # Offset to iterate through the array
# Use of stack needed to keep the value of $ra.
sub $sp $sp $s3 # Stack PUSH
sw $ra ($sp)
la $s4 R0
la $s5 V0
la $s6 V1
li $s7 10
for: bge $s1 $s0 end # Loop condition (i<100)
addv_2 $s4 $s5 $s6 $s7
add $s1 $s1 $s2 # i++
b for # Go to check condition of the loop again
end: lw $ra ($sp) # Stack POP
add $sp $sp $s3
jr $ra # return
finish: