Hacker News

Top stories

Live mirror
30 storiesupdated just nowView source snapshot
  1. AI-generated posters don’t have to be horrible(john.hartnup.uk ↗)
    229comments
  2. Laya the open source version of Jev(convaiinnovations.com ↗)
    13comments
  3. Human brain is two separate organs, Stanford Medicine-led research finds(stanford.edu ↗)
    125comments
  4. “The Secret Life of Circuits” is here(coredump.cx ↗)
    30comments
  5. If math is more than proof, we need to better celebrate the rest of it(terrytao.wordpress.com ↗)
    115comments
  6. GPT-6 Astra Solves a WWI German Radio Cipher(prinzai.com ↗)
    93comments
  7. Android 17 is the first since 3.x to add new APIs without releasing to the AOSP(grapheneos.social ↗)
    474comments
  8. San Francisco Onion Futures Company(onionfutures.com ↗)
    83comments
  9. Show HN: I wrote a custom assembler for CHIP-8 in C++(github.com/tackx ↗)
    discuss
  10. Communication by means of modulated Johnson noise(pnas.org ↗)
    6comments
  11. Cloudflare Quick Tunnels(cloudflare.com ↗)
    292comments
  12. How to Write with an LLM(sockpuppet.org ↗)
    344comments
  13. You can run Git on object storage if you re-make packfiles(tigrisdata.com ↗)
    19comments
  14. SDCC – Small Device C Compiler(sourceforge.net ↗)
    20comments
  15. From Stonemasons to Carpenters(thelastsoftwareengineer.substack.com ↗)
    2comments
  16. Saving another 100TB of RAM(cloudflare.com ↗)
    84comments
  17. Science Is Open Software(jepedersen.dk ↗)
    41comments
  18. Why building a Rust LSP is hard(rust-glancer.github.io ↗)
    38comments
  19. How OpenAI Used Its Own LLMs to Design Its Jalapeño Chip(ieee.org ↗)
    98comments
  20. Ctenophores: Wonders of Biology(quantamagazine.org ↗)
    6comments
  21. NASA-IBM Lunar Foundation open-Source Geospatial AI Model(usra.edu ↗)
    4comments
  22. The first new cat species discovered in 100 years(nationalgeographic.com ↗)
    108comments
  23. OpenJev(openjev.com ↗)
    273comments
  24. Goroutine Leak Profiles(go.dev ↗)
    5comments
  25. Show HN: Cactus Needle 3: 8-29MB automation models can match DeepSeek V4 Flash(cactuscompute.com ↗)
    89comments
  26. Photon-Emission-Guided Laser Fault Injection Enables RP2350 Secure Debug(ledger.com ↗)
    73comments
  27. Veronese's Dogs(publicdomainreview.org ↗)
    2comments
  28. Warez: The Infrastructure and Aesthetics of Piracy (2021)(archive.org ↗)
    87comments
  29. Cache-to-Cache: Direct Semantic Communication Between LLMs (2025)(arxiv.org ↗)
    14comments
  30. Inside ZCode: Silently uploading your Git history to the cloud(ferstar.org ↗)
    105comments

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.