Answered step by step
Verified Expert Solution
Question
1 Approved Answer
evrything goes well , untill i want to print the values stored in the array it just store the first numbers but the last added
evrything goes well untill i want to print the values stored in the array it just store the first numbers but the last added number alwyas wrong i do not where is the problem if it was in the diplay method or the add elemnt method this is my MIPS code incomplete :data
menu: asciiz CPCS Assignment
Enter to end the program
Enter to compute the series
Enter to deal with array
Enter the choice:
series: asciiz "Enter the end of series:
Armenue: asciiz
Enter to add an element to the array
Enter to display the array elements
Enter to return to the main menu
Enter the choice:
emptymsg: asciiz "Array is empty
entervalue: asciiz "Enter the value:
addedmsg: asciiz "The value is added
elementsmsg: asciiz "Array elements:
arraySS:.asciiz "Array size:
spacee:.asciiz
thanksmsg: asciiz Thank you for using the program
arr: word # Assuming array size of
arrSize: word # Variable to store array size
text
main:
# calling the display menu
jal displayMenu
# read the user choice
li $v
syscall
move $s$v # choice $s
beqz $sexit # Choice Eexit
beq $scomputeSeries # Choice compute series
beq $sdealarray # Choice array dealing
# # # # # # # # # # # # # #
displayMenu:
# print
la $amenu
li $v
syscall
# back to main
jr $ra
# # # # # # # # # # # # # # # #
computeSeries:
j main
# # # # # # # # # # # # # #
dealarray :
# print
la $aArmenue
li $v
syscall
# read the user choice
li $v
syscall
move $s$v # choice $s
beq $smain #Choice back to main
beq $sDisplayArray
beq $sAddelement
# # # # # # # # # # # # # #
DisplayArray:
lw $tarrSize # check array size limit
#@@#
la $aarraySS
li $v
syscall
#@@#
#@@#
move $a$t
li $v
syscall
#@@#
beqz $tempty
la $aelementsmsg
li $v
syscall
la $tarr # array addres pointer $t
li $s # counter
loop:
# print space
la $aspacee
li $v
syscall
bgt $s$tdealarray # if counter greater than array size back
lw $a$t # get the elemnt
li $v # print
syscall
addi $t$t # invrement array addres pointer
addi $s$s # invrement counter
j loop
empty:
# print
la $aemptymsg
li $v
syscall
j dealarray
j dealarray
# # # # # # # # # # # # # # # # # # # # # # # #
Addelement:
# print
la $aentervalue
li $v
syscall
la $tarr# array addres pointer $t
# increment the array size
lw $tarrSize
sll $t$t
add $t $t$t
# input
li $v
syscall
sw $v$t# add the value to array
addi $t$t # invrement array addres pointer
addi $t$t
sw $tarrSize
# print
la $aaddedmsg
li $v
syscall
j dealarray # go back to deal array menue
# # # # # # # # # # # # # # # # # # # # # # # #
exit:
la $athanksmsg
li $v
syscall
li $v
syscall For this assignment, your mission is to write a MIPS program that simulates the output shown below. The
program contains some of required subroutines which perform specific tasks based on the following
requirements:
A subroutine called displayMenu that displays the menu shown in the sample output.
A subroutine called computeSeries that computes the series based on the end of series value entered
by the user. The subroutine should deal with the numbers as double or float numbers. See
Sample output
cdotsneed helpn
i also not know how
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started