5 ms·
What 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 stil
by jwr 11y ago
What 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.
- deleted 11y ago[deleted]
- emily-c 11y agofasm has pretty powerful macros that could do something like this though at that point why are you using an assembler directly?
- claystu 11y agoYour wish has been granted. It's called C and it's been around since the 70's.
- jwr 11y agoI will take an educated guess that none of the responders to my comment (and I'll just post this one reply to all) have written significant amounts of assembly code, especially using MMX/SSE/AVX, and so will respectfully disagree with all of the responses. 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.
- claystu 11y agoThis is a serious question: what's the point of programming in assembly if you don't want to control the registers? And what do you do if the assembler does a poor job of register allocation? If you hand optimize it, you're back in normal assembly; if you ignore it, you might as well not check in the first place. 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?
- Marat_Dukhan 11y agoThere is an assembler that does more intelligent things - https://github.com/Maratyszcza/PeachPy https://github.com/Maratyszcza/PeachPy