Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help to translate the following C++ code into MIPS language. Thank you. #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++# #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++# #void ProcArraysA(int a1[], int a2[], int a3[], int a4[],

I need help to translate the following C++ code into MIPS language.

Thank you.

#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#

#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#

#void ProcArraysA(int a1[], int a2[], int a3[], int a4[], int* used1Ptr, int* used2Ptr, int used3, int used4)

# $a0 $a1 $a2 $a3 16($fp) 20($fp) 24($fp) 28($fp)

#{

###############################################################################

ProcArraysA:

#################

# Register usage:

#################

# $t0: holder for a value/address

# $t1: hopPtr (must preserve across call to InsertSortedND)

# $t9: endPtr (must preserve across call to InsertSortedND)

# $v1: another holder for a value/address

# (usual ones for syscall & function call)

###############################################################################

####################(46)####################

# PROLOG:

# BODY:

# *used1Ptr = 0;

lw $t0, 16(sp)

sw $zero,0($t0)

# *used2Ptr = 0;

lw $t0, 20($sp)

sw $zero,0($t0)

# int* hopPtr = a3;

# int* endPtr = a3 + used3;

# goto WTest1_PAA;

# //while (hopPtr < endPtr)

begW1_PAA:# //{

# InsertSortedND(a1, used1Ptr, *hopPtr);

# ++hopPtr;

#// }

WTest1_PAA:

# if (hopPtr < endPtr) goto begW1_PAA;

# hopPtr = a4;

# endPtr = a4 + used4;

# goto WTest2_PAA;

# //while (hopPtr < endPtr)

begW2_PAA:# //{

# InsertSortedND(a2, used2Ptr, *hopPtr);

# ++hopPtr;

#// }

WTest2_PAA:

# if (hopPtr < endPtr) goto begW2_PAA;

# EPILOG:

#}

#########################################

# deliberate clobbering of caller-saved

# (meant to catch improper presumptions -

# no effect if no such presumptions made)

#########################################

li $a0, 999999999

li $a1, 999999999

li $a2, 999999999

li $a3, 999999999

li $t0, 999999999

li $t1, 999999999

li $t2, 999999999

li $t3, 999999999

li $t4, 999999999

li $t5, 999999999

li $t6, 999999999

li $t7, 999999999

li $t8, 999999999

li $t9, 999999999

li $v0, 999999999

li $v1, 999999999

#########################################

jr $ra

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

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Did I see new opportunities and act on them? What surprised me?

Answered: 1 week ago