davidx1
davidx1

Reputation: 3673

Branch On Equal In Assembly/Machine Code

What is the difference between using:

c.eq.s    $1, $2
bc1t      L2

And using:

beq $1, $2, L2

Why are there two ways to branch if they do the same thing? And if they are different, what's the benefit of each?

Thanks

EDIT: I wasn't aware "c.eq.s" is coprocessor specific. I only wrote $1, $2 instead of $f1, $f2, for uniformity with the second set of code.

Upvotes: 2

Views: 13958

Answers (1)

paxdiablo
paxdiablo

Reputation: 881113

The bc1t instruction simply branches if math co-processor condition bit 1 is true. That is the case here if the two registers were equal. It's equivalent to simply branching if the values are equal, with beq, but only if the registers were in fact the same registers in both cases.

With the MIPS floatiing point co-processor, the registers should be $f1/$f2 in the c.eq.s instruction so the two instructions would not be equivalent. I have never seen the use of $1/$2 in floating point instructions, other than in those that move data between the regular registers and the co-processor ones.

I think the only way to floating point conditional branches in in a two-step manner. The IDT MIPS Microprocessor Family Software Reference Manual states:

The FP test and branch instructions are separate. A test instruction compares two FP values and set the FPA condition bit accordingly (C in the FP status register); the branch instructions branch on whether the bit is set or unset.

Upvotes: 4

Related Questions