Chapter 8. Our Object All Sublime

Creating Programs That Work

They don't call it "assembly" for nothing. Facing the task of writing an assembly language program brings to mind images of Christmas morning: you've spilled 1,567 small metal parts out of a large box marked Land Shark HyperBike (some assembly required) and now you have to somehow put them all together with nothing left over. (In the meantime, the kids seem more than happy playing in the box.)

I've actually explained just about all you absolutely must understand to create your first assembly language program. Still, there is a nontrivial leap from here to there; you are faced with many small parts with sharp edges that can fit together in an infinity of different ways, most wrong, some workable, but only a few that are ideal.

So here's the plan: in this chapter I'll present you with the completed and operable Land Shark HyperBike—which I will then tear apart before your eyes. This is the best way to learn to assemble: by pulling apart programs written by those who know what they're doing. Over the course of this chapter we'll pull a few more programs apart, in the hope that by the time it's over you'll be able to move in the other direction all by yourself.

The Bones of an Assembly Language Program

Back in Listing 5 in Chapter 5, I presented perhaps the simplest correct program for Linux that will do anything visible and still be comprehensible and expandable. Since then we've been looking at instructions in a sandbox through ...

Get Assembly Language Step-by-Step: Programming with Linux®, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.