LEGv8 Machine Language & Instruction Formats (Section 2.5)
1. Humans vs. Computers: Instructions
- Humans write assembly language instructions (e.g.,
ADD X9, X20, X21).
- Computers store and execute machine language instructions — patterns of high/low electronic signals, represented as numbers.
- Each part of an instruction is a number; placing numbers side by side forms the machine instruction.
- The 32 LEGv8 registers are numbered X0–X31.
2. Assembly → Machine Instruction Example
Assembly instruction:
ADD X9, X20, X21
Machine instruction fields (decimal):
- Opcode (ADD): 1112
- Second source operand: X21 (21)
- Unused field: 0
- First source operand: X20 (20)
- Destination register: X9 (9)
Machine instruction fields (binary):
- 10001011000 (opcode, 11 bits)
- 10101 (X21, 5 bits)