Question: Identify and define. Make a table for registers and one for labels with their respective names and descriptions. .data prompt: .asciiz Enter integers for A,
Identify and define. Make a table for registers and one for labels with their respective names and descriptions.
.data prompt: .asciiz "Enter integers for A, B, C, D: " newLine: .asciiz " " decimal: .asciiz "f_ten = " binary: .asciiz "f_two = " decimal2: .asciiz "g_ten = " binary2: .asciiz "g_two = " .text
main: #display prompt li $v0, 4 la $a0, prompt syscall
#read A in $v0 and store in $t0 li $v0, 5 syscall move $t0, $v0
#read B in $v0 and store in $t1 li $v0, 5 syscall move $t1, $v0 #read C in $v0 and store in $t2 li $v0,5 syscall move $t2, $v0 #read D in $v0 and store in $t3 li $v0, 5 syscall move $t3, $v0
#A^4 #loop (A x A) li $t6, 0
L1: bge $t6, $t0, quit add $s1, $s1, $t0 #a = s + a addi $t6, $t6, 1 #i = i + 1 j L1 quit: li $t6, 0 L1A: bge $t6, $s1, quit1A add $s5, $s5, $s1 addi $t6,$t6, 1 j L1A #find 4 x A^3 quit1A: #loop (4 x B) li $t6, 0 L2: bge $t6, 4, quit2 add $s2, $s2, $t1 addi $t6, $t6, 1 j L2 quit2: #loop (B x B) li $t6, 0 L2A: bge $t6, $t1, quit2A add $s6, $s6, $t1 addi $t6,$t6, 1 j L2A quit2A: #loop (B x B) li $t6, 0 L2AA: bge $t6, $s2, quit2AA add $t7, $t7, $s6 addi $t6,$t6, 1 j L2AA #loop 2 #find 3 x C^2 quit2AA: li $t6, 0 L3: bge $t6, $t2, quit3 add $s3, $s3, $t2 addi $t6,$t6, 1 j L3 #find 2 x D quit3: li $t6, 0
L3A: bge $t6, 3, quit3A add $s0, $s0, $s3 addi $t6,$t6, 1 j L3A quit3A: li $t6, 0 L4: bge $t6, 2, quit4 add $s4, $s4, $t3 addi $t6,$t6, 1 j L4 #find A x B^2 quit4: li $t6, 0 li $s1, 0 L5: bge $t6, $t1, quit5 add $s1, $s1, $t1 addi $t6, $t6, 1 j L5 quit5: li $t6, 0 li $s2, 0
L6: bge $t6, $t0, quit6 add $s2, $s2, $s1 addi $t6, $t6, 1 j L6 #find C^2 x D^3 quit6: #C^2: li $t6, 0 li $s1, 0
L7: bge $t6, $t2, quit7 add $s1, $s1, $t2 addi $t6, $t6, 1 j L7 quit7: #D^2 li $t6, 0 li $s6, 0
L8: bge $t6, $t3, quit8 add $s6, $s6, $t3 addi $t6, $t6, 1 j L8 quit8: #D^3 li $t6, 0 li $s7, 0 L9: bge $t6, $t3, quit9 add $s7, $s7, $s6 addi $t6, $t6, 1 j L9 quit9: #C^2 x D^3 li $t6, 0 li $s3, 0
L10: bge $t6, $s1, end add $s3, $s3, $s7 addi $t6, $t6, 1 j L10 end: #program termination #f -> $t8 li $t8 , 0 sub $t8, $s5, $t7 add $t8, $t8, $s0 sub $t8,$t8, $s4 #g -> $t9 li $t9 , 0 add $t9, $s2, $s3
Display: #equation 1 li $v0,4 #answer string with syscall $v0 = 4 la $a0, decimal #answer in decimal syscall #value returned in register $v0
li $v0, 1 #answer string with syscall $v0=1 move $a0, $t8 #moves value $a0 to $t8 syscall
li $v0,4 #answer string with syscall $v0=4 la $a0, newLine # in between syscall
li $v0,4 #answer string with syscall $v0=4 la $a0, binary #answer in binary syscall
li $v0, 35 move $a0, $t8 syscall
li $v0,4 #answer string with syscall $v0=4 la $a0, newLine syscall
#equation 2 li $v0,4 #answer string with syscall $v0=4 la $a0, decimal2 syscall
li $v0, 1 #answer string with syscall $v0=1 move $a0, $t9 syscall
li $v0,4 #answer string with syscall $v0=4 la $a0, newLine syscall li $v0,4 #answer string with syscall $v0=4 la $a0, binary2 syscall
li $v0, 35 move $a0, $t9 syscall
li $v0,4 #answer string with syscall $v0=4 la $a0, newLine syscall #end program li $v0, 10 syscall
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
