5 ms·
Flat assembler: x86 assembler that does multiple passes to optimize machine code
- dang 11y agoWe changed the URL from http://flatassembler.net/docs.php?article=manual#2.3.3 http://flatassembler.net/docs.php?article=manual#2.3.3 to the root page because it looks like this project hasn't had attention on HN before.
- cfcef 11y agoA better link might be http://flatassembler.net/docs.php?article=design http://flatassembler.net/docs.php?article=design which helps explain wtf this is and why anyone should care.
- ers35 11y agoSee also: The newer flat assembler g, a generic assembler not tied to a particular architecture. Download http://flatassembler.net/fasmg.zip http://flatassembler.net/fasmg.zip and read docs/manual.txt. There are examples for 8086, 8052, AVR, and Java Virtual Machine. http://board.flatassembler.net/topic.php?t=17952 http://board.flatassembler.net/topic.php?t=17952
- metafex 11y agoIf I understand this right, fasm_g is the macro-language of fasm with some additions and the ability to output bytes. That's really quite something, is it yet comparable to the current fasm?
- ers35 11y agoSee the board post in my parent comment for a comparison to fasm 1 by the author.
- Jach 11y agoAnother see also: STOKE: https://github.com/StanfordPL/stoke-release https://github.com/StanfordPL/stoke-release "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."
- jwr 11y agoWhat would really get me excited is an assembler that does more intelligent things — automatic register allocation at a minimum. I don't know why in 2015 I still have to manually track which register I'm using for what. This gets particularly problematic with MMX/SSE/AVX registers. I think the x86 assembly world would benefit from learning about features found in DSP assemblers (I'm thinking of TI C6000 tools in particular).
- arthurcolle 11y agoWhat do you mean automatic register allocation? Your example doesn't really make sense to me. 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!
- indutny 11y agoSomething like 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.
- gfody 11y agobasm (borland's assembler, built into delphi and bcb) does this. You just freely reference variables defined outside your 'asm' block and the compiler determines how to map them to registers, stack offsets, etc.
- to3m 11y agoI used CodeWarrior for PowerPC a few years ago and this did something similar. You did have to declare register variables with `register', though. (Being RISC, all instructions took register operands exclusively, so the distinction between memory and register was fairly important.) 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.
- majke 11y agoThe introduction to SSE is not bad http://flatassembler.net/docs.php?article=manual#2.1.15 http://flatassembler.net/docs.php?article=manual#2.1.15
- gravypod 11y agoI've been looking for something like the FAT12 bootloader from the examples section for some time. Not really related to the main post, but still a big help!
- Grom_PE 11y agoThe most interesting points of flat assembler are elegant syntax, "Same source - same output" philosophy, and a very powerful macro system that consists of preprocessing and assembling stage; the fasm preprocessor has been shown to be turing-complete [0]. 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 http://board.flatassembler.net/topic.php?t=6624 [1]: http://board.flatassembler.net/topic.php?t=8876 http://board.flatassembler.net/topic.php?t=8876 [2]: http://board.flatassembler.net/topic.php?t=8632 http://board.flatassembler.net/topic.php?t=8632 [3]: http://board.flatassembler.net/topic.php?t=8951 http://board.flatassembler.net/topic.php?t=8951
- wruza 11y agoThe word "optimize" is overused here. Fasm makes multiple passes because it allows forward references, and rich macro system makes it hard to guess everything in 1-2 passes (it also removes lot of formalism from user). What is actually optimized: jmp width.