Question: Create a flowchart for the following MIPS code: # Registers used: # $t 0 for A # $t 1 for B # $t 2 for
Create a flowchart for the following MIPS code:
# Registers used:
# $t for A
# $t for B
# $t for C
# $t for D
# $t$t is used to store results from evaluations
data
promptA: asciiz "Enter integers for A B C D respectively:"
resultFb: asciiz ftwo:"
resultFten: asciiz ften:
resultGb: asciiz gtwo:
resultGten: asciiz gten:
newline: asciiz
text
main:
#input promptA
la $a promptA
li $v
syscall
#newline
li $v
la $a newline
syscall
#read integers from users input
li $v
syscall
move $t $v #int A$t
li $v
syscall
move $t $v #int B$t
li $v
syscall
move $t $v #int C$t
li $v
syscall
move $t $v #int D$t
li $t
li $t
loopb:
beqz $t exit #if B exit loop
add $t $t $t
subi $t $t #repeat addition B number of times
j loopb
exit:
li $t
move $t $t #copy Ds value to $t
loopbd:
beqz $t exit #if D exit loop
add $t $t $t
subi $t $t #repeat subsequent addition D number of times
j loopbd
exit:
add $t $t $t #calculate fBDA
#input resultFten
la $a resultFten
li $v
syscall
move $a $t #move f result into $a
li $v #print F in decimal
syscall
#newline
li $v
la $a newline
syscall
#input resultFb
la $a resultFb
li $v
syscall
move $a $t #move f result into $a
li $v #print F in binary
syscall
#newline
li $v
la $a newline
syscall
move $t $t #copy Ds value to $t
li $t
loopDD:
beqz $t exit #if D exit loop
add $t $t $t
subi $t $t #repeat addition D number of times
j loopDD
exit:
li $t
loopCA:
beqz $t exit #if A exit loop
add $t $t $t
subi $t $t #repeat addition A number of times
j loopCA
exit:
sub $t $t $t #compute g result
#input resultGten
la $a resultGten
li $v
syscall
move $a $t #move G result into $a
li $v #print G in decimal
syscall
#newline
li $v
la $a newline
syscall
#input resultGb
la $a resultGb
li $v
syscall
move $a $t #move G result into $a
li $v #print G in binary
syscall
#newline
li $v
la $a newline
syscall
#exit program
li $v
syscall
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
