Skip to content

Implement ALU and memory instructions #7

@kevinamccorvon

Description

@kevinamccorvon

Once the execution loop works need to implement the instruction handlers for arithmetic (ADD, SUB, ADDI, MUL, DIV, DIVU, REM, REMU, LUI, AUIPC), logic (AND, ANDI, OR, ORI, XOR, XORI, SLL, SLLI, SRL, SRLI, SRA, SRAI), comparison (SLT, SLTU, SLTI, SLTIU), and memory (loads LB/LH/LW/LBU/LHU, stores SB/SH/SW).
Most are straightforward like ADD is just rd = rs1 + rs2 but watch out for register x0 always reading as 0 and ignoring writes, division by zero should set rd to -1 (or 0 for unsigned, check spec), shifts mask amount to 5 bits (0-31), loads/stores need bounds and alignment checking, sign extension vs zero extension for loads. Test overflow/underflow, edge cases like shift by 0 or 31, signed vs unsigned comparisons. Needs execution loop from #6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions