cardiograph-computer/readme.md

85 lines
2.5 KiB
Markdown

# Paper computer simulator experiment
## TODO
- [ ] Document current state of affairs (how to run it etc)
Computer:
- [ ] Implement carry flag on SUB
- [ ] Move screen memory down,
and add a pointer to screen mem at $00
to make the screen relocatable
Misc:
- [ ] Write some more complex test programs
- [ ] Display (hex) numbers
- [ ] Do a proper binary version... (or lose the typed arrays?)
- [ ] Extract debugging to its own module
## Instruction set
0 END
1 STO lit# ; store ... mem[lit#] <- A
2 STO addr ; store ... mem[mem[addr]] <- A
3 LDA lit# ; load ... A <- lit#
4 LDA addr ; load ... A <- mem[addr]
5 ADD lit# ; add ... A <- A + lit# ... and un/set carry flag
6 ADD addr ; add ... A <- A + mem[addr] ... and un/set carry flag
7 SUB lit# ; sub ... A <- A - lit# ... and un/set carry flag
8 SUB addr ; sub ... A <- A - mem[addr] ... and un/set carry flag
9 HOP lit# ; hop ... skip next instruction if A == lit# ... when true: IP <- PC + 2
A HOP addr ; hop ... skip next instruction if A == addr ... when true: IP <- PC + 2
B JMP lit# ; jump ... IP <- lit#
C JMP addr ; jump ... IP <- addr
D CCF ———— ; clear Carry Flag ... CF = 0
E CHP ———— ; carry hop ... skip next instruction if Carry Flag is set ... when true: IP <- PC + 2
F
- instructions are two bytes long:
one byte for the opcode, one for the argument
### Nice features that didn't fit
- hop `IF<` and hop `IF>`
- `MUL` and `DIV`
- rotates and shifts
## Registers and Flags
- `A` - accumulator
- `IP` - instruction pointer (aka program counter)
- `CF` - carry flag
## Memory map / Peripherals
- `00-0F` - 4x4 display
- `10-1F` - keypad? (details TBD)
- `20 ` - initial value for IP
- `20-FF` - free
### Maybe someday
- timer (for a version in software/electronic-hardware)
## Assembly language
ADD $01 ; comments follow a `;`
ADD $FF ; this is direct addressing
ADD ($CC) ; this is indirect addressing
END ; END, CFC, and CHP don't require arguments
; (a default value of 0 will be used as their operand)
@subroutine ; create a label
ADD $01 ; (it must be on the line before the code it names)
ADD $02
JMP @subroutine ; use a label as an argument
; the label will be replaced with
; the address of the label
- Hexadecimal numbers are preceded by a `$`
- Whitespace is ignored