Live data from Hacker News

The faker's guide to reading x86 assembly language

timdbg.com

31–40 of 49 posts

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

#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 compilers actually do to source code, people cannot actually derive meaningful signal or intuition. A very experienced programmer without exposure to assembly might be able to optimize a tight loop or spot a performance issue, but that's probably the extent of it.

Complexity increases as you introduce platform-specific calling conventions, APIs, etc.

I don't know a better way to acquire assembly intuition than by implementing a RISC-V CPU or staring at a lot of decompiled output.

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

#32
post #20

Earlier quoted context omitted.

Yes - it is one way to do it and it will work and be reasonably efficient. Everyone[1] who knows x86-64 asm today learned 32 bit first. You still have 32 bit instructions, and 16 bit, and 8 bit. The instructions will translate. You get more registers. You need to update the function and syscall calling conventions. There's no reason there can't be "learn x64 asm" books but there aren't many last I looked, but maybe s…

I would doubt that, people haven't been running 32-bit x86 code for years at this point.

How exactly do you get away with not using the 32-bit subset of AMD64 ASM?

"32-bit x86 code" just means "code that does not use any of the AMD64 ISA." (And at this point, probably SSE2+ and a handful of other extensions.)

GP is correct: anyone that "knows" AMD64 assembly inherently must know 32-bit ASM because one must use the original x86 registers, instructions, etc. for the vast majority of tasks.

People are still constantly running what was formerly known as "32-bit x86 code" in their 64-bit applications.

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

#33
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…

AsmBB - a forum written in Assembly prove that usage

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

#34

> 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

> between assembly and what a processor will actually execute

Well, modern processors can execute out of order for efficiency reasons, but the end result must be exactly the same as if the instructions were executed serially.

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

#35
near the end of text,one of the most complete resources:

https://www.intel.com/content/www/us/en/developer/articles/t...

coding in assembler is very manual, such as stack manipulation, or dropping assembler instructions into windows applications.

these are procedures you can pickout from the code, but very hard to discover if you are unaware of the hueristic.

other resources.

https://www.agner.org/optimize/

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

#36
post #7
post #4

Earlier quoted context omitted.

An easy way to learn to see those patterns is through exploring compiler output: https://godbolt.org/ Other than that, I like "Assembly Language Step By Step" by Jeff Duntemann, which is currently in its third edition and is Linux-only, as opposed to previous editions which were MS-DOS and Linux. He has example assembly code (Intel syntax for NASM, another reason I like his book) for download on his website: http://w…

Regarding the book, What would be the difference between 32bit and 64bit? Is it still relevant to read today?

From my very limited RE experience, one difference is calling convention: 32-bit passes a lot of stuffs on stack while 64-bit passes the first 8 (IIRC) through registers and the rest on stack. I could be wrong but this is one glaring difference. Another one of course is the registers them selves: EAX vs RAX for example.

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

#37
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…

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.

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

#38
post #4

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…

An easy way to learn to see those patterns is through exploring compiler output: https://godbolt.org/ Other than that, I like "Assembly Language Step By Step" by Jeff Duntemann, which is currently in its third edition and is Linux-only, as opposed to previous editions which were MS-DOS and Linux. He has example assembly code (Intel syntax for NASM, another reason I like his book) for download on his website: http://w…

> Intel syntax for NASM

Like the Good Lord intended.

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

#39
post #37
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…

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.

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

#40
post #32

Earlier quoted context omitted.

I would doubt that, people haven't been running 32-bit x86 code for years at this point.

How exactly do you get away with not using the 32-bit subset of AMD64 ASM? "32-bit x86 code" just means "code that does not use any of the AMD64 ISA." (And at this point, probably SSE2+ and a handful of other extensions.) GP is correct: anyone that "knows" AMD64 assembly inherently must know 32-bit ASM because one must use the original x86 registers, instructions, etc. for the vast majority of tasks. People are still…

I read “learned 32-bit first” as “learned on i386 machines”, not “learned what the 32-bit instructions do on 64-bit computers”. There’s a big difference between these two, because the way you write code for a machine that doesn’t do 64-bit is quite different, since you have many more registers, the calling convention is pretty different, etc.
Post reply on HN