| Bitwise logical operations | |||||||||||||
| R-type | |||||||||||||
| and $rd, $rs, $rt # R[d] <- R[s] & R[t] | Bitwise AND | ||||||||||||
| or $rd, $rs, $rt # R[d] <- R[s] | R[t] | Bitwise OR | ||||||||||||
| nor $rd, $rs, $rt # R[d] <- ~(R[s] | R[t]) | Bitwise NOR | ||||||||||||
| xor $rd, $rs, $rt # R[d] <- R[s] ^ R[t] | Bitwise XOR | ||||||||||||
| what about bitwise negation (complement)? | |||||||||||||
| can use XOR with -1: | |||||||||||||
| addi $8,$0,0x42 # put 2's comp. hex 42 into register 8 | |||||||||||||
| what value is in register 0? | |||||||||||||
| addi $9,$0,-1 # put 2's comp. -1 into register 9 | |||||||||||||
| note sign bit extension for immediate value | |||||||||||||
| xor $10,$8,$9 # xor register 8 and 9, result in 10 | |||||||||||||
| $r8 | 0000 | 0000 | 0000 | 0000 | 0000 | 0000 | 0100 | 0010 | 42 | ||||
| $r9 | 1111 | 1111 | 1111 | 1111 | 1111 | 1111 | 1111 | 1111 | -1 | ||||
| $r10 | 1111 | 1111 | 1111 | 1111 | 1111 | 1111 | 1011 | 1101 | |||||
| example of fewer instruction types --> more instructions | |||||||||||||
| also no NAND (negated AND) | |||||||||||||