MIPS - expand SLE pseudoinstruction
From
kukadlo@pobox.sk@21:1/5 to
All on Tue Jan 17 21:51:35 2017
Hello,
Probably way too late to reply, but I was actually looking for it and this post come near top in google (and I didn't find it).
So I finally got about 20h later (after I got curious) to MARS simulator, to see how it does it (was driving me crazy), and it turned out I had total mind blackout :/.
slt is (x < y)
sle is (x <= y) <=> !(x > y) <=> !(y < x)
Doh! I mean... I was even "so sge is 'slt (y < x)', I see, but how do they the sle?". Blind leads blind...
So it gets compiled as:
sle $4, $5, $6 =
slt $4, $6, $5 ; r = y < x
ori $1, $0, 1 ; $at = 1
subu $4, $1, $4 ; r = $at - r = not(y < x)
Which leaves me wondering, why not:
sle $4, $5, $6 =
slt $4, $6, $5 ; r = y < x
xori $4, $4, 1 ; r = not(y < x)
? is xori somehow bad? (I don't know anything about MIPS CPU, I just by accident did help with some assembly to somebody else, and the "sle"-being-only-pseudo-instruction made me curious, how one can do it simply)
And for completeness:
seq (x == y) is treated a bit sideways, it does: r = |x - y| < 1
subu r, x, y
ori $at, $zero, 1
sltu r, r, $at
sne (x != y) is: r = 0 < |x - y|
subu r, x, y
sltu r, $zero, r
Ped7g
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)