Answered step by step
Verified Expert Solution
Link Copied!

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

1) Change the PrintIntArray subprogram so that it prints the array from the last element to the first element.
Question 1- 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 $a0, array_base
lw $a1, array_size
jal PrintIntArray
jal Exit
.data
array_size: .word 5
array_base:
.word 12
.word 7
.word 3
.word 5
.word 11
# Subprogram: PrintIntArray# Purpose: print an array of ints# inputs: $a0-
the base address of the array
# $a1- the size of the array
.text
PrintIntArray:
addi $sp, $sp,-16 # Stack record
sw $ra,0($sp)
sw $s0,4($sp)
sw $s1,8($sp)
sw $s2,12($sp)
move $s0, $a0 # save the base of the array to $s0
# initialization for counter loop # $s1 is the ending index of the loop
# $s2 is the loop counter
move $s1, $a1 move $s2, $zero la $a0 open_bracket #
print open bracket jal PrintString
loop: # check ending condition
sge $t0, $s2, $s1 bnez $t0, end_loop
sll $t0, $s2,2 # Multiply the loop counter by 4 to get
# offset (each element is 4 big)
add $t0, $t0, $s0 # address of next array element
lw $a1,0($t0) # Next array element
la $a0, comma
jal PrintInt # print the integer from array
addi $s2, $s2,1 #increment $s0
b loop
end_loop:
li $v0,4 # print close bracket la $a0,
close_bracket
syscall
lw $ra,0($sp)
lw $s0,4($sp)
lw $s1,8($sp)
lw $s2,12($sp) # restore stack and return
addi $sp, $sp,16
jr $ra
.data open_bracket: .asciiz "["
close_bracket: .asciiz "]"
comma: .asciiz ","
.include "utils.asm"
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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

Find the indicated derivative. dz dx dz : ifz=In(x8+ed) dx

Answered: 1 week ago

Question

Language in Context?

Answered: 1 week ago