1

I'm writing a program to convert temperature from F to C in MIPS but the compiler returns 0. It works when I do it with integers, any ideas on what could be wrong?

Code Section

    .text
main:

    # Print msg
    la      $4, input_msg
    li      $2, PRINT_STR
    syscall

    # Prompt user for input
    li      $2, READ_INT
    syscall



    move     $t0, $2             #load f from memory
    sub      $t0, $t0, 32      # f -32
    mul      $t0, $t0, 5      #(f-32)*5
    div      $t0, $t0, 9       #((f-32)*5)/9  
    mtc1     $t0, $t1 
    move     $4, $t1
    li       $2, 2
    syscall

    li      $4, 0
    li      $2, 17
    syscall

The output should be the Celsius temperature in float but it returns 0.

Michael
  • 57,169
  • 9
  • 80
  • 125
acelifter
  • 11
  • 3
  • `mtc1 $t0, $t1` <-- What is that supposed to do (and how does that even assemble)? Anyway, use the simulator's single-step feature to step through your code until you find where it goes wrong. – Michael Nov 04 '19 at 07:34

0 Answers0