News for hackers. Stuff that matters.
Re:How to Read Assembly Language by tptacek on Tuesday March 02, 2021 @10:28AM (#26316253)
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.
Re:How to Read Assembly Language by chrisaycock on Tuesday March 02, 2021 @10:44AM (#26316446)
That'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.
Re:How to Read Assembly Language by tralarpa on Tuesday March 02, 2021 @11:10AM (#26316783)
> 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.)

Re:How to Read Assembly Language by tptacek on Tuesday March 02, 2021 @11:21AM (#26316939)
Sure, 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.

Re:How to Read Assembly Language by dtornabene on Tuesday March 02, 2021 @12:29PM (#26317807)
I'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
Re:How to Read Assembly Language by tptacek on Tuesday March 02, 2021 @10:48PM (#26324508)
I wish. If you write it, let me know.
Re:How to Read Assembly Language by gens on Tuesday March 02, 2021 @01:04PM (#26318255)
That's how i write assembly. Extra newline between each small block, and two between every major block.
Re:How to Read Assembly Language by wglb on Tuesday March 02, 2021 @06:54PM (#26322926)
This was also discussed by Don Lancaster.

So for a good trivia question: who invented the concept of Basic Blocks?

Re:How to Read Assembly Language by tptacek on Tuesday March 02, 2021 @10:48PM (#26324505)
It turns out it is not Frances Allen, if you're wondering.
Re:How to Read Assembly Language by dtornabene on Tuesday March 02, 2021 @12:27PM (#26317776)
this was also a major step for me, understanding what a basic block was and also seeing the code organized that way