Description For project four, your objective is to convert the given C++ code in
ID: 3741581 • Letter: D
Question
Description For project four, your objective is to convert the given C++ code into MIPS assembly. Please do not modify the C++ code itself. You are only allowed to make modifications to the assembly file. Start writing your code below the main: label and above the exit: label. For this project stay BETWEEN these labels. When doing a C++ to MIPS conversion, it can be done in the following steps: 1 Assign variables to registers. When inspecting code, any constant values in expressions may need to be assigned to temporary registers 2 Initialize variables to registers. (actually put the values into the registers.) 3 Then you may begin converting the rest of the code.. Before you begin, please make sure you click the link on ilearn to create your GitHub repo. After created please clone this repo with the git clone repo.url command. Expected Output: Sum: 7179 Reversed Number: 98654 is Palindrome: 1 Submission When you have completed the assignment please commit all work done to your private repository. This can be done with the following commands: git add git comit -m "some meBsage" git pushExplanation / Answer
NOTE:- I wrote the answer which is required to be placed between labels main and exit. Thank you
MIPS PROGRAM:-
main:
sum_of_array:
li $t0,0
la $s1,sumarr
li $t2,10
li $s0,0
loop_sum_of_array:
beq $t0,$t1,end_loop_sum_of_array
lw $t4,0($s1)
add $s0,$s0,$t4
addi $s1,$s1,4
addi $t0,$t0,1
j loop_sum_of_array
end_loop_sum_of_array:
li $s1,sumarr
reverse_number:
xor $s2,$s2,$s2
li $t0,10
beqz $s3,end_of_reverse
loop_of_reverse:
div $s3,$t0
mflo $s3
mfhi $t4
mul $s2,$s2,$t0
add $s2,$s2,$t4
bgtz $s3,loop_of_reverse
end_of_reverse:
prog_is_palindrome:
la $s5,arr #start of array
li $t0,8
li $t4,4
mul $t0,$t0,$t4
add $t0,$s5,$t0 #end of array
li $s4,1
loop_of_palindrome:
beq $s5,$t0,end_of_loop_of_palindrome
lw $t1,0($s5)
lw $t2,0($t0)
bne $t1,$t2,not_palindrome
addi $s5,$s5,4
addi $t0,$t0,-4
j loop_of_palindrome
not_palindrome:
li $s4,0
end_of_loop_of_palindrome:
exit: