Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing instruction fetching #9

Open
sameo opened this issue Mar 19, 2021 · 0 comments
Open

Missing instruction fetching #9

sameo opened this issue Mar 19, 2021 · 0 comments

Comments

@sameo
Copy link
Collaborator

sameo commented Mar 19, 2021

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).

@sameo sameo changed the title The Core crate is missing a fetch implementation Missing instruction fetching Mar 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant