Purpose: Understand the architecture components and their roles in data processing.
Basics: Includes control unit, arithmetic logic unit (ALU), and register file.
64-bit mode features:
32 integer registers (64-bit each)
32 floating-point registers (64-bit each)
Standard register names (e.g., x0 for zero, x1 for return address)
Registers identified by both index (x0, x1, ...) and ABI names (sp, a0, a1, ...).
Types of Instructions:
Integer Instructions: Add, subtract, multiply, etc.
Logic Instructions: AND, OR, XOR operations.
Branch Instructions: beq (branch if equal), bne (branch if not equal).
Jump Instructions: jal (jump and link), jalr (jump and link register).
Memory Instructions: load and store operations.
Floating Point Instructions: Add, subtract, etc. specifically for floating-point numbers.
Instruction Formats:
Register Type (R-type): Operands are registers.
Immediate Type (I-type): One operand is an immediate integer.
Store Type (S-type): Store instructions for memory.
Branch Type (B-type): For branching.
Upper Type (U-type): For setting upper immediate values.
Jump Type (J-type): For jump with a larger immediate.
Instruction pipeline stages:
Instruction fetch (IF)
Instruction decode (ID)
Execute (EXE)
Memory access (MEM)
Write back (WB)
Defines how registers are used for standard interoperability between code.
Each register has a designated purpose (argument registers, saved registers, etc.).
Example register usage for functions:
a0-a7 for arguments
s0-s11 for saved values
ABI helps manage memory layout for arguments and function calls.
Executable Sections:
.text: Code section (CPU instructions)
.data: Initialized global variables.
.bss: Uninitialized global variables.
.rodata: Read-only data.
Stack Memory Management:
Stack grows downwards from high to low memory.
Stack pointer must be aligned to 16 bytes.
Frame pointers mark the base of function stack frames.
Endianness determines storage and access format of multi-byte data:
Little Endian: LSB first (common in RISC-V).
Big Endian: MSB first.
Impacts how data is stored and accessed between architectures.
Defines binary representation of floating-point numbers, including sign, exponent, and fraction.
Example Conversion:
Determine sign bit (0 for positive, 1 for negative).
Use an exponent with a bias for representation.
Handle normalization to fit format requirements.
In binary: addition, subtraction, multiplication, and division.
Use of two's complement for negative numbers.
Focus on efficient algorithms for bitwise operations integrating carry and overflow checks.
Simplifies certain complex assembly tasks into manageable commands for programmers.
Common examples include jumps and store functions that leverage hardware capabilities.
Importance of understanding ABI around pseudo-instructions for effective assembly coding.
Understanding computer architecture is crucial for creating efficient programs and utilizing the underlying hardware effectively. RISC-V's design facilitates simple and efficient operations while adhering to a logical instruction set.