Skip to content
Lesson 7 of 10

Step 1 of 5 · Reading · ~2 min

Read

Execution

Fetch-Decode-Execute Loop

Putting it together:

python

The loop is straightforward; the per-instruction logic is the real work. Get one instruction right; the rest are templates.

Edge cases:

  • Misaligned pc (set jal to odd address): exception.
  • Memory bounds: catch Python IndexError; raise as exception.
  • Division by zero (M extension): defined behavior (returns -1 for signed div).

System instructions:

  • ECALL: software interrupt. In our toy, dispatch syscall by a7.
  • EBREAK: debugger trap. Pause for inspection.
  • FENCE: memory ordering. No-op for single-core.
Up nextCalling ConventionExecution

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…