rentzsch.com: tales from the red shed

Don't Fear the Assembler

Notes
I don't think you have to be a hard-core geek to pick up PowerPC assembly. I would say learning assembly on a noninsane processor (like the PowerPC) from scratch is probably easier than learning C from scratch. You have a small set of symmetrical instructions, registers and memory. That's it. Nothing really brain-bending about it (purposely ignoring the rotate left word * suite). Really, the biggest headache is that you have to manage the stack yourself, which is more tedious than anything.

I guess that's my point: assembly programming is more tedious than hard. Nowadays it's insane to write lots of code in assembly, but it's still a handy skill to have. First, you can do things in assembly that you can't in C. Second, it gives you a better insight how, exactly, your software works. Finally, assembly is a wicked razor wakizashi for slicing down hardened bugs in your apps. At that level, there's simply no place for them to hide.

Update: Eric Gundrum (one of the founders of Extendamac, mach_*'s home) reminds me to mention a great way to get started learning PowerPC assembly is to write a little C code and then disassemble it (in Xcode: Build->Show Assembly Code), paying particular attention to how the stack frame is formed and how the registers are used. Try adding a stack variable or three, a loop, returning from the middle of a function, etc. Make sure you start off with all optimizations turned off, so the code is straight-forward. Then you can start turning them on, and notice how the code changes. In no time, you'll be an old codger like me, complaining with the rest of us about the poor code your compiler generates. (grin)

Wednesday, April 06, 2005
12:00 AM