(docs) readme - Add intro + re-arrange, to clarify relationship between Cardiograph and its constituent parts

This commit is contained in:
n loewen 2023-08-29 09:26:09 -04:00
parent dee5b4afd4
commit 144ae8de6c
1 changed files with 57 additions and 48 deletions

105
readme.md
View File

@ -1,13 +1,21 @@
# Cardiograph Mark I — simulator for an imaginary computer
## Dependencies
Cardiograph is an imaginary computer. It has three main components:
1. the CPU, *Card* (short for 'Completely Analogue Risc Machine')
2. an input-output processor, *IO*
3. a display, *Graph*
## Simulator
### Dependencies
- Node.js
- readline-sync
## Run
### Use
### Assemble
#### Assemble
Hex output:
```./run-assembler run source_code.asm```
@ -18,7 +26,7 @@ Binary output:
Verbose debugging output (hex):
```./run-assembler debug source_code.asm```
### Assemble and run
#### Assemble and run
With animated display of screen memory:
```./run-cpu run source_code.asm```
@ -33,7 +41,9 @@ With single stepping + verbose debugging output:
```./run-cpu stepdebug source_code.asm```
## Registers and Flags
## CPU
### Registers and Flags
- `A` - accumulator
- `IP` - instruction pointer (aka program counter)
@ -46,9 +56,9 @@ With single stepping + verbose debugging output:
- (bitwise, `0000 = ONZC`)
## Instruction set
### Instruction set
### Operations
#### Operations
```
Hex Mnem. Operand Effect
@ -75,7 +85,7 @@ Hex Mnem. Operand Effect
one byte for the opcode, one for the operand
### Effects on memory, flags, registers
#### Effects on memory, flags, registers
```
op mem flags IP
@ -102,50 +112,13 @@ FTG r ONZC +2
FHP r ONZC +2/+4
```
## CPU start-up
### Start-up
When starting up, the CPU executes a `JMP $FF`.
Put differently: it starts executing instructions at the address contained in `$FF`.
## Cardiograph memory map
- `00-19` - display (5x5)
- `1A ` - pointer to display memory
- `1B ` - keypad: value of latest key pressed
- `1C ` - reserved for future use (bank switching flag)
- `1D ` - initial IP
- `1D-FE` - free
- `FF ` - ROM (unwriteable) pointer to initial IP (not yet implemented)
## Peripherals
### Keypad
The value of the latest keypress on a hex keypad is stored at `$1B`.
The keypad uses the same layout as the COSMAC VIP (and CHIP-8). The CPU simulator maps those keys onto a Qwerty set:
```
1 2 3 C 1 2 3 4
4 5 6 D Q W E R
7 8 9 E A S D F
A 0 B F Z X C V
hex pad simulator
```
The arrow keys are also mapped onto the hex keypad:
```
5 ↑
7 8 9 ← ↓ →
hex pad simulator
```
## Assembly language
### Assembly language
ADD $01 ; comments follow a `;`
@ -172,4 +145,40 @@ hex pad simulator
; where the current line will be stored after assembly
- Hexadecimal numbers are preceded by a `$`
- Whitespace is ignored
- Whitespace is ignored
## Cardiograph memory map
- `00-19` - display (5x5)
- `1A ` - pointer to display memory
- `1B ` - keypad: value of latest key pressed
- `1C ` - reserved for future use (bank switching flag)
- `1D ` - initial IP
- `1D-FE` - free
- `FF ` - ROM (unwriteable) pointer to initial IP (not yet implemented)
## Cardiograph peripherals
### Keypad
The value of the latest keypress on a hex keypad is stored at `$1B`.
The keypad uses the same layout as the COSMAC VIP (and CHIP-8). The CPU simulator maps those keys onto a Qwerty set:
```
1 2 3 C 1 2 3 4
4 5 6 D Q W E R
7 8 9 E A S D F
A 0 B F Z X C V
hex pad simulator
```
The arrow keys are also mapped onto the hex keypad:
```
5 ↑
7 8 9 ← ↓ →
hex pad simulator
```