I wish to access the value of the MIPS coprocessor 1 condition flag.
For example
c.eq.s $f4 $f6
move $t0 condflag1 #clearly illegal
I understand that the following is possible:
c.eq.s $f4 $f6
bc1f L_CondFalse
li $t0 0
j L_CondEnd
L_CondFalse : li $t0 1
L_CondEnd :
Any ideas?
You can avoid branching by using conditional move instruction (available since MIPS32).
li $t0, 1 # move 1 into t0
c.eq.s $f4, $f6 # compare f4 and f6; set FCC[0] to the result
movt $t0, $0, $fcc0 # move 0 into t0 if comparison was true
(not tested)
Another option is to move the FCCR into a GPR and read the bit 0.
cfc1 $t0, $25 # load FCCR into t0
andi $t0, 1 # mask the bit 0 only
FCCR is not available before MIPS32, so you might have to use FCSR ($31) instead.