Question: part a . data Num 1 : . double 4 . 6 4 #Number being added Prompt: . asciiz Enter a number: #Prompt .
part a
data
Num:double #Number being added
Prompt:asciiz "Enter a number: #Prompt
text
Main:
#Outputs prompt
li $v
la $a Prompt
syscall
#Input floating point
#Stored in register f
li $v
syscall
ldc $f Num #Loads Num into f
add.d $f $f $f #Performs floating point addition
#Output floating point number
mov.d $f $f #Moved to output register
li $v
syscall
#Closes program
li $v
syscall
part bdata
Zero:double #Number being compared to
Prompt:asciiz "Enter a number: #Prompt
text
#Loads Zero into f
ldc $f Zero
Loop: #Loop of program
#Outputs prompt
li $v
la $a Prompt
syscall
#Input floating point
#Stored in register f
li $v
syscall
#If statement to exit program
cltd $f$f #Chechs if less than zero. If so set flag
bct end #If flag set than exit program
#Output floating point number
mov.d $f $f #Moved to output register
li $v
syscall
#Outputs newline
li $v
li $a
syscall
b Loop
end:
#Closes program
li $v
syscall
part c
data
Zero:double #Number being compared to
Prompt:asciiz "Enter a number: #Prompt
text
#Loads Zero into f and f
ldc $f Zero
ldc $f Zero
#Zeroes t
li $t
Loop: #Loop of program
#Outputs prompt
li $v
la $a Prompt
syscall
#Input floating point
#Stored in register f
li $v
syscall
#If statement to exit program
cltd $f$f #Chechs if less than zero. If so set flag
bct end #If flag set than exit program
#Addition performed
add.d $f$f$f #Adds new number to total
add $t$t #Increment total number of inputs
b Loop
end:
#Converts t value to double
mtc $t $f #Moves to double register
cvtdw $f$f #Preforms conversion
#Preforms divison
div.d $f$f$f
#Output floating point number
mov.d $f $f #Moved to output register
li $v
syscall
#Closes program
li $v
syscall
part d
data
someGrade:word
Grades:asciiABCDF
Prompt:asciiz "Enter a grade number: #Prompt
text
li $v
la $a Prompt
syscall
li $v
syscall
cvtwd $f $f
mfc $t$f
#lw $t someGrade
la $t Grades
blt $t RecL
blt $t AD
blt $t AC
blt $t AB
lb $t Grades#They get an A
b endCase
AB:lbu $t$t # they get a B
b endCase
AC:lb $t$t
b endCase
AD:lb $t$t
b endCase
RecL: lb $t$t #They're Dumb
endCase:
move $a $t
li $v
syscall
li $v
syscall
part e
#Macro to end program
macro done
li $v
syscall
endmacro
#Macro to get double and output prompt
macro GetDoublevalue
#Outputs prompt
li $v
la $avalue
syscall
#Input floating point
#Stored in register f
li $v
syscall
endmacro
data
someGrade:word
Grades:asciiABCDF
Prompt:asciiz "Enter a grade number: #Prompt
text
GetDoublePrompt
cvtwd $f $f
mfc $t$f
#lw $t someGrade
la $t Grades
blt $t RecL
blt $t AD
blt $t AC
blt $t AB
lb $t 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
