Live data from Hacker News

The faker's guide to reading x86 assembly language

timdbg.com

41–49 of 49 posts

Re: The faker's guide to reading x86 assembly language

#41

> But the assembly code will always tell you the truth. Is this really still the case with modern caching branch-predicting microcode processors? [1] From what I know (which is little), there is quite a way between assembly and what a processor will actually execute. [1] just throwing around buzzwords

It's the closest you'll get without going complete insaneo style. [0]

[0] https://www.youtube.com/watch?v=hQ40jNXMDlk

Re: The faker's guide to reading x86 assembly language

#43
post #37

Earlier quoted context omitted.

I've heard nothing but good things about this course which should do the trick: https://www.nand2tetris.org It on my todo list at some point, maybe this year or next.

I completed the hardware part last month. It's definitely accessible and serves as a good entry project for interested students. However it glossed over a lot of things (that even I'm aware of) so I decided to up the game and find other projects/lectures. The CPU project of University of Tokyo seems interesting but is too tough for whoever just completes nand2tetris. Some bridge project is needed.

I came across this on HN a month or two back, might be the kind of project you're looking for?

https://539kernel.com

Re: The faker's guide to reading x86 assembly language

#44

This was a nice read, but I was hoping for something one step above this. When I was writing an emulator, I spent so much time looking at 8080(ish) code that I began to see constructs for bigger concepts. Like, “oh you’re setting up and running a loop over some subroutine X times.” “You’re checking if a certain math expression equals a certain value before continuing.” Etc. I imagine an Assembly reader sees these thi…

I'm planning to write a future post on "common compiler generated code" to recognize those patterns. The intention of this post was to encourage folks who think asm is scary to give it a try because it's not as bad as they think. You really need to spend a bunch of time with godbolt or a debugger with a side-by-side source and asm view to really build an intuition for these things. I want to try to give folks the tools they need to start building that intuition, because you can read dozens of articles about asm and still have no idea what you're doing.

Re: The faker's guide to reading x86 assembly language

#45
post #42

"not so hard" .. until your compiler decide to vectorize your loop then good luck!

That's actually something I want to tackle in the next post I'm writing. I need good examples though of stuff like that, so I think I need to spend some time with godbolt...

Re: The faker's guide to reading x86 assembly language

#46
post #2

Yes, the simple opcodes are the most-used, and this was one of the ideas floating around that helped inspire RISC, but be careful how you figure out which opcodes are different. For example, mov in x86 is extremely polysemous: It can be move from register to register, load register with data from RAM, store register contents out to RAM, store a constant out to RAM, and even perform ALU operations and then use the res…

The target audience here were folks that have very little experience with asm, but you're completely right that a lot of complexity gets glossed over. That's not even to mention cases where an instruction behaves differently depending on the code segment attribute or privilege level it's running in.

Re: The faker's guide to reading x86 assembly language

#47
post #31

In my opinion, most articles, lessons, etc. that purport to teach assembly miss the forest for the trees. This is a good article for someone wanting to learn "what assembly _is_" - but I have yet to see an article targeted to programmers that would teach "how do I practically use this." One can learn the vague syntax complexities, etc. - maybe even write a Hello World..but without having real-world exposure of what c…

Covering how to practically use it is far too much for a single post (and I don't think I really claimed to teach assembly... I just want to give people the tools they need to start learning assembly). This was mainly to get people to not be scared and start reading asm, which is really the only way you can learn this stuff. In my opinion, writing a hello world in asm is not useful for most people. But learning enough to understand what part of a complex C++ expression caused a program to crash is much easier, and more widely useful. My plan for future posts is to talk about common compiler-generated code patterns to help people recognize what's causing a crash even if they don't understand every line of asm.

Re: The faker's guide to reading x86 assembly language

#48

I dabbed into reverse engineering a while ago (and probably will dive deeper into it seriously later) and realized it is not particularly difficult to recognize constructs in assembly code, but only for simple code such as examples. Once they go up one level, say start using a lot of win32 api, it then makes the business a lot more confusing. That was why I decided to drop the study temporarily. I wanted to figure ou…

That's true. It's far too broad to learn everything without having a specific goal in mind. Learning the parts of asm that are useful for writing asm code is very different than learning enough asm to understand what APIs are being called from malware.

Re: The faker's guide to reading x86 assembly language

#49
post #43

Earlier quoted context omitted.

I completed the hardware part last month. It's definitely accessible and serves as a good entry project for interested students. However it glossed over a lot of things (that even I'm aware of) so I decided to up the game and find other projects/lectures. The CPU project of University of Tokyo seems interesting but is too tough for whoever just completes nand2tetris. Some bridge project is needed.

I came across this on HN a month or two back, might be the kind of project you're looking for? https://539kernel.com

Thanks! That's part of the picture. I'm looking for something similar to nand2tetris but level up one notch. 539kernel definitely can serve as part of the puzzle.
Post reply on HN