Introduction: In this lab, you will write a MIPS program to read in (up to) 50 i
ID: 3821908 • Letter: I
Question
Introduction: In this lab, you will write a MIPS program to read in (up to) 50 integer values from the user, store them in an array, print out the amay, one number per line, reverse the elements in the array and finally print out the elements in the just-reversed) array. Feel free to do this lab and all assembly programming labs) in Windows. You must use MARS Getting started: l. In MARS, create a new assembly file with the name array-reverse. asm. 2. Use the following code to get started: Description: Data segment data #your data will go here Code segment text globl MAIN MAIN: #your code will go here EXIT End of file 3. Assemble the file (F3). You should receive no warnings or emors. Requirements: Write a MIPS program that does the following: l. Prompt the user to enter how many integer values they would like to enter (up to 50). Assume that the user will not type in a number that is greater than 50. 2. Read in the number of integer values that the user would like to enter. 3. Read in the integer values from the user. 4. Store the values in an array in the same order in which the user enters them.Explanation / Answer
MIPS CODE :
$LFB0 = .
main:
addiu $sp,$sp,-248
sw $31,244($sp)
sw $fp,240($sp)
move $fp,$sp
lui $2,%hi($LC0)
addiu $4,$2,%lo($LC0)
jal printf
nop
addiu $2,$fp,236
move $5,$2
lui $2,%hi($LC1)
addiu $4,$2,%lo($LC1)
jal scanf
nop
lui $2,%hi($LC2)
addiu $4,$2,%lo($LC2)
jal puts
nop
$LBB2 = .
sw $0,24($fp)
lw $2,236($fp)
lw $3,24($fp)
nop
slt $2,$3,$2
beq $2,$0,$L2
nop
addiu $3,$fp,36
lw $2,24($fp)
nop
sll $2,$2,2
addu $2,$3,$2
move $5,$2
lui $2,%hi($LC1)
addiu $4,$2,%lo($LC1)
jal scanf
nop
lw $2,24($fp)
nop
addiu $2,$2,1
sw $2,24($fp)
b $L3
nop
$LBE2 = .
lui $2,%hi($LC3)
addiu $4,$2,%lo($LC3)
jal puts
nop
$LBB3 = .
sw $0,28($fp)
lw $2,236($fp)
lw $3,28($fp)
nop
slt $2,$3,$2
beq $2,$0,$L4
nop
lw $2,28($fp)
nop
sll $2,$2,2
addiu $3,$fp,24
addu $2,$3,$2
lw $2,12($2)
nop
move $5,$2
lui $2,%hi($LC4)
addiu $4,$2,%lo($LC4)
jal printf
nop
lw $2,28($fp)
nop
addiu $2,$2,1
sw $2,28($fp)
b $L5
nop
$LBE3 = .
lui $2,%hi($LC5)
addiu $4,$2,%lo($LC5)
jal puts
nop
$LBB4 = .
lw $2,236($fp)
nop
addiu $2,$2,-1
sw $2,32($fp)
lw $2,32($fp)
nop
bltz $2,$L6
nop
lw $2,32($fp)
nop
sll $2,$2,2
addiu $3,$fp,24
addu $2,$3,$2
lw $2,12($2)
nop
move $5,$2
lui $2,%hi($LC4)
addiu $4,$2,%lo($LC4)
jal printf
nop
lw $2,32($fp)
nop
addiu $2,$2,-1
sw $2,32($fp)
b $L7
nop
$LBE4 = .
move $2,$0
move $sp,$fp
lw $31,244($sp)
lw $fp,240($sp)
addiu $sp,$sp,248
j $31
nop
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.