So people doing something trivial thinks they're easy (like this example), people trying to do a bit more think they're really hard, and people doing an entire assembler think they're easy again.
So people doing something trivial thinks they're easy (like this example), people trying to do a bit more think they're really hard, and people doing an entire assembler think they're easy again.
https://github.com/oracle/graal/tree/master/compiler/src/org...
Then take a random instruction
https://github.com/oracle/graal/blob/master/compiler/src/org...
See how it has common methods used by other instructions simdPrefix and emitModRM? Those are the abstractions.
Here's a concrete example from an industrial assembler.
Almost every simple instruction boils down this helper method which is parameterised by a bunch of flags and can then deal with all of them.
https://github.com/oracle/graal/blob/f3a3576493f87abdea1045d...
Even that looks complicated! But writing this per instruction (the simple case) would be insanely complicated.