Author: Randall Hyde
Publisher: No Starch Press, 2010 (2nd Edition)
Aimed at: Beginners
Pros: A good introduction to the HLA dialect
Cons: It introduces HLA rather than raw assembler
Reviewed by: Harry Fairhead
If you have always wanted to learn assembly language then this book might be just what you have been looking for but you need to know exactly what it is all about to make a decision.
This is a book that stirs a controversy. The big problem is that it is a beginner's book on assembly language. Now when you are a beginner you probably don't know exactly what assembly language is or quite what you should be learning and this book is about a dialect of assembly language called HLA - High Level Assembly - which was invented by the author to make teaching assembler easier. It is open source and can be downloaded for use with the book for both Windows and Linux.
This is a good idea but it also has its problems. After all if you want to learn assembler why learn HLA instead? The whole issue comes down to the question - is learning HLA the same as learning assembler? The best answer I can give is - both yes and no.
The key things that make assembler different from a high-level language, even a low-level, high-level language such as C, is that in assembler you are thinking in terms of the machine's architecture. You are writing programs that make use of registers, addressing modes, raw memory locations and the operations that the machine supports directly in hardware.
In this respect both the book and the language are indeed about assembler. However you might not think it from the opening chapter. This introduces you to HLA in the time honoured way of writing a Hello World program. In this case it reads:
"Hello World of Assembly Language",nl );
This looks a lot like a C program doing the same job and there is no sign of a register or memory location in sight! This isn't unreasonable as the same sort of introductory program could have been written using almost any more traditional assembler - as long as it was a macro assembler. HLA is really just a well developed macro assembler designed to make assembly language programming easier. You can, if you want to, write the same program using nothing but pure x86 instructions but the result is rather longer and much more difficult for a beginner to understand. But clearly if you are going to be writing programs in the style of the "hello world" then you aren't going to learn much that is low level.
Chapter One goes on to introduce you to the architecture of the x86 family - registers, memory and some basic instructions. From here the book continues to dig deep into low level ideas - data representation, memory access, variables, procedures, arithmetic and so on. All of this is done by explaining the basic principles and using higher level control structures to make the overall programs simpler. That is assembly language proper doesn't has if statements, and do loops, It just has conditional jumps and you have to use these to build the more familiar control structures. Chapter Seven finally gets around to explaining how these work but to be honest - once you have seen them you can more or less ignore them. Primitive jump style control is a feature of assembler but it isn't core to making use of it. Most experienced assembly language programmers will be using higher level constructs provided as macros or language extensions.
The rest of the book goes into advanced arithmetic, macros, bit manipulation, string operations, and the final chapter deals with object oriented assembly language programming - something that most people don't even know is possible. Object-oriented program is more a state of mind than something that a language provides and it is possible in almost any language.
So at the end of the day does the book teach you assembler?
No it teaches you HLA which even though it is just an elaboration on standard x86 assembler isn't actually x86 assembler as used by most assembly language programmers. They tend to use tools such as MASM (Microsoft Macro Assembler) which is available as a free download and can be used with C++ Express. If you learn how to program in assembler using HLA then using MASM or any x86 assembler should represent a minor change. However you probably will find it irritating that you don't have the friendly features that make HLA easier to use than raw assembler. HLA can also cross compile to MASM and a number of other popular assemblers.
It is clear that the book should be called The Art of HLA Assembly Language and if you really want a pure x86 assembly language approach then you will find this book unsuitable. On the other hand if you are a beginner and want to find your way into lower level programming and gain an understanding of how a machine's hardware works then this is a good way to get into things. However after you have finished the book you will still have a long way to go if your aim is to do anything with assembly language. Most assembly language programs do something with hardware or with the deeper parts of the operating system and this particular book tells you nothing about these topics.
So as long as you accept HLA as a suitable macro assembler to learn x86 architecture and machine language with then this book is highly recommended. But if you are an assembly language puritan and want a non-macro assembler approach that is as close to the op-codes as possible then look for another book.