Make program memory writable
It seems like it’d be straightforward to add opcodes for program memory load/store, and therefore allow the program memory to be writable. That could enable use of a Lisp implementation of the compiler on the microcontroller itself.
One challenge is that program memory is currently necessarily wider than a data word, since each instruction has a full width operand in addition to the opcode. Here are a few rough thoughts of ways to address this:
- Make instructions be clamped to the data width and not have a full width operand. For example, for a 16-bit architecture, it would have an 11 bit operand. This would be sufficient for most instructions, but would require another way to encode larger operands (could be other instructions).
- Add two instructions to write each data word, one to set low bits and one to set high bits (seems kind of clunky)
A parallel question is whether instruction and data memory should be combined. This would get writable program memory using existing instructions, and would be cleaner and simpler, but would result in larger modifications because data and instruction memory would need to be the same width, and would require an extra cycle for the instruction fetch.
The Symbolics 3600 and Ivory actually clamped instructions to half their word width (so 18 and 20 bits respectively) and had two instruction widths: They used a couple 2-bit instructions for immediate load/store, and wider instructions for everything else. I think SPARC did something similar for its most common immediate-load instruction.