0

I am trying to write a MIPS program that takes a user entered float value in degrees Fahrenheit and convert it to degrees Celsius. However, I'm having a difficult time finding the user entered float.

My code up to the float read:

.data
getDegreesF:  .asciiz "Please enter the degrees in Fahrenheit: "
degreesF:  .asciiz " degrees Fahrenheit is "
degreesC:  .asciiz " degrees Celsius."
.text

.globl main
addi $sp, $sp, -8
sw $s0, 0($sp)
sw $s1, 84($sp)

main:
la $a0, getDegreesF #load getDegreeF sting
li $v0, 4       #syscall to print string
syscall

li $v0, 6       #syscall to read float
syscall

li $v0, 10      #syscall to exit program
syscall

My understanding is that, once the float is read, it is stored in $f0. I want to place it in $s0, but I keep getting a syntax error. What am I doing wrong?

Thanks.

Blackwell
  • 85
  • 2
  • 10
  • `$f0` is a floating point register, `$s0` is an integer register. Usually it doesn't make sense to move between them (but it is possible). You should instead say the **actual** issue, why you need it in `$s0`. See also [XY problem](http://xyproblem.info/). – Jester May 03 '15 at 23:00
  • Sorry, the goal is to take the entered value, subtract 32 from it, multiply the result by 5, divide that result by 9 and place it in a register for printing. My output should be "__ degrees Fahrenheit is __ degrees Celsius." So I want to save the user entered value for printing, and I want to save the converted value for printing. I did try move $f1, $f0 and got a syntax error as well. – Blackwell May 03 '15 at 23:08
  • 3
    You need to use the coprocessor instructions `mov.s` or `mov.d` as appropriate. Read up on the instruction set. Also note that `$f1` is not available, it's the second half of `$f0` when used for double precision. – Jester May 03 '15 at 23:11

0 Answers0