(MIPS) How to perform floating point operations only using addition and subtraction

懵懂的女人 提交于 2020-01-25 08:16:08

问题


I'm tasked with trying to find the value of a certain mathematical expression without using multiplication or division: f =(0.1×A^4) -(0.2×B^3) + (0.3×C^2) -(0.4×D). I have to use subroutines to help with the calculations. I'm currently trying to find the first term and I am lost right now. This is what I have so far:

.data
prompt: .asciiz "Enter 4 integers for A, B, C, D respectively: \n"
newLine: .asciiz "\n"
f_output: .asciiz "f= "
g_output: .asciiz "g= "

.text
main:
li $v0, 4   #displaying prompt
la $a0, prompt
syscall

li $v0, 6   #getting A value
syscall
mov.s $f1, $f0

li $v0, 6   #getting B value
syscall
mov.s $f2, $f0

li $v0, 6   #getting C value
syscall
mov.s $f3, $f0

li $v0, 6   #getting D value
syscall
mov.s $f4, $f0

mfc1 $a0, $f1
jal ATermCalculator

EXIT:
li $v0, 10
syscall


ATermCalculator:
mtc1 $a0, $f1
lwc1 $f5, 0 #Using this to compare to $f1 and to be a counter to get A^2

A2Calculator:
c.eq.s $f1, $f5
bc1t A4Calculator
add.s $f5, $f5, 1
bc1f A2Calculator

A4Calculator

My thought process is that I have to see if the counter $f5 is equal to $f1 and increment the counter and keep adding $f1 to itself until it becomes A^2 and then to repeat that process again.

Thank you for any help!

来源:https://stackoverflow.com/questions/59119467/mips-how-to-perform-floating-point-operations-only-using-addition-and-subtract

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!