Linux Format logo

Why learn assembler?

That's the question I've been hearing a lot recently (well, that and "Why do you suck at $GAME?", but I'll beat Paul one day). Regular blogwatchers have seen the embryonic stages of MikeOS, which is moving along well, but I'm itching to try some other (less ugly) languages than 16-bit x86 assembly. 68k is supposedly a good instruction set, but I think my next step should be ARM -- after all, it's the CPU used in my mobile phone, GBA, Nintendo DS, and no doubt a squillion other gizmos I've acquired. Oh, and I've got a Acorn 7000 somewhere, with its warm marbley widgets (which most people now seem to hate).

Assembler can be difficult, yes, and you certainly wouldn't want to recreate a monster like in machine code. Although I've got no stats to hand, I'd wager that 99% of software development today is done in mid or high-level languages, with assembler being reserved for tiny embedded devices, a few hardware drivers and pure geekocity. Even handheld consoles have moved out of machine code land -- most Game Boy and Game Gear titles were coded in asm back in the early '90s, whereas today's DS and PSP games tend to be written in C. So there's very little demand for hardcore asm hackers now.

However, that doesn't mean it's not worth learning assembler. From a programming standpoint, there's no better way to understand how your programs work -- you can see exactly what they boil down to, after all the pre-processing, abstraction, compiling, linking, and so forth. You've got the fundamental code interfacing with the hardware and operating system (that is, if you even have an operating system!) You can take the output of a compiler and hand-optimise it for maximum speed -- rarely worth the effort on complex multi-GHz chips like the P4, but often yielding good results on slow devices.

Assembler gives you the ultimate control. You do what you want with your registers and memory, completely unconstrained by the restrictions of a high-level language. Of course, this means it's easier to make mistakes, as there's no run-time error checking (and not much the assembler can do to spot potential problems). But you get a complete picture of what's going on, and despite the oft-repeated blather, you can write neat, modular code in most assembly languages. It takes time, but just like painting a picture or building a house from scratch, it's massively rewarding. High-level languages, in comparison, make you feel like you're painting a landscape scene using pre-made stamps for cows, buildings and rivers.

Meanwhile, LXF Artmeister Effy joins the blogosphere, with this snap from his World Cup travels. Can you spot Effy?

Your comments

Web hosting by UKFast