Search code examples
assemblymipsmips32mars-simulator

Why can I not use li.s in MARS?


I cannot use li.s in MARS. I am new to MIPS programming and I am trying not to use any co processors. Why can I not use li.s is MARS the program? It would be very helpful is someone could lead me in a new direction!


Solution

  • You can achieve the same effect as the pseudoinstruction li.s using pseudoinstruction l.s and the constant stored in the data segment:

      l.s $f1, fpconst
    
    .data 0x1000
    fpconst:
    .float 1.2345
    

    That will use the coprocessor register $f1 to store the floating point constant.

    You can also put the constant in a regular register using lw $f1, fpconst instead of l.s