Skip to content

Missing instruction fetching #9

@sameo

Description

@sameo

The Core crate decodes and executes instructions, but does not fetch instructions from memory.

In order to fetch instructions, a core needs to know where the code is actually loaded in memory.
This could be overwritten by the still missing executable format, but I propose that the default code section starts at 0x100 in memory. Unless overwritten, $RIP should be initially set to that value, and this is where the first instruction will live (a.k.a. as the reset vector).

The fetch-decode-execute loop should then be as simple as:

  1. Read 32 bits from $RIP, that's the next instruction to decode and execute
  2. Increase RIP by 4 (next instruction, 32 bits further)
  3. Decode the instruction
  4. Execute the instruction
  5. goto step 1

Note that the instruction executions step (step 4) could modify RIP as well (branches and jumps).

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