|
|
@ -1,11 +1,7 @@ |
|
|
|
# Declare main as a global function |
|
|
|
|
|
|
|
.globl main |
|
|
|
.globl main |
|
|
|
|
|
|
|
|
|
|
|
# All program code is placed after the |
|
|
|
|
|
|
|
# .text assembler directive |
|
|
|
|
|
|
|
.text |
|
|
|
.text |
|
|
|
|
|
|
|
|
|
|
|
# The label 'main' represents the starting point |
|
|
|
|
|
|
|
main: |
|
|
|
main: |
|
|
|
# print user input |
|
|
|
# print user input |
|
|
|
li $v0, 4 |
|
|
|
li $v0, 4 |
|
|
@ -23,16 +19,19 @@ main: |
|
|
|
li $s0, 0 # set counter to 0 |
|
|
|
li $s0, 0 # set counter to 0 |
|
|
|
jal lookup # hop to lookup function |
|
|
|
jal lookup # hop to lookup function |
|
|
|
|
|
|
|
|
|
|
|
# print newline |
|
|
|
|
|
|
|
#li $v0, 4 |
|
|
|
|
|
|
|
#la $a0, newline |
|
|
|
|
|
|
|
#syscall |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# print out result |
|
|
|
# print out result |
|
|
|
li $v0, 1 # print_int syscall code = 1 |
|
|
|
li $v0, 1 # print_int syscall code = 1 |
|
|
|
move $a0, $s0 # load integer into $ao |
|
|
|
move $a0, $s0 # load integer into $ao |
|
|
|
syscall |
|
|
|
syscall |
|
|
|
j exit # exit out of program |
|
|
|
|
|
|
|
|
|
|
|
# print newline |
|
|
|
|
|
|
|
li $v0, 4 |
|
|
|
|
|
|
|
la $a0, newline |
|
|
|
|
|
|
|
syscall |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# exit |
|
|
|
|
|
|
|
li $v0, 10 |
|
|
|
|
|
|
|
syscall |
|
|
|
|
|
|
|
|
|
|
|
lookup: |
|
|
|
lookup: |
|
|
|
addi $t0, $a2, 1 # store one higher value |
|
|
|
addi $t0, $a2, 1 # store one higher value |
|
|
@ -59,12 +58,7 @@ setoob: |
|
|
|
li $s0, -1 # index is oob, set to -1 |
|
|
|
li $s0, -1 # index is oob, set to -1 |
|
|
|
jr $ra # jump back to ra in main |
|
|
|
jr $ra # jump back to ra in main |
|
|
|
|
|
|
|
|
|
|
|
exit: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# All memory structures are placed after the |
|
|
|
|
|
|
|
# .data assembler directive |
|
|
|
|
|
|
|
.data |
|
|
|
.data |
|
|
|
arr: .word 5, 2, 1, 4, 6, 3 # change array to test |
|
|
|
arr: .word 5, 2, 1, 4, 6, 3 # change array to test |
|
|
|
enter_num: .asciiz "Enter number to be found: " |
|
|
|
enter_num: .asciiz "Enter number to be found: " |
|
|
|