v80
v80 copied to clipboard
Reduce heap usage
Both in general, and specifically when assembling v80, which uses roughly 25KB of heap space. This would make assembling v80 a major squeeze on even a 48K system, if even possible. v80 is 8KB + 256B buffers, + 256B stack. v80's heap usage whilst assembling itself needs to be reduced to at least 20KB. There are general strategies, such as just using less labels, but this issue will focus on code changes that can help.
- [x] Do not store the first char of symbols (consts & labels). Since there's specific routines for accessing constants and labels, we can assume the first char and reconstruct it where necessary. Saves 1 byte for every symbol
- [ ] When a deferred expression is a relative jump, store the virtual program-counter in the expr-byte code so that it doesn't need to be included in the record of every deferred expression
- [ ] Store the parameter & rel-flag byte in the first reserved byte in the code-segment, rather than in the deferred record. Saves 1 byte every record
- [ ] Store numbers that fit into 1 byte in a special 1-byte number token. This complicates the parser / evaluator a little more, but is an easy way to save bytes