Why can't I use li.s in MARS?

I can not use li.s in MARS. I am new to MIPS programming and I try not to use any processors. Why can't I use li.s - is it a MARS program? It would be very helpful if someone could lead me in a new direction!

+4
source share
2 answers

You can achieve the same effect as the pseudo-instruction li.s using the pseudo-instruction ls and the constant stored in the data segment:

ls $f1, fpconst .data 0x1000 fpconst: .float 1.2345 

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

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

0
source

This is a pseudo-instruction that is probably not implemented on Mars. You can use the sequence li (ori) and mtc1.

Loads the value 1.234 into $ fp1 and works in MARS:

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

a 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 it is similarly using a cast pointer):

 read(*,*) a i=transfer(a,i) write(*,*) i end 
+2
source

Source: https://habr.com/ru/post/1380498/


All Articles