3 ms·
I've done a similar thing in Scheme to learn Intel assembly (it only supports a small subset of it, and produces standard .as output files instead of byte code,
by pflanze 11y ago
I've done a similar thing in Scheme to learn Intel assembly (it only supports a small subset of it, and produces standard .as output files instead of byte code, and I have not used it for anything in production so far):
https://github.com/pflanze/hasm https://github.com/pflanze/hasm
I implemented a number of higher level features for structured programming. Example input file: https://github.com/pflanze/hasm/blob/master/examples/fact.scm https://github.com/pflanze/hasm/blob/master/examples/fact.sc...
It doesn't use Scheme macros but expands assembly macros using custom code (because the bottom layer isn't Scheme anyway, just S-expressions, and so that I could let the macro expanders access their context).
Of course the difficult part would be to grow the higher level features in a way that they are safe, and I'm not sure how useful they really are when allocating registers manually. Once you build in a register allocator, you'd probably call it a compiler.