Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 ) Change the PrintIntArray subprogram so that it prints the array from the last element to the first element. Question 1 - Edited text
Change the PrintIntArray subprogram so that it prints the array from the last element to the first element.
Question Edited text document highlighting your changes from the book's PrintIntArray
THis is supposed to be used in MIPS assembly language. Heres the copy and pasted text document of the program and Ill take screenshots of it
text
globl main
main:
la $a arraybase
lw $a arraysize
jal PrintIntArray
jal Exit
data
arraysize: word
arraybase:
word
word
word
word
word
# Subprogram: PrintIntArray# Purpose: print an array of ints# inputs: $a
the base address of the array
# $a the size of the array
text
PrintIntArray:
addi $sp $sp # Stack record
sw $ra$sp
sw $s$sp
sw $s$sp
sw $s$sp
move $s $a # save the base of the array to $s
# initialization for counter loop # $s is the ending index of the loop
# $s is the loop counter
move $s $a move $s $zero la $a openbracket #
print open bracket jal PrintString
loop: # check ending condition
sge $t $s $s bnez $t endloop
sll $t $s # Multiply the loop counter by to get
# offset each element is big
add $t $t $s # address of next array element
lw $a$t # Next array element
la $a comma
jal PrintInt # print the integer from array
addi $s $s #increment $s
b loop
endloop:
li $v # print close bracket la $a
closebracket
syscall
lw $ra$sp
lw $s$sp
lw $s$sp
lw $s$sp # restore stack and return
addi $sp $sp
jr $ra
data openbracket: asciiz
closebracket: asciiz
comma: asciiz
include "utils.asm"
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