Comment by Grom_PE
17 days ago
flat assembler g (fasmg) does this. It has a powerful macro language, in which, among other architectures and formats, it implements x86 and ELF/PE/macho and is able to assemble itself.
I like to use it for scripting for turning binary formats to text and vice-versa.
It's also possible to use stock flat assembler (non-g) for this, to some extent. I've done it before here: https://github.com/Rohansi/FPCompo11/blob/master/Assembler/i...
https://github.com/tgrysztar/fasmg