Firstly, I am a beginner learning Assembly/Machine code, so forgive me if I am asking the obvious.
I was reading some code and came across a snippit where the code puts “1.0” into a floating point coprocessor registers.
The code is
addi $t5, $0, 1
mtc1 $t5, $f2
cvt.s.w $f0, $f2 # 1.0 in $f0
My first question is:
Why does it have to put “1” into “$t5” first, before transferring it into a coprocessor? Wouldn’t it be easier to do
addi $f2, $0, 1
or even
addi $f2, $0, 1.0
My second question is:
for this line of code
cvt.s.w $f0, $f2 # 1.0 in $f0
Is it necessary for the two register to be different? Or can they both be $f2?
Instructions operate on the type of registers laid out in its specifications, if you want to know read it.
So no
addicannot operate on coprocessor registersIt doesn’t say that fd and fs have to be different so unless is some other rule about source and destination register can’t be the same you can use one.