Pseudoinstructions: logical | ||||||||||||
Instruction | Real instructions | Semantics | ||||||||||
not $rd, $rs | addi $at, $0, -1 | # R[1] = -1 | ||||||||||
xor $rd, $rs, $at | # R[d] = R[s] ^ R[1] | |||||||||||
Better way: | ||||||||||||
not $rd, $rs | nor $rd, $rs, $0 | # R[d] = ~R[s] | ||||||||||
Why does this work? | ||||||||||||
a | b | a | b | ~(a|b) | ~(0|b) | ~b | |||||||
0 | 0 | 0 | 1 | 1 | 1 | |||||||
0 | 1 | 1 | 0 | 0 | 0 | |||||||
1 | 0 | 1 | 0 | |||||||||
1 | 1 | 1 | 0 | |||||||||