Live data from Hacker News

Ask HN: What's the best resource for learning modern x64 assembly?

news.ycombinator.com

11–20 of 112 posts

Re: Ask HN: What's the best resource for learning modern x64 assembly?

#11
post #5
post #2

As far as I know, x86_64 added instructions, modes and memory address changes but the assembly is the same? https://software.intel.com/en-us/articles/introduction-to-x6... I mean, you have different modes, and in 64-bit mode EAX becomes RAX for example.

I agree with this, if you are competent at 32-bit those skills are going to translate. It is mostly the same. Some exceptions that come to mind: * The old floating point stuff is gone. EDIT: guess I am wrong on that, was thinking of what compilers typically generate for the architecture. * The C abi now tends to focus on pass-by-register for the first few arguments. * If you are working in kernel mode, some stuff is…

> The old floating point stuff is gone.

Do you mean x87? I’m not sure it’s true that it’s gone is it? The instructions are still documented? Do they not work?

Re: Ask HN: What's the best resource for learning modern x64 assembly?

#14

Here is a book on computer architecture that has a good section on x86-64 assembly language. Please note that I have edited this comment to reflect a change suggested by a cold comment. This book (the third edition) introduces x86-64 assembly very well. https://csapp.cs.cmu.edu/

Working through this now (again) and its excellent. A few observations- do the labs (google them) they are even better. The lectures are also available on youtube and the recitations on something I found called panopto- they are mostly repetition from the book but nice to reinforce.

Re: Ask HN: What's the best resource for learning modern x64 assembly?

#15
post #5

Earlier quoted context omitted.

I agree with this, if you are competent at 32-bit those skills are going to translate. It is mostly the same. Some exceptions that come to mind: * The old floating point stuff is gone. EDIT: guess I am wrong on that, was thinking of what compilers typically generate for the architecture. * The C abi now tends to focus on pass-by-register for the first few arguments. * If you are working in kernel mode, some stuff is…

> The old floating point stuff is gone. Do you mean x87? I’m not sure it’s true that it’s gone is it? The instructions are still documented? Do they not work?

I guess I stand corrected. I was under the impression that C compilers don't tend to use it anymore when compiling for amd64. (Because you can assume SSE support on amd64, unlike a binary that might run on an old Pentium.) Then I misread that situation as it not working.

It does take effort for an OS kernel to save and restore x87 state, so I could imagine somebody dropping support.

Re: Ask HN: What's the best resource for learning modern x64 assembly?

#16
post #9

Honestly? Learn old-style 8086 assembly, then 386 code. The new stuff may be architecturally simpler in many ways, but it sits as an edge case on top of a very thick historical stack that seems completely insane if you look at it a priori. But the early CPUs were actually quite simple! At the time "CISC" was a good thing because it provided straightforward mechanisms for expressing things (e.g. "push", "call", load a…

[deleted]

Re: Ask HN: What's the best resource for learning modern x64 assembly?

#18
post #9

Honestly? Learn old-style 8086 assembly, then 386 code. The new stuff may be architecturally simpler in many ways, but it sits as an edge case on top of a very thick historical stack that seems completely insane if you look at it a priori. But the early CPUs were actually quite simple! At the time "CISC" was a good thing because it provided straightforward mechanisms for expressing things (e.g. "push", "call", load a…

I think segmented memory really hampered my ability to learn 8086 assembly well. It really made a mess of just about everything.

Re: Ask HN: What's the best resource for learning modern x64 assembly?

#20
There's no magic anywhere and 99.1% of it is documented.

IA-32e/AMD64 is basically an extension of IA-32/x86. What you're looking for is to understand the difference between real mode, 386 protected mode, PAE, paging and long mode because the registers, instructions, addressing and sizes of structures differ.

You can learn all of this by reading the Intel software manuals and digging into it yourself.

Tools you need (for non-Windows):

- gdb/lldb

- assemblers: yasm, nasm, binutils (contains "as")

Optional tools:

- IDA Pro

- Virtualization/emulation such as VMware Fusion/Workstation (because it supports being a gdbserver), VirtualBox or QEMU

- Intel's CPUID app

You also need good references like:

- the Intel manual set (a giant PDF or a collection of several) https://software.intel.com/en-us/articles/intel-sdm

- https://sandpile.org (fairly current)

- https://ref.x86asm.net (outdated by useful)

Another helpful exercise is writing a toy operating system in Rust or only assembly. https://osdev.org has many resources and guides.

Post reply on HN