CHAPTER 8Our Object All Sublime: Creating Programs That Work
The Bones of an Assembly Language Program
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 rest 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.
In Listing 5.1 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 ...
Get x64 Assembly Language Step-by-Step, 4th 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.