proj-oot-old-ootAssemblyThoughtsOld

old MEDIUM instructionEncodings:

TODO: consider having only 1024 regs and having the following encoding (meta bits TBD), and having a pluggable interpreter with an EXEC instruction or somesuch to load plugin(s) 2 format bits, 1 meta addr mode bit, 4 meta bits, 2 instruction addr mode bits, 10 instruction operand bits, 3 x (4 addr mode bits + 11 operand bits)

TODO: consider having only 256 regs and: 2 format bits + 1 implementation-dependent bit + 1 flag bit + 5 x (4 addr mode bits + 8 data bits)

TODO: consider having only 512 regs and: 2 format bits + 1 implementation-dependent bit + 1 flag bit + 2 meta addr mode bits + 6 meta bits + 4 x (4 addr mode bits + 9 data bits)

TODO: consider having only 256 regs and: 2 format bits + 2 implementation-dependent bits + 2 meta tower bits (here, lower, higher, infinity) + 10 custom bits + 4 x (4 addr mode bits + 8 data bits)

(2 addr mode bits + 12 operand bits + 2 format bits) + 3 x (12 operand bits + 4 addr mode bits)

---

addr modes: 0000: immediate constant 0001: constant table 0010: register direct 0011: register indirect

todo: i'm thinking of combining immediate constant/constant table and just splitting their space, eg 0-2047 is immediate, 2048-4095 is constant table. Then making 'indirect with read post-increment, write pre-decrement (=stack addr, downwards)' one of the previous four todo: i think i'm going to get rid of the following 4 and have this bit be a 'meta bit', instead, use to-be-determined. See ootAssemblyNotes12 for ideas about the meta.

0100: indirect-offset 0101: indirect with read post-increment, write pre-decrement (=stack addr, downwards) 0110: indirect with read post-decrement, write pre-increment (=stack addr, upwards) 0111: subexpression

todo: or mb

indirect with read post-decrement, write pre-increment: This is like 'register indirect', except that if this address mode is found in the second or third operand ('read'), the value at the address in the operand is incremented after the effective address is determined (but before the rest of the instruction executes), and if this address modeis found in the first operand ('write'), the value at the address in the operand is incremented before the effective address is determined. Note that whether the effective address is actually read to or written from is irrelevant; it only matters which of the 3 argument operands we are in. Note: This addressing mode provides the equivalent of POP and PUSH commands when applied to a stack pointer with an upward-growing stack, and also can be used for scanning an array in a loop.

subexpression: this indicates that the given subexpression must be computed and then put in place of this operand. The operand contains a PC-relative offset to the code that computes the subexpression. If the offset is '0', this has a special meaning, namely to return from the current subexpression with a result. That is, the result of a subexpression is indicated by an instruction with a '0' operand in subexpression addressing mode; when this is encountered, the value that would be written to the effective address of that operand is instead returned as the value of the subexpression (or, if nothing is written to that effective address by that instruction, then 0 is returned).

---

todo: ?frame pointer?

todo, mb:

todo, mb:

---

Metaprogramming opcodes range from 0 to 7. Core opcodes range from 8 to 255. 'Custom' instruction opcodes range from 256 to 2047. Instruction opcodes range from 256 to 2047.