Section 2.6 – Logical Operations in LEGv8
1. Why Logical Operations Exist
- Early computers operated on whole words.
- It became clear it was useful to operate on fields of bits within a word or on individual bits.
- Example: examining characters within a word (each character = 8 bits).
- Programming languages and ISAs added logical operations to simplify:
- Packing/unpacking bits.
- Isolating fields.
- Masking bits.
2. Common Logical Operations: C, Java, LEGv8 Mapping

3. Shifts
3.1 Concept
- A shift moves all bits in a doubleword left or right.
- Emptied bits are filled with 0s.
- LEGv8 instructions:
- LSL = Logical Shift Left.
- LSR = Logical Shift Right.
- “Shift left logical provides a bonus benefit. Shifting left by i bits gives the same result as multiplying by 2i, just as shifting a decimal number by i digits is equivalent to multiplying by 10i. For exammmmjmmj7ple, the above
LSL shifts by 4, which gives the same result as multiplying by 2^4 or 16. The first bit pattern above represents 9, and 9 × 16 = 144, the value of the second bit pattern.”
- Shamt stands for shift amount in our previously explained R-format

3.2 Example – Shift Left by 4
- Initial value (decimal 9):
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00001001