R – How to become good at assembly?

assemblyperformance

The answer to this question is, of course, "write some assembly code!"

But I can do that: I know basic x86 syntax, the types of registers and how to use them, subroutines, etc etc.

When I took an assembly class, each assignment had a maximum number of instructions that we were allowed to use. If we went over, then we would lose points – so this taught us to do things efficiently. You know, efficiently in the way that, if you saw a C program doing such things, you might harp on that individual for creating difficult-to-follow code.

For C, one can suggest "write a multi-threaded program" or "write a socket server/client". For PHP, suggestions might be "write a personal blog software". To learn the syntax of a language, "project euler" is often suggested.

So my question(s) are:

  1. What kinds of things can I write in assembly that will let me hone my assembly and efficiency skills? For example, I could do a project euler problem in x86, but that doesn't help me with assembly-specific skills. What are project ideas I could do that can only really be coded in assembler?

  2. How would I go about profiling whether or not I'm writing "good" code? For example, with C and sockets, there are a billion tutorials on the web, and there are a billion people on my buddy list who can look at my code, and there are a billion SO questions about them: so it is easier to measure one's progress.

  3. Are there existing assembly heavy projects which I can look at to learn from? Or even parts of programs where they break into assembly for [specific task] for the sake of efficiency?

  4. What kinds of books should I be reading? Blogs of people who routinely look at low-level things?

(preferably things I could do on x86 on linux. I figure the concepts will carry over to other architectures.)

Best Answer

Good answers. I would also suggest writing a small compiler and having it write the assembly language for you. That way, you get to think about different ways to do things in assembler, like passing arguments, making stack frames, composing address expressions, array indexing, managing memory, conditionals, loops, try-catch, etc. etc.