Domanda

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!

È stato utile?

Soluzione

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

Altri suggerimenti

It is a pseudoinstruction, which is probably not implemented in mars. You can use sequence of li (ori) and mtc1.

This loads the value 1.234 to $fp1 and works in MARS:

li $t1,0x3f9df3b6
mtc1 $t1,$f1

the hexadecimal or integer value can be found using http://babbage.cs.qc.edu/IEEE-754/Decimal.html or using a simple program (in Fortran, in C is similar using a pointer cast):

read(*,*) a
i=transfer(a,i)
write(*,*) i
end
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top