code_coloring
Differences
This shows you the differences between two versions of the page.
| code_coloring [2026/01/31 08:41] – created appledog | code_coloring [2026/01/31 08:52] (current) – removed appledog | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | = Code Coloring | ||
| - | Welcome to my article on Code Coloring, the totally new thing I, Appledog, invented on January 31st, 2006 at 4:35pm while chatting on discord. | ||
| - | == How did you invent such a wonderful thing? | ||
| - | So basically I was thinking about how to optimize the hot path and cam.k1 said, "How does the 65816 get away with only having 3 registers (A,X,Y) while it's competitor the m68k has 16" | ||
| - | |||
| - | In the ensuing discussion, I said you don't need that many registers. Then when hypothesizing how many you need, I came to the idea of 8 registers. Then without even realizing what I said, I said | ||
| - | |||
| - | < | ||
| - | Appledog — 4:23 PM | ||
| - | You don't really need 16 registers | ||
| - | Actually it would be a lot simpler to have standard registers.. like an ADD instruction automatically adds A and B and puts the result in C | ||
| - | In that sense, I am thinking, instead of registers, you could design a meta-CPU with meta execution-contexts. | ||
| - | Such as ABXY or ABCXYZ; just 4 or 6 contexts, maybe with a stack and flags (8 total).. Hmm! | ||
| - | |||
| - | calc84maniac — 4:28 PM | ||
| - | simpler CPU design for sure, but compiler designers will hate it | ||
| - | |||
| - | Appledog — 4:28 PM | ||
| - | And operations require values to be in certain registers. Ok so given that variable assignments are faster than array accesses you could probably set up a mini cache or stack with actual variables. | ||
| - | Well the thing is, I think programmers have gotten a bit lazy | ||
| - | Everyone expects certain kinds of architecture | ||
| - | If you could guarantee that operations used certain registers you could eliminate at least two IFS and a memory op per cycle in an emulator | ||
| - | You'd double the speed | ||
| - | So you have four execution contexts | ||
| - | And four versions of LOAD for each register-- thats 32 LOADs, 32 STOREs, 32 ADDs, 32 SUB, etc | ||
| - | Its a lot of opcodes but it would be way faster. All you are really doing is unrolling the register encoding on an opcode | ||
| - | It actually might make things clerarer and easier to pipeline because you can execute code in different contexts out of order, with guaranteed non-interference | ||
| - | Like automatically enabling the cpu to multithread your code | ||
| - | omg did you hear what I just said | ||
| - | |||
| - | Appledog — 4:36 PM | ||
| - | This is amazing. Its code coloring! | ||
| - | I invented code coloring! | ||
| - | </ | ||
code_coloring.1769848873.txt.gz · Last modified: by appledog
