

Ask HN: Examples of beautifully written x64 assembly? - nkurz

I&#x27;m looking for clear and idiomatic modern x64 assembly code to learn from and imitate.  Are there examples out there?  That is, what&#x27;s the assembly equivalent of Redis or SQLite that I can use to learn about good stylistic choices.<p>I&#x27;m less concerned with what it does, and more concerned with how it reads:  formatting, use of macros, naming conventions.  Most of the code I read is generated by compilers, and I&#x27;m worried that it doesn&#x27;t serve well as a style guide.
======
J_Darnley
x264? FFmpeg (at least the newer parts)? It is mostly SIMD and suitably
abstracted so it runs on x86, win64 and *nix64 but that doesn't mean it can't
teach you things. It is what got me interested.

I would say that SIMD is the biggest reason to dip into assembly and for many
situations, the only one.

Anyway, you can see how these projects format the source. The general rule is:
align instrcutions, and align first, second, and third operands (within
reason). Indent loops (like any other language)

------
checker659
Also, while we're at it, a good book to get up to speed with x64 assembly
would be awesome.

------
segmondy
clear and idiomatic assembly? I don't write assembly code, but when I did. It
was for performance reasons, there was no such thing as clear and idiomatic. I
needed performance and every spare cycle I could get, and that meant taking
advantage of whatever the cpu offered, some obscure things that made no sense,
but made the program run faster. Beautiful assembly code to me and my mates
was one that made the program faster, as a program, the beauty was in how it
was illogical at first sight but made sense when you read into it.

