Hacker News

Top stories

Live mirror
30 storiesupdated just nowView source snapshot
  1. GPT-6 Sol and Luna(openai.com)
    448comments
  2. Claude Opus 5.5(anthropic.com)
    684comments
  3. Microsoft killed FoxPro in 2007. Anyway, here's FoxPro revived(foxscript.org)
    1comments
  4. 'We hacked the FBI:' Hackers say they have data on all FBI employees(404media.co)
    94comments
  5. OpenAI GPT–6 Astra breaks Enigma message that has resisted solution since 2005(cryptocellar.org)
    343comments
  6. Claude Opus 5.5 Intelligence, Performance and Price Analysis (Max)(artificialanalysis.ai)
    51comments
  7. SAML: A Fractal of Bad Design(trailofbits.com)
    34comments
  8. No Sloptober(no-sloptober.com)
    11comments
  9. WordPress: Unauthenticated path traversal leading to conditional RCE(github.com/wordpress)
    61comments
  10. What California is learning from solar panels built over irrigation canals(kqed.org)
    28comments
  11. Native apps written in TypeScript and CSS(github.com/geastack)
    9comments
  12. The UV index is not the warm sensation of sunlight on bare skin(asciitweezers.com)
    discuss
  13. Did OpenAI solve the wrong Navier-Stokes problem?(scientificamerican.com)
    23comments
  14. Markdown in /src(htmx.org)
    15comments
  15. OpenAI is well positioned to fast-follow Jev(arcturus-labs.com)
    173comments
  16. Rabbit Hole: Minimum L-seams(fractalkitty.com)
    5comments
  17. MUNI Heritage Weekend in San Francisco(lawrence.lu)
    32comments
  18. An update on how we confirm your age group on Discord(discord.com)
    12comments
  19. How did AMD Ryzen get 50% faster in two years?(lemire.me)
    28comments
  20. Unreal Agent(unreallabs.ai)
    48comments
  21. The Trouble with 'Ntile()'(djnavarro.net)
    discuss
  22. Show HN: Training a model to identify AI web content from structure alone(arxiv.org)
    6comments
  23. Show HN: JevBench, a reproducible benchmark for typed decision models(benchmarkheaven.com)
    1comments
  24. A Faster Shortest Path Algorithm(vals.ai)
    5comments
  25. 16-bit Intel 8088 chip (c. 1985)(allpoetry.com)
    13comments
  26. George Lucas Returns to Earth, Bearing Gifts(commonedge.org)
    24comments
  27. Overreliance on AI contributed to missile strike on Iran school – Pentagon(bloomberg.com)
    126comments
  28. Apple has added persistent 'ads' to iOS, and it's driving users crazy(techradar.com)
    398comments
  29. There's a high chance of devices being sold with GrapheneOS preinstalled in 2027(grapheneos.social)
    93comments
  30. The JavaScript Midlife Crisis(maroun-baydoun.com)
    5comments

Ask HN: How did you learn x86-64 assembly?

48 pointsby 6y ago
20 comments
I'm an experienced C/C++ programmer and I occasionally look at the generated assembly to check for optimizations, loop unrolling, vectorization, etc. I understand what's going on the surface level, but I have a hard time understand what's going on in detail, especially with high optimization levels, where the compiler would do all kinds of clever tricks. I experiment with code in godbolt.org and look up the various opcodes, but I would like to take a more structured way of learning x86-64 assembly, especially when it comes to common patterns, tips and tricks, etc.

Are there any good books or tutorials you can recommend which go beyond the very beginner level?

6y agoHN ↗

thanks, this looks really nice and condensed.

6y agoHN ↗

I think what I am looking for is basically a modern equivalent to this text... (and without all the HLA :-)

6y agoHN ↗

It sounds like you are off to a great start. Afaik there really isn't any 400 or 500 level material for advanced assembly programming. You could read Goto BLAS [1] or mkl-dnn [2]

I find reading assembly output from compilers to be a good start, it also helps you develop a mental model of what compilers expect in terms of stack hygiene.

Before godlbolt, https://godbolt.org/ there was `gcc -S` and now there is [3]

    gcc -Wa,-adhln -g <file.c>

for interleaving source and assembly output. Keep the reference manual close and write lots of little experiments to confirm your findings.

[1] https://en.wikipedia.org/wiki/GotoBLAS

[2] uses macros and intrinsics https://github.com/oneapi-src/oneDNN

[3] https://stackoverflow.com/questions/3867721/is-there-any-c-c...

6y agoHN ↗

High Level Assembly (HLA) https://en.wikipedia.org/wiki/High_Level_Assembly

HLA was originally conceived as a tool to teach assembly language programming at the college-university level. The goal is to leverage students' existing programming knowledge when learning assembly language to get them up to speed as fast as possible. Most students taking an assembly language programming course have already been introduced to high-level control flow structures, such as IF, WHILE, FOR, etc. HLA allows students to immediately apply that programming knowledge to assembly language coding early in their course, allowing them to master other prerequisite subjects in assembly before learning how to code low-level forms of these control structures. The book The Art of Assembly Language Programming by Randall Hyde uses HLA for this purpose

Web: https://plantation-productions.com/Webster/

Book: "The Art of Assembly Language Programming" https://plantation-productions.com/Webster/www.artofasm.com/

Portable, Opensource, IA-32, Standard Library: https://sourceforge.net/projects/hla-stdlib/

"12.4 Programming in C/C++ and HLA" in the Linux 32 bit edition: https://plantation-productions.com/Webster/www.artofasm.com/...

... A chapter(s) about wider registers, WASM, and LLVM bitcode etc might be useful?

... Many awesome lists link to OllyDbg and other great resources for ASM; like such as ghidra: https://www.google.com/search?q=ollydbg+site%3Agithub.com+in...

6y agoHN ↗

Programming from Ground Up, by Jonathan Bartlett.

https://download-mirror.savannah.gnu.org/releases/pgubook/Pr...

I was able to learn a lot about low level programming. The problems with this book: the examples are in Intel syntax (I find AT&T's syntax better to read and it's more common to use), and not in x86-64.

Also, Hacking: The Art of Exploitation (https://nostarch.com/hacking2.htm) have a nice introduction on Assembly, from the standpoint of a person doing reverse engineering, debugging with GDB or shellcoding.

6y agoHN ↗

Http://agner.org is a good resource once you know the basics. It explains a lot of how microprocessors interpret instructions, caches, decoding, microinstructions. Assembler is not really a language, it’s deeply connected to the material. Agner explains a lot of those things.

This might be what you want : https://www.agner.org/optimize/#manuals

6y agoHN ↗

A good debugger that shows the registers and flags, inspect memory and single step instructions is also a must when you're starting out. I spent many an hour staring at STmon on my atari ST.

6y agoHN ↗

securitytube linux assembly expert

Focused on offensive security techniques and concepts but taught me a ton and has both x86 and x86-64 architectures. Briefly touched on ARM as well

6y agoHN ↗

Start by writing very simple C code and compiling that to assembly with the C comments. Then follow the System V ABI to learn what registers you need to pay attention to when calling functions. Start small. Once you learn the simple stuff, the more complex stuff is a matter of using it when you run into it.

6y agoHN ↗

First of all I learned Z80 assembly, because BASIC was too slow. Then I moved to Intel and 8086 assembly!

That's not so helpful, so more seriously the way that I started was to spend a lot of time reading tutorials and writing sample programs. Back in the day I read virus "magazines" like 40Hex, because they had decent examples of intel assembly and often useful discussion.

These days I've been revisiting things writing a couple of simple compilers:

https://github.com/skx/math-compiler/

https://github.com/skx/bfcc/

The first was mostly written because I'd not done anything recently with floating-point, and the second because compiling brainfuck programs to assembly seemed like it would result in fast programs.

Simple projects like those above could be written quite quickly I think, because they only involve writing a very small collection of "primitives" (such as "write string to STDOUT", or "sin(x)"). They're almost template-based programs.

6y agoHN ↗

I started programming when I was about 9. When I was a teenager, around 13 or 14, I became interested in how to influence the behavior of software after it was written. I had also taken an interest in reading and writing source code of programs that relied on other programs to continue to live, flourish, and fulfill their goal, which meant that sometimes they had to hide, or present themselves in ways that made them accepted.