Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have this program so far but now I need it to ask the user if he/she would lik

ID: 3628989 • Letter: I

Question

I have this program so far but now I need it to ask the user if he/she would like to input another sequence and I can't figure it out. Please help!

.data
vals: .space 4000
msg1: .asciiz "Enter a value (integer): 9999 to exit "
msg2: .asciiz " The elements in the array are: "
msg3: .asciiz "Would you like to do another sequence? "
next_line: .asciiz " "

.text
.globl main
main:

la $a1, vals
li $a2, 9

li $t0, 0
li $t1,9999

loop:
la $a0, msg1
li $v0, 4
syscall
li $v0, 5
syscall
beq $v0,$t1,sort
addi $t0,$t0,4
sw $v0, ($a1)
addi $a1, $a1, 4 # move the array over by 1 element
j loop

sort:
la $t4, vals #t0 is number up to outer loop
la $t1, vals #t1 is number comparing to inner loop
addi $t1,$t1,4
la $t8,vals
add $t8,$t0,$t8
la $t9,vals
add $t9,$t0,$t9
addi $t9,$t9,-4

loops:
lw $t2,($t4) #get number 1 of the outer loop
lw $t3,($t1) #get number 2 of the inner loop
blt $t2,$t3,next #swapping not required
sw $t3,($t4) #swap the numbers
sw $t2,($t1)

next:
addi $t1,$t1,4
blt $t1,$t8,loops #inner loop completed
addi $t4,$t4,4 #if completed - increment outer loop
move $t1,$t4
addi $t1,$t1,4
blt $t4,$t9,loops #outer loop completed

printArray:
la $a1,vals
la $a0, msg2
li $v0, 4
syscall

loop1:
blez $t0, done
li $v0, 1
lw $a0, 0($a1)
syscall
la $a0, next_line
li $v0, 4
syscall
addi $a1, $a1, 4
addi $t0, $t0, -4
j loop1

done:
j done

Explanation / Answer

please rate - thanks

.data
vals: .space 4000
msg1: .asciiz "Enter a value (integer): 9999 to exit "
msg2: .asciiz " The elements in the array are: "
msg3: .asciiz "Would you like to do another sequence? "
next_line: .asciiz " "

.text
.globl main
main:

la $a1, vals
li $a2, 9

li $t0, 0
li $t1,9999

loop:
la $a0, msg1
li $v0, 4
syscall
li $v0, 5
syscall
beq $v0,$t1,sort
addi $t0,$t0,4
sw $v0, ($a1)
addi $a1, $a1, 4 # move the array over by 1 element
j loop

sort:
la $t4, vals #t0 is number up to outer loop
la $t1, vals #t1 is number comparing to inner loop
addi $t1,$t1,4
la $t8,vals
add $t8,$t0,$t8
la $t9,vals
add $t9,$t0,$t9
addi $t9,$t9,-4

loops:
lw $t2,($t4) #get number 1 of the outer loop
lw $t3,($t1) #get number 2 of the inner loop
blt $t2,$t3,next #swapping not required
sw $t3,($t4) #swap the numbers
sw $t2,($t1)

next:
addi $t1,$t1,4
blt $t1,$t8,loops #inner loop completed
addi $t4,$t4,4 #if completed - increment outer loop
move $t1,$t4
addi $t1,$t1,4
blt $t4,$t9,loops #outer loop completed

printArray:
la $a1,vals
la $a0, msg2
li $v0, 4
syscall

loop1:
blez $t0, done
li $v0, 1
lw $a0, 0($a1)
syscall
la $a0, next_line
li $v0, 4
syscall
addi $a1, $a1, 4
addi $t0, $t0, -4
j loop1

done:
la $a0, msg3
li $v0, 4
syscall
li $v0,8
la $a0,vals
li $a1,2
syscall
la $a0, next_line
li $v0, 4
syscall
lb $t1,vals
li $t2,89                           #Y
beq $t1,$t2,main
li $t2,121                        #y
beq $t1,$t2,main
complete:
j complete