Answered step by step
Verified Expert Solution
Link Copied!

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 214 Assignment
Enter 0 to end the program
Enter 1 to compute the series
Enter 2 to deal with array
Enter the choice: "
series: .asciiz "Enter the end of series: "
Armenue: .asciiz "
Enter 1 to add an element to the array
Enter 2 to display the array elements
Enter 3 to return to the main menu
Enter the choice: "
empty_msg: .asciiz "Array is empty
"
enter_value: .asciiz "Enter the value: "
added_msg: .asciiz "The value is added
"
elements_msg: .asciiz "Array elements: "
arraySS:.asciiz "Array size: "
spacee:.asciiz ""
thanks_msg: .asciiz ">> Thank you for using the program
"
arr: .word 100 # Assuming array size of 100
arrSize: .word 0 # Variable to store array size
.text
main:
# calling the display menu
jal displayMenu
# read the user choice
li $v0,5
syscall
move $s0,$v0 # choice = $s0
beqz $s0,exit # Choice 0--> Eexit
beq $s0,1,computeSeries # Choice 1--> compute series
beq $s0,2,deal_array # Choice 2--> array dealing
# # # # # # # # # # # # # #
displayMenu:
# print
la $a0,menu
li $v0,4
syscall
# back to main
jr $ra
# # # # # # # # # # # # # # # #
computeSeries:
j main
# # # # # # # # # # # # # #
deal_array :
# print
la $a0,Armenue
li $v0,4
syscall
# read the user choice
li $v0,5
syscall
move $s1,$v0 # choice = $s1
beq $s1,3,main #Choice 3--> back to main
beq $s1,2,Display_Array
beq $s1,1,Add_element
# # # # # # # # # # # # # #
Display_Array:
lw $t2,arrSize # check array size =limit
#!!@!@#!
la $a0,arraySS
li $v0,4
syscall
#!!@!@#!
#!!@!@#!
move $a0,$t2
li $v0,1
syscall
#!!@!@#!
beqz $t2,empty
la $a0,elements_msg
li $v0,4
syscall
la $t0,arr # array addres pointer =$t0
li $s2,1 # counter
loop:
# print space
la $a0,spacee
li $v0,4
syscall
bgt $s2,$t2,deal_array # if counter greater than array size back
lw $a0,0($t0) # get the elemnt
li $v0,1 # print
syscall
addi $t0,$t0,4 # invrement array addres pointer
addi $s2,$s2,1 # invrement counter
j loop
empty:
# print
la $a0,empty_msg
li $v0,4
syscall
j deal_array
j deal_array
# # # # # # # # # # # # # # # # # # # # # # # #
Add_element:
# print
la $a0,enter_value
li $v0,4
syscall
la $t0,arr# array addres pointer =$t0
# increment the array size
lw $t1,arrSize
sll $t8,$t1,2
add $t0, $t8,$t0
# input
li $v0,5
syscall
sw $v0,0($t0)# add the value to array\
addi $t0,$t0,4 # invrement array addres pointer
addi $t1,$t1,1
sw $t1,arrSize
# print
la $a0,added_msg
li $v0,4
syscall
j deal_array # go back to deal array menue
# # # # # # # # # # # # # # # # # # # # # # # #
exit:
la $a0,thanks_msg
li $v0,4
syscall
li $v0,10
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)
s=12+13+14+cdots1implmentthecomputseriesmethod
needhelpn
need helpn
i also do not know how to
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic Net Database Programming

Authors: Rod Stephens

1st Edition

0789726815, 978-0789726810

More Books

Students also viewed these Databases questions