Logical Operations for PPC ASM
For ASM Coders who already know the basics.
Chapter 1: Fundamentals
Logical Operation Instructions are Instructions that compute a result using Binary/Bit operation. We need to go over some basic vocab first before diving into actual Instructions.
The term "high" or "true" refers to when a Bit has a value of 1.
The term "low" or "false" refers to when a Bit has a value of 0.
The far left-hand bit of any value in a register is known as the "Sign Bit" or the "Most Significant Bit" (aka MSB). The far right-hand bit of any value in a register is known as the "Least Significant Bit" (aka LSB).
Each Bit has an assigned number that we use for easy reference, so other coders can know which bit within a register we are talking about. The MSB is bit 0. The LSB is bit 31. The bit numbers ascend as you move from left to right within a register.
The far left hand bit (first bit) is bit 0. Next bit is bit 1. Then bit 2. All the way until you hit the LSB which is bit 31. Since bit numbering ascends from left to right, this is called "Big Endian" (there's more to the term Big Endian, we're just talking about the bit numbering system).
Logical Operations are done on a bit-by-bit basis! It's important to understand this.
Let's say we have a value in r3 and we preform a logical operation instruction with the value in r27. Bit 0 of r3 will have a logical operation done in reference to bit 0 of r27. Bit 1 of r3 will have an operation done in reference to bit 1 of r27. Bit 2 of r3 will have a logical operation done in reference to bit 3 of r27, and so on and so on.
There are a maximum of 6 types of Logical Operations, they are...
The easiest way to understand each Logical Operation is with its corresponding truth table. A truth table is a table/list of the results of all 4 combinations of possible bit operations for a Logical Operation. Each Logical Operation has a unique truth table. They are actually not too hard to remember. You simply need to remember or, and, & xor. After that the other 3 truth tables (nor, nand, xnor respectively) are the just the the flipped versions of the original 3.
For ASM Coders who already know the basics.
Chapter 1: Fundamentals
Logical Operation Instructions are Instructions that compute a result using Binary/Bit operation. We need to go over some basic vocab first before diving into actual Instructions.
The term "high" or "true" refers to when a Bit has a value of 1.
The term "low" or "false" refers to when a Bit has a value of 0.
The far left-hand bit of any value in a register is known as the "Sign Bit" or the "Most Significant Bit" (aka MSB). The far right-hand bit of any value in a register is known as the "Least Significant Bit" (aka LSB).
Each Bit has an assigned number that we use for easy reference, so other coders can know which bit within a register we are talking about. The MSB is bit 0. The LSB is bit 31. The bit numbers ascend as you move from left to right within a register.
The far left hand bit (first bit) is bit 0. Next bit is bit 1. Then bit 2. All the way until you hit the LSB which is bit 31. Since bit numbering ascends from left to right, this is called "Big Endian" (there's more to the term Big Endian, we're just talking about the bit numbering system).
Logical Operations are done on a bit-by-bit basis! It's important to understand this.
Let's say we have a value in r3 and we preform a logical operation instruction with the value in r27. Bit 0 of r3 will have a logical operation done in reference to bit 0 of r27. Bit 1 of r3 will have an operation done in reference to bit 1 of r27. Bit 2 of r3 will have a logical operation done in reference to bit 3 of r27, and so on and so on.
There are a maximum of 6 types of Logical Operations, they are...
- Logical OR
- Logical AND
- Logical XOR
- Logical NOR (also known as Logical Not OR)
- Logical NAND (also known as Logical Not AND)
- Logical XNOR (also known as Logical EQV or as Logical Not XOR)
The easiest way to understand each Logical Operation is with its corresponding truth table. A truth table is a table/list of the results of all 4 combinations of possible bit operations for a Logical Operation. Each Logical Operation has a unique truth table. They are actually not too hard to remember. You simply need to remember or, and, & xor. After that the other 3 truth tables (nor, nand, xnor respectively) are the just the the flipped versions of the original 3.