Question
Code in assembly programming **MIPS** Write a program that reads an array of 20 integers with an appropriate prompt, stores it, and then prints in
Code in assembly programming **MIPS**
Write a program that reads an array of 20 integers with an appropriate prompt, stores it, and then prints in three formats: - One integer per line; -All integers in a single line separated by spaces; -All in integers in a single line in the reverse order separated by spaces, - You program requests entering a positive integer n <=20 and then prints the 20 integers, n integers (separated by space) per line.
I AM HALF WAY THROUGH THE PROGRAM WHERE IT CAN ACCPET INTEGERS. CAN YOU PRINT THE ARRAY ELEMENTS THIS AS IN THE QUIESTION?
.data
array: .space 80
newLine:.asciiz " " # I will use it to start a new line
space: .asciiz " " # I will use it to have a space
Prompt: .asciiz " Enter an integer: "
.globl main
.text
main:
li $t0,20 # $t0 keeps track of the number of integers to be read
la $t1,array # loading the starting address of an array
loopQ:
la $a0,Prompt
li $v0,4
syscall
li $v0,5 # reading an integer
syscall
sw $v0,0($t1) # storing the integer entered add $t0,$t0,-1 # decrement the number of integers by one
add $t1,$t1,4 # load the address of the next integer
bgtz $t0,loopQ # branch to read and store the next integer
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