Question: Implement the read, reverse, and print functions used by f function in Figure 7.6 & Figure 7.7 in the PDF file. These functions should work

Implement the read, reverse, and print functions used by f function in Figure 7.6 & Figure 7.7 in the PDF file. These functions should work with any size n not only size 10. Then write a main function that calls function f.

I did read and print function but I don't know how to do the reverse function

this is my code

.data integer: .asciiz "Enter int " array: .word 10 .text #caller jal f li $v0,10 syscall

f: addiu $sp, $sp, -44 # allocate stack frame = 44 bytes sw $ra, 40($sp) # save $ra on the stack move $a0, $sp # $a0 = address of array on the stack li $a1, 10 # $a1 = 10 jal read # call function read move $a0, $sp # $a0 = address of array on the stack li $a1, 10 # $a1 = 10 jal reverse # call function reverse move $a0, $sp # $a0 = address of array on the stack li $a1, 10 # $a1 = 10 jal print # call function print lw $ra, 40($sp) # load $ra from the stack addiu $sp, $sp, 44 # Free stack frame = 44 bytes jr $ra # return to caller #read(int*array,int size) read: beq $t0,$a1,endread li $v0,5 syscall sw $v0,($a0) addi $t0,$t0,1 addi $a0,$a0,4 j read endread: jr $ra

print: beq $t1,$a1,endprint lw $t2,($a0) #move $t3,$a0 addi $a0,$a0,4 move $t3,$a0 addi $t1,$t1,1 move $a0,$t2 li $v0,1 syscall

li $v0,11 li $a0,' ' syscall

move $a0,$t3 j print

endprint: jr $ra

reverse:

endreverse: jr $ra

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!