3 ms·
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 lec
by eldavido 12y ago
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.
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.
Nice article.
- xur17 12y agoIt's also pretty fun to find spots where the compiler failed to fully optimize the code (possibly due to the optimization level chosen). For example, I recently saw a few cases in the code I was looking at where a function pushed several registers onto the stack that were never used in the function. I've found it reasonably interesting to look at at first, but it can get dull relatively quickly, especially when you're first learning.