Re:Local Register Allocator for 8086
by userbinator on Monday May 10, 2021 @09:35PM
(#27113129)
I really like the fact that the output of this more closely approximates what a skilled Asm programmer (human) would write, than the usual compiler output. The algorithm also resembles more how the human would think --- where results should go, where inputs can come from, and what instructions can "fit" within those constraints. Contrary to what some compiler textbooks might imply, humans (or at least this one) don't think about graph colouring when they're writing Asm.
To load a value from memory we need the memory address in one of 3 suitable registers: bx, si, di.
You can use bp too, and for local variables it's the best one, since it defaults to using the stack segment. Adding support for non-movs with memory operands is probably the last step to this algorithm, and with that, its output could fool the majority of people into believing a human wrote the code instead of a compiler.
To load a value from memory we need the memory address in one of 3 suitable registers: bx, si, di.
You can use bp too, and for local variables it's the best one, since it defaults to using the stack segment. Adding support for non-movs with memory operands is probably the last step to this algorithm, and with that, its output could fool the majority of people into believing a human wrote the code instead of a compiler.