honeylisp/thinks.txt

39 lines
1.8 KiB
Plaintext
Raw Normal View History

2020-08-22 19:05:42 +00:00
GOAL:
live-program an emulator in assembly
- a program is a graph that is flattened into a set of bytestreams.
- first step: make the damn graph.
APPROACH:
- program is split into "ROM" and "RAM" - ROM is code that generally doesn't change while the program is running, RAM is program data
- a program is assembled from snippets that refer to other snippets by name
- a code snippet can be marked as a "loop point", a safe spot to pause and replace a running program's code
- this is also be a good spot to take snapshots of "RAM" which we could roll back to
- this assumes an empty stack + no code references in RAM - perhaps a special typed variable is needed for snippet pointers?
- for now, we will depend on gsplus' socket-based remote debugging capabilities to poke the program into emulated memory
WHAT IS A SNIPPET
- label + block
- block = bytestring, labels (offset into instruction list), fixups (label references)
- can concatenate blocks; snippets are stored "loose" - accessed by absolute JMP or JSR
- other compositional ideas:
- "scopes" - keep labels "alive" only for a short period, for autogenerated loops, if statements, etc
- could also just gensym
(lda 13) ; immediate
(lda (addr #x2000)) ; absolute
(lda (addr #x20)) ; zero-page
(lda (off-x (addr #x20))) ; zp,x
(lda (off-y (addr #x20))) ; zp,y
(lda (off-x@ (addr #x20))) ; (zp,x)
(lda (@off-y (addr #x20))) ; (zp),y
(lda (off-x (addr #x2000))) ; abs,x
(lda (off-y (addr #x2000))) ; abs,y
label = lazy address
maybe treat zero-page and absolute as different types? we will always plan what goes into zero-page. zp has addressing modes abs doesn't.
each opcode is a function that returns a block, usually 0-3 bytes with optionally associated labels + fixups
(fixup is a tuple: local offset, label reference, and whether we're expecting an absolute, zero-page, or relative address)