Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 1 ) Using MIPS ( MARS 4 . 5 ) Assembly language. Please comment and screenshot the code. Change the PrintIntArray subprogram so that
Question Using MIPSMARS Assembly language. Please comment and screenshot the code. Change the PrintIntArray subprogram so that it prints the array from the last element to the first element. Please answer the two exercise questions at the end of Ch Just in case I took a screenshot of the code and will copy and paste it
Heres the code:
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 $sbnez $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