Skip to content

Register File

Carson Bush edited this page Apr 4, 2024 · 10 revisions

Register Reference

Name Conventional Usage Notes
r0 Routine Argument 1 Caller Saved
r1 Routine Argument 2 Caller Saved
r2 Routine Argument 3 Caller Saved
r3 Routine Argument 4 Caller Saved
r4 Upper Accumulator Callee Saved
r5 Accumulator Callee Saved
r6 General Purpose Callee Saved
r7 General Purpose Callee Saved
r8 General Purpose Callee Saved
r9 General Purpose Caller Saved
ra Memory Access Upper Caller Saved
rb Memory Access Lower Caller Saved
rih Interrupt Address Upper Location of interrupt routine
ril Interrupt Address Lower Location of interrupt routine
rsh Stack Pointer Upper Tracked with push/pop instructions
rsl Stack Pointer Lower Tracked with push/pop instructions
rfl Condition codes Cannot be directly used, affected by other operations

General Purpose Registers

  • 8-bit word size
  • Any of them can be used together with adjacent registers for address operations
  • Can be used for calculations without additional side effects
  • 5 registers (r4 through r8) available under all circumstances

Special Registers

Device Select

  • Used for memory operations, can be used as a general register when not accessing memory
    • TODO: only by convention or a hard requirement?
  • When memory operations occur, this can select the device/memory bank
  • Effectively allows for 256 different I/O devices with 16-bit address spaces

Memory Access

  • Conventionally stores any 16-bit address in ra and rb

Interrupt Address

  • Can be used as a general register if interrupts aren't enabled
  • rih and ril make up a 16-bit address pointing to the desired interrupt routine

Stack Pointer Registers

  • rsh and rsl make up a 16-bit address pointing to the current descending stack address.
  • Modified indirectly with push and pop instructions
  • Can optionally be used as a general purpose register with severe side effects

Flag register

  • Stores various flags
  • Cannot be used as a general register under any circumstance
Bit Name Description Affected By
0 c Carry flag, final carry output result cp, ALU functions
1 z Zero flag, indicates result of an operation is zero cp
2 s Sign flag, MSB of the result cp, ALU functions
3 p Parity flag, LSB of the result cp, ALU functions
4 o Overflow flag, indicates whether operation overflowed cp, ALU functions
5
6 i Interrupt enable ei, di
7 w CPU in wait mode (paused execution) wait

Clone this wiki locally