A Proper x86 Assembler in Haskell Using the Escardó-Oliva Functional
5 comments
·January 20, 2025netr0ute
This is basically irrelevant now that better ISAs like RISC-V have a fixed instruction length (2 or 4 bytes) so the fancy algorithm here isn't necessary.
lifthrasiir
That fancy algorithm is relevant to RISC-V (and in fact, most fixed-length ISAs) because loading an immediate into a register needs one or two instructions depending on the immediate; you surely want to elide a redundant LUI instruction if you can. Of course such redundant instructions don't harm by itself, but that equally applies to x86 as the algorithm is an optimization.
Coolbeanstoo
As a result of RISC-V existing, all x86 processors have ceased to exist or be produced.
nicebyte
ARM would have been a better example because the amount of people that care about RISC-V is a rounding error compared to x86 or ARM.
One pass, but.. I'm willing to bet there is some transitional internal state which had to be looped over to do this, subsuming the "pass" inside lazy eval. You have to know the indeterminate "where" to jump to, which depends on subsequent state. So you preserve execution state, calculate on, and return at end to fill in the gaps.