Flat assembler: x86 assembler that does multiple passes to optimize machine code
flatassembler.net
flatassembler.net
"STOKE is a stochastic optimizer for the x86_64 instruction set. STOKE uses random search to explore the extremely high-dimensional space of all possible program transformations. Although any one random transformation is unlikely to produce a code sequence that is both correct and an improvement over the original, the repeated application of millions of transformations is sufficient to produce novel and non-obvious code sequences that have been shown to outperform the code produced by general-purpose and domain-specific compilers, and in some cases expert hand-written code."
That's really quite something, is it yet comparable to the current fasm?
In 2008 I've played with it, creating macros that patch a binary file (and used it to extend a closed-source Windows program [1]), made PE format from scratch [2], a simple PE encryptor [3].
[0]: http://board.flatassembler.net/topic.php?t=6624
[1]: http://board.flatassembler.net/topic.php?t=8876
Briefly:
* writing assembly in C is an exercise in frustration, just try to see anything past the syntax, same goes for intrinsics, with the added bonus of having to check whether the code you got is actually what you wanted, * no, you do not want to manually keep track of all of your 32 AVX-512 registers, trust me (for x86+SSE I used printed register allocation tables to help me track of what is where at which stage), heck, even on a measly ARM Cortex-M managing your R0-R12 (and not all instructions operate on all of them) can get annoying. The idea that you can keep registers in your head stems from the days when we had AX-DX to work with.
"Assembly" doesn't have to mean doing everything manually (and macros, yay!), really. There is a middle ground, where you get a reasonably intelligent assembler which does a lot of the manual grudge work for you. There are also more intelligent assemblers which, for example, take your linear assembly and convert it into VLIW, allocating processing units. Or reorder instructions around branches.
Assembly language should be thought of as a spectrum of tools.
Once you sacrifice the registers, assembly just becomes a non-portable programming language without any libraries. Unless you build it out with macros and capitalize on it being a programmable programming language, but then why not go with Forth or some kind of Lisp?
What does no-register assembly gain you that higher level languages don't already offer?
mov 5, eax
mov eax, ebx
It seems pretty prerequisite to know what you're doing with the registers themselves. I have only taken a basic systems class that taught y86 so knowledge of building anything production worthy in assembly is nil. Just caught my eye and thought I'd ask!
mov 5, a
mov a, b
Where `a` gets `eax`, and `b` gets `ebx` during register allocation, and the lifetime analysis of each variable makes sure that all alive vars have register.
This worked really well - the compiler would sort out spills and reloads at the start and end of asm blocks, so you could generally just write one or two instructions per asm block, then have an assert, then on to the next asm block. Made debugging amazingly easy, and I never had to care about the ABI.
For day-to-day programming it was certainly streets ahead of the nonsense gcc foists on you.
Not really related to the main post, but still a big help!