Assembly x64 Programming

Author: Mike McGrath
Publisher: Easy Steps
Date: November 2021
Pages: 192
ISBN: 978-1840789522
Print: 1840789522
Kindle: ‎B09FTNN4P5
Audience: Developers wanting to learn assembler
Rating: 5
Reviewer: Harry Fairhead
Assembler, why would you want to learn that!

I've been writing assembler for various machines for a long time but over the last few years it has become increasingly a rare event. The reason is simply that whenever I try to do better than my current compiler I find I can't. Modern optimizing compilers seem to beat hand-crafted assembler a lot of the time and even when they don't the gains aren't worth the effort.

Writing assembler isn't a guarantee of the fastest code - writing in C is nearly always as fast and often faster.

So why bother?

There are two good reasons for learning assembler. The first is that occasionally you might want to access hardware that isn't well supported and assembler is the most direct way of doing the job. The second is simply that you really want to understand how computers work - and for me this is the best reason. Even when I program in C, I often think in terms of what the machine is doing and that means I need to know assembler.


Of course, assembly language is specific to each machine and this book deals with x64 language which is found in most modern PCs. If you are looking for Arm, or one of the many micro-controller assembly languages, this isn't going to help you. It is also more oriented toward a PC running Windows than anything else, but the skill would transfer to Linux.

Another problem with x64 assembler is that there is more than one implementation and this is a nuisance. In this book you will encounter the dialect used by MASM - the Microsoft Assembler. To use this you have to install Visual Studio Community Edition and configure it. Thankfully this isn't difficult but it is still the most time-consuming and tortuous step of all. Unfortunately there is no standard template for an assembly language program in Visual Studio and so your first task is to create one. This is unavoidable, but it does represent a hurdle you have to get over before you can start assembly language programming.

From here you learn assembler in a set of small, mostly self-contained steps:

  • Beginning Basics
  • Getting Started
  • Performing Arithmetic
  • Directing Flow
  • Addressing Options
  • Handling Strings
  • Building Blocks
  • Expanding Macros
  • Floating Points
  • Calling Windows
  • Incorporating Code

The approach is very condensed and this is quite a slim book so it isn't much more than an introduction, but even so it goes quite a long way. 

To really understand assembler you have to have good grasp of the hardware and while the book does start off with an examination of a typical architecture, number bases and so on, it doesn't really tell you enough - it would be a much bigger book if it did. You either need to know hardware or you need to be prepared to look things up. It then moves on to start to program in assembler and as long as you are familiar with another language you should be able to follow, even if you start to wonder why you have to do things in such a strange way. For example, why can't I add a memory location to another without using a register? I also think that the coverage of addressing modes comes a bit late and without making it seem as important as it is - addressing modes are central to using assembler.

Most of the examples are small standalone tasks that demonstrate how an instruction works but don't really show you how an entire assembly language program works. Later we discover how to interface with subroutines written in other language and this is probably where you will use assembler in the future - if you ever actually use it. Calling the Windows API and using vector architecture for floating point arithmetic are also covered and are generally considered to be advanced topics. If you are the type of reader who wants complete and realistic examples then this book isn't for you. Personally I think a complete working assembler program would be amazingly boring and very difficult to get into. Small examples are best.

Overall if you already program and have always wanted to try your hand at assembler then this is a good place to start. It won't turn you into an expert, but it will get you started and once started who knows where you will end up.



To keep up with our coverage of books for programmers, follow @bookwatchiprog on Twitter or subscribe to I Programmer's Books RSS feed for each day's new addition to Book Watch and for new reviews.


Algorithms: Absolute Beginner's Guide

Author: Kirupa Chinnathambi
Publisher: Addison-Wesley
Date: November 2023
Pages: 416
ISBN: 978-0138222291
Print: 0138222290
Kindle: B0CCTZ37DQ
Audience: General
Rating: 4.5
Reviewer: Kay Ewbank

Subtitled 'a practical introduction to data structures and algorithms in JavaScript', this book is split into tw [ ... ]

Foundational Python For Data Science

Author: Kennedy Behrman
Publisher: Pearson
ISBN: 978-0136624356
Print: 0136624359
Kindle: B095Y6G2QV
Audience: Data scientists
Rating: 4.5
Reviewer: Kay Ewbank

This book sets out to be a simple introduction to Python, specifically how to use it to work with data.

More Reviews





Last Updated ( Wednesday, 01 December 2021 )