Мне нужно создать программу, в которую я ввожу 3 десятичных значения, и она возвращает значения с плавающей запятой этих десятичных значений. Затем предполагается вычислить и распечатать максимум для первых двух значений, а также распечатать сумму и произведение всех введенных значений. У меня есть сумма и продукт работает. Я только что получил максимум для работы, но он не будет распечатывать сумму и продукты после вычисления максимума. Я мог бы пропустить что-то, что может быть очень очевидным, но я не могу понять это.
Вот код:
.data
sum: .word 0
max: .word 0
prod: .word 0
bias: .word 127
prompt: .asciiz "Enter 3 Floating Point Numbers on separate lines: \n"
bues: .asciiz "Biased and Unbiased exponents and significand: \n"
msp: .asciiz "Max, Sum, and Product: \n"
crlf: .asciiz "\n" #For printing a lf
.macro out_str($arg1)
li $v0, 4
la $a0, $arg1
syscall
.end_macro
.text
.globl main #System 'calls' main
main:
############################# PART 1 #############################
#ENTER 3 FLOATING POINT NUMBERS ON SEPARATE LINES
out_str(prompt) #Print the user prompt
#Get first number
li $v0, 6 #Read FP into $f0
syscall #Do the read
mov.s $f12, $f0 #Copy $f0 to $f12 for printing
mov.s $f1, $f0 #Copy $f0 to $f1 for calculating
li $v0, 2 #Print FP from $f12
syscall #Do the print
out_str(crlf) #Print cr and lf
#Get second number
li $v0, 6 #Read FP into $f0
syscall #Do the read
mov.s $f12, $f0 #Copy $f0 to $f12 for printing
mov.s $f2, $f0 #Copy $f0 to $f2 for calculating
li $v0, 2 #Print FP from $f12
syscall #Do the print
out_str(crlf) #Print string
#Get third number
li $v0, 6 #Read FP into $f0
syscall #Do the read
mov.s $f12, $f0 #Copy $f0 to $f12 for printing
mov.s $f3, $f0 #Copy $f0 to $f2 for calculating
li $v0, 2 #Print FP from $f12
syscall #Do the print
out_str(crlf) #Print string
############################# PART 2 #############################
#Calculate the MAX, SUM, PRODUCT.
out_str(msp) #Print the Max, Sum, Product line
### MAX ###
c.eq.s $f1,$f2
bc1t printequal
c.lt.s $f1,$f2 # is f1 < f2?
bc1t print2
c.lt.s $f2,$f1 # is f2 < f1?
bc1t print1
### SUM ###
jal a3fp #Calculate the sum
s.s $f4, sum #Store the sum into memory
mov.s $f12, $f4 #Get the sum in $f12 for printing
li $v0, 2 #Print sum
syscall
out_str(crlf) #Print string
### PRODUCT ###
jal m3fp #Calculate the product
s.s $f5, prod #Store the product into memory
mov.s $f12, $f5 #Put the product in $f12 for printing
li $v0, 2 #Print product
syscall
# MARS return to system.
li $v0, 10
syscall
printequal:
mov.s $f12, $f1
li $v0, 2
syscall
out_str(crlf)
print1:
mov.s $f12,$f1 # print f1
li $v0, 2
syscall
out_str(crlf)
print2:
mov.s $f12,$f2 # print f2
li $v0, 2
syscall
out_str(crlf)
############ FUNCTIONS ############
#Add: $f1 + $f2, puts in $f4, then adds $f3 to $f4 and stores sum in $f4
a3fp:
add.s $f4, $f1, $f2
add.s $f4, $f4, $f3
jr $ra # return to caller
#multiply: $f1 * $f2, puts in $f5, then multiplies $f5 to $f3 and stores sum in $f5
m3fp:
mul.s $f5, $f1, $f2
mul.s $f5, $f5, $f3
jr $ra # return to caller
Я думаю, что основная проблема связана с c .eq.s и команды c .lt.s для веток .. Пожалуйста, дайте мне знать, что, по вашему мнению, может быть проблемой.