#Application 17 .text 0x00400000 #Code section again: jal print_menu #Call subprogram #for displaying menu jal read_choice #Call subprogram for #reading the user’s choice move $t0,$s0 #Store selection in $t0 bltz $t0,again #If selection <0, go to start bgt $t0,3,again #If selection >3, go to start beq $t0,1,choice_1 #First selection: fill array beq $t0,2,choice_2 #Second selection: display array beq $t0,3,choice_3 #Third selection: for test only exodos: #Display the message #"\n\nProgram termination" li $v0,4 #Load the function number la $a0,exit_mes #Load the message starting address syscall #Function call #Program termination li $v0,10 #Load the function number syscall #Function call choice_1: #Fill array li $t2,1 #Loop counter li $t1,0 #Deviation counter start: #Display the message "Pos[" li $v0,4 #Load the function number la $a0,m1 #Load the message starting address syscall #Function call #Display current array location li $v0,1 #Load the function number move $a0,$t2 #Load the number to be displayed syscall #Function call #Display the message "]=" li $v0,4 #Load the function number la $a0,m2 #Load the message starting address syscall #Function call #Read number (keyboard) li $v0,5 #Load the function number syscall #Function call move $t0,$v0 #Load the number in $t0 sw $t0,arrayA($t1) #Store the number in array starting #from the address arrayA+$t1 add $t1,$t1,4 #Update deviation counter add $t2,$t2,1 #Update loop counter ble $t2,10,start #If all the numbers have #not been stored, go to start j again #Return to selection menu choice_2: #Display array li $t2,1 #Numbers counter li $t1,0 #Deviation counter start2: lw $t0,arrayA($t1) #Read number from array #Display number li $v0,1 #Load the function number move $a0,$t0 #Load the number to be displayed syscall #Function call #Display a space character li $v0,4 #Load the function number la $a0,spacechar #Load the message starting address syscall #Function call add $t1,$t1,4 #Update deviation counter add $t2,$t2,1 #Update loop counter ble $t2,10,start2 #If all the numbers #have not been read, go to start2 j again #Return to selection menu choice_3: #Display the message "\n C selected" li $v0,4 #Load the function number la $a0,ep3 #Load the message starting address syscall #Function call j again #Return to selection menu print_menu: #Display selection menu li $v0,4 #Load the function number la $a0,menu #Load the message starting address syscall #Function call jr $31 #Return read_choice: #Read menu selection li $v0,5 #Load the function number syscall #Function call move $s0,$v0 #Store selection in $s0 jr $31 #Return #Data section .data menu: .ascii "\n**********************" .ascii "\n* 1. Fill array *" .ascii "\n* 2. Display array *" .ascii "\n* 3. Selection C *" .ascii "\n* 0. Exit *" .ascii "\n**********************" .asciiz "\nSELECT (1-3 or 0):" ep3: .asciiz "\n C selected" exit_mes: .asciiz "\n\nProgram trmination" m1: .asciiz "Pos[" m2: .asciiz "]=" .align 2 arrayA: .space 40 spacechar: .asciiz " "