DDCA Ch6 - Part 6: Logical Instructions

DDCA Ch6 - Part 6: Logical Instructions

Logical and Shift Instructions Overview

In this section, the video introduces logical and shift instructions in RISC-V assembly language, essential for translating high-level programming constructs into assembly code.

Logical Instructions

  • Three logical instructions in RISC-V: AND, OR, XOR perform bitwise operations on 32-bit sources to produce a 32-bit result.
  • Use cases: AND for masking bits, OR for combining bits, XOR for inverting bits.
  • Example: Demonstrates logical operations with two sources (S1 and S2), showcasing outcomes of AND, OR, and XOR operations.

Immediate Values with Logical Instructions

  • Immediate values are 12 bits long and can be positive or negative; sign extension is applied.
  • Example: Illustrates logical operations with immediate values using AND and OR operations.

Shift Instructions

  • Three types of shift instructions in RISC-V: logical left shift, logical right shift, arithmetic right shift.
  • Difference between logical and arithmetic shifts lies in filling upper bits with zeros or sign bit copies respectively.