Very nice, this is the blog post that I wanted to follow up mine with: <a href="http://nickdesaulniers.github.io/blog/2014/04/18/lets-write-some-x86-64/" rel="nofollow">http://nickdesaulniers.github.io/blog/2014/04/18/lets-write-...</a> I guess I still could, for x86_64. Any interest?<p>I believe the term for these patterns is called "lowering."
Interested in this stuff? Get a computer engineering degree. This is precisely what we studied in my first-year programming classes. I have fond memories of lecture halls with blackboards on every wall, divided into right and left columns, showing simplified x86 assembly on the left, and C code on the right.<p>Another interesting topic in this area is calling conventions: the expectations of your compiler/platform on how the stack is arranged, to facilitate "linkage" between callers and callees. The "calling convention" dictates where the return value goes, where the processor registers get saved (so they can be restored when control transfers back from the called function to the caller), and the location of the return address. Also, it varies based on whether you're calling code in your own program or into the operating system -- OS calls always have to scrub all the registers, to avoid leaking protected state back to userspace.<p>Nice article.
In the late 80's, when compilers for micro-computers still generated crappy code, it was quite easy to write tools that would map back to the source, if one knew which compiler was used.<p>Most patterns were as easy as tracking down bytecodes.
I'm working on the Coursera compilers class right now, which is excellent: <a href="https://class.coursera.org/compilers-004" rel="nofollow">https://class.coursera.org/compilers-004</a><p>The code generation portion of the class covers this material from the other end, i.e. at the point where the AST is transformed into assembly code, and it has been super interesting.<p>This is obvious in retrospect but wasn't to me beforehand: if you're interested in reverse engineering, it's very helpful to study how the assembly was written in the first place.