On the topic of micro-optimizations, here's a new (?) one.
I was reading the coldfire manual today, and I found that it suggested using trapf instead of unconditional bra.b in if-else type clauses with very short jump distance (+2 or +4).
cmp d0,d1
beq.b hej
moveq #1,d2
bra.b hopp
hej:
moveq #2,d2
hopp:
Here the "bra.b hopp" can be replaced by encoding the followin moveq as the argument to a trapf.w instruction. The moveq would not be executed, unless the beq.b is taken.
This should possible on 68k aswell, allthough its not mentioned in the PRM. But the CF manual does not say anything about the benefits of this. Could anyone say if this is really faster than bra.b?