Question: part a . data Num 1 : . double 4 . 6 4 #Number being added Prompt: . asciiz Enter a number: #Prompt .

part a
.data
Num1:.double 4.64 #Number being added
Prompt:.asciiz "Enter a number: " #Prompt
.text
Main:
#Outputs prompt
li $v0,4
la $a0, Prompt
syscall
#Input floating point
#Stored in register f0
li $v0,7
syscall
ldc1 $f2, Num1 #Loads Num1 into f2
add.d $f2, $f2, $f0 #Performs floating point addition
#Output floating point number
mov.d $f12, $f2 #Moved to output register
li $v0,3
syscall
#Closes program
li $v0,10
syscall
part b.data
Zero:.double 0.0 #Number being compared to
Prompt:.asciiz "Enter a number: " #Prompt
.text
#Loads Zero into f4
ldc1 $f4, Zero
Loop: #Loop of program
#Outputs prompt
li $v0,4
la $a0, Prompt
syscall
#Input floating point
#Stored in register f0
li $v0,7
syscall
#If statement to exit program
c.lt.d 2 $f0,$f4 #Chechs if less than zero. If so set 2 flag
bc1t 2, end #If 2 flag set than exit program
#Output floating point number
mov.d $f12, $f0 #Moved to output register
li $v0,3
syscall
#Outputs newline
li $v0,11
li $a0,10
syscall
b Loop
end:
#Closes program
li $v0,10
syscall
part c
.data
Zero:.double 0.0 #Number being compared to
Prompt:.asciiz "Enter a number: " #Prompt
.text
#Loads Zero into f4 and f2
ldc1 $f4, Zero
ldc1 $f2, Zero
#Zeroes t1
li $t1,0
Loop: #Loop of program
#Outputs prompt
li $v0,4
la $a0, Prompt
syscall
#Input floating point
#Stored in register f0
li $v0,7
syscall
#If statement to exit program
c.lt.d 2 $f0,$f4 #Chechs if less than zero. If so set 2 flag
bc1t 2, end #If 2 flag set than exit program
#Addition performed
add.d $f2,$f2,$f0 #Adds new number to total
add $t1,$t1,1 #Increment total number of inputs
b Loop
end:
#Converts t1 value to double
mtc1 $t1, $f6 #Moves to double register
cvt.d.w $f6,$f6 #Preforms conversion
#Preforms divison
div.d $f2,$f2,$f6
#Output floating point number
mov.d $f12, $f2 #Moved to output register
li $v0,3
syscall
#Closes program
li $v0,10
syscall
part d
.data
someGrade:.word 76
Grades:.ascii"ABCDF"
Prompt:.asciiz "Enter a grade number: " #Prompt
.text
li $v0,4
la $a0, Prompt
syscall
li $v0,7
syscall
cvt.w.d $f0, $f0
mfc1 $t1,$f0
#lw $t1, someGrade
la $t2, Grades
blt $t1,50, RecL
blt $t1,60, A_D
blt $t1,70, A_C
blt $t1,80, A_B
lb $t3, Grades#They get an A
b endCase
A_B:lbu $t3,1($t2) # they get a B
b endCase
A_C:lb $t3,2($t2)
b endCase
A_D:lb $t3,3($t2)
b endCase
RecL: lb $t3,4($t2) #They're Dumb
endCase:
move $a0, $t3
li $v0,11
syscall
li $v0,10
syscall
part e
#Macro to end program
.macro done
li $v0,10
syscall
.end_macro
#Macro to get double and output prompt
.macro GetDouble(%value)
#Outputs prompt
li $v0,4
la $a0,%value
syscall
#Input floating point
#Stored in register f0
li $v0,7
syscall
.end_macro
.data
someGrade:.word 76
Grades:.ascii"ABCDF"
Prompt:.asciiz "Enter a grade number: " #Prompt
.text
GetDouble(Prompt)
cvt.w.d $f0, $f0
mfc1 $t1,$f0
#lw $t1, someGrade
la $t2, Grades
blt $t1,50, RecL
blt $t1,60, A_D
blt $t1,70, A_C
blt $t1,80, A_B
lb $t3, Grades#They get an A
b endCase

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 Programming Questions!