Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- == boolean logic ==
- definition rougly equates to logic involving things that can be one of two states (true or false, 1 or 0)
- == Basic boolean operations ==
- === NOT ===
- negates a given input
- Truth Table
- _______
- | I | O |
- |---|---|
- | 0 | 1 |
- |---|---|
- | 1 | 0 |
- |___|___|
- The C language equivalent operator should be ! (not 100% sure).
- === OR ===
- takes two inputs and outputs 1 if AT LEAST ONE input is 1, or 0 if neither is.
- The OR bitwise operator can be used to force a sequence of bits into their on (1) state.
- In MIPS, you will occasionally see the OR instructiong being used to initialize a register to an immediate value.
- The C language equivalent operator is |
- Truth Table
- _____________
- | I1 | I2 | O |
- |----|----|---|
- | 0 | 0 | 0 |
- |----|----|---|
- | 1 | 0 | 1 |
- |----|----|---|
- | 0 | 1 | 1 |
- |----|----|---|
- | 1 | 1 | 1 |
- |____|____|___|
- === AND ===
- Takes two inputs and outputs 1 if BOTH inputs are 1, or 0 if neither is.
- The AND bitwise operator can be used to capture a specific set of bits, ignoring the state of the rest.
- The C language equivalent operator is &
- Truth Table
- _____________
- | I1 | I2 | O |
- |----|----|---|
- | 0 | 0 | 0 |
- |----|----|---|
- | 1 | 0 | 0 |
- |----|----|---|
- | 0 | 1 | 0 |
- |----|----|---|
- | 1 | 1 | 1 |
- |____|____|___|
- === XOR ===
- Takes two inputs and outputs 1 if the inputs do not match, or 0 if they match
- The XOR bitwise operator can be used to flip the state of a bit or sequence of bits
- The C language equivalent operator is ^
- Truth Table
- _____________
- | I1 | I2 | O |
- |----|----|---|
- | 0 | 0 | 0 |
- |----|----|---|
- | 1 | 0 | 1 |
- |----|----|---|
- | 0 | 1 | 1 |
- |----|----|---|
- | 1 | 1 | 0 |
- |____|____|___|
- == Bitwise Operations ==
- Bitwise Operations perform multiple boolean operations within one instruction. This is done by comparing the bits
- on the same position. For example, consider the simple example of 0x05 OR 0x0C.
- 5 = 0 1 0 1
- C = 1 1 0 0
- we start by performing a boolean OR with the rightmost bits of the two numbers (1, 0), giving us an output of 1
- ? = ? ? ? 1
- Then we perform the same operation with the next columns as such:
- ? = ? ? 0 1 (0, 0 is 0)
- ? = ? 1 0 1 (1, 1 is 1)
- E = 1 1 0 1 (0, 1 is 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement