Chapter 11. Strings and Things

Those Amazing String Instructions

At this point in the book we've touched on most of the important facets of assembly language work, including nearly all categories of machine instruction. One category remains, and for my money they're probably the most fascinating of all: the x86 string instructions.

They alone, of all the instructions in the x86 instruction set, have the power to deal with long sequences of bytes, words, or double words in memory at one time. (In assembly language, any contiguous sequence of bytes in memory may be considered a string—not simply sequences of human-readable characters.) More amazingly, some string instructions have the power to deal with these large sequences of bytes in an extraordinarily compact way: by executing a complete instruction loop as a single instruction, entirely within the CPU.

In this chapter, we'll cozy up to assembly language strings, and cover a few more topics related to programming and debugging for Linux.

The Notion of an Assembly Language String

Words fail us sometimes by picking up meanings as readily as a magnet picks up iron filings. The word string is a major offender here. It means roughly the same thing in all computer programming, but there are a multitude of small variations on that single theme. If you learned about strings in Pascal (as I did), you'll find that what you know isn't totally applicable when you program in C/C++, Python, Basic, or (especially) assembly.

So here's the Big View: ...

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.