CHAPTER 4Location, Location, Location: Registers, Memory Addressing, and Knowing Where Things Are

I wrote this book in large part because I could not find a beginning text on assembly language that I respected in the least. Nearly all books on assembly start by introducing the concept of an instruction set and then begin describing machine instructions, one by one. This is moronic, and the authors of such books should be spanked. Hard. Even if you've learned every single instruction in an instruction set, you haven't learned assembly language.

You haven't even come close.

The naïve objection that a CPU exists to execute machine instructions can be disposed of pretty easily: it executes machine instructions once it has them in its electronic hands. The real job of a CPU, and the real challenge of assembly language, lies in locating the required instructions and data in memory. Any idiot can learn machine instructions. The skill of assembly language consists of a deep comprehension of memory addressing. Everything else is details—and easy details, at that.

The Joy of Memory Models

Memory addressing is a difficult business, made much more difficult by the fact that there are a fair number of different ways to address memory in the Intel/AMD CPU family. Each of these ways is called a memory model. There are three major memory models that you can use with the more recent members of the Intel family, and a number of minor variations on those three, especially the one in the middle. ...

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.