5 ms·
The major breakthrough I had in being able to comprehend assembly code was when I learned to look at it in basic blocks, rather than as a straight line. I don't
by tptacek 6y ago
The major breakthrough I had in being able to comprehend assembly code was when I learned to look at it in basic blocks, rather than as a straight line. I don't know if that's super obvious (it seems obvious, written out that way), but just taking a listing and adding newlines at block boundaries is massively helpful to me.
- chrisaycock 6y agoThat's definitely how a compiler does it, especially at the IR stage. It's much easier to track values within a localized region; this applies to both people and computers.
- tralarpa 6y ago> it seems obvious, written out that way Yep. Most disassembly tools have configuration settings specifically for that (add newline after jumps, put labels on separate lines, etc.)
- tptacek 6y agoSure, and I'm guessing I learned to read assembly this way from IDA Pro; I'd had to deal with assembly long before IDA was a thing, but I was never an especially able reader of other people's assembly. But even today, like, when the eBPF verifier coughs on a hairball, I end up pulling assembly into Emacs and then doing a quick pass marking up the basic blocks before I try to read it.
- dtornabene 6y agoI'm sure its not too much trouble to whip up on my own but if you have any emacs lisp helping you do this I'd love to read (and use) it
- tptacek 6y agoI wish. If you write it, let me know.
- dtornabene 6y agothis was also a major step for me, understanding what a basic block was and also seeing the code organized that way
- gens 6y agoThat's how i write assembly. Extra newline between each small block, and two between every major block.
- wglb 6y agoThis was also discussed by Don Lancaster. So for a good trivia question: who invented the concept of Basic Blocks?
- tptacek 6y agoIt turns out it is not Frances Allen, if you're wondering.