Home DEVELOPER Learn Assembler the fun way | Heise Online

Learn Assembler the fun way | Heise Online

0


The time has finally come – today I present to you a book I’ve been eagerly and excitedly waiting to read for months. The topic of the book is a bit unusual for the year 2024, as it is an introduction to modern assembly language programming. Now you may be wondering why you should bother with assembler, but more about that in a moment. Above all, my main concern in this blog post is the question of whether I think the book is worth reading. Let’s begin!

Advertisement


The name of the book is “Introduction to Modern Assembly Language Programming” and its subtitle is “Learning RISC-V in a playful and streamlined way”. It was written by Scott W. Stevenson and will be published by Deepunkt-Verlag in July 2024. (Editor’s note: A publisher of the Heise Group) appeared. The publisher was kind enough to provide me with a review copy free of charge. However, it is important for us to emphasize that my opinion in this blog post does not agree with the publisher. This is my personal and honest assessment and I receive no compensation for the review. It is important for us to disclose this because reviews must be trustworthy, and that can only be guaranteed if I can freely say what I like and what I don’t. This is just a brief introduction.

Before we dive into the book, perhaps we should first ask: Why should we be concerned about assembly language programming in 2024? Isn’t there something more important? The author asks this question in the introduction:

“A modern book about assembly language programming, what’s the point of this?”

The author knows that the subject definitely needs explaining. He writes that, on the one hand, there are people who are forced to deal with assembler during their studies. On the other hand, there are people who believe that understanding assembler will lead to a better understanding of computers. Both are valid reasons to read the book, but: The book is written primarily for the third target group – namely for those who enjoy the intrinsics and out of curiosity and a thirst for knowledge want to understand how things work under the hood. I think this is a beautiful and honest description that really resonates with me.

Recommended editorial content

With your consent, an external YouTube video (Google Ireland Ltd) will be loaded here.

Visual Studio Code 1.92 offers the choice of a default browser

Always load YouTube videos

Introduction to Modern Assembly Programming (by Scott W. Stevenson)

In my opinion, everything you learn does not always have to be of direct benefit. At least I really enjoy dealing with some things for their own sake, and for me zeros and ones are definitely one of them. In this regard, the book may not directly advance your career, but it can appeal to your intellectual instincts and perhaps even broaden your horizons. Nonetheless, I also believe that a certain understanding of assembler leads to a better understanding of the machine we all deal with every day.

I myself tried to learn x86 assembler once, many years ago. So I have some of the basics, but I’ve never really gone in depth. However, I have a lot of respect when someone actually knows assembler. We had a developer as a guest on one of our live streams in March, who shared this with me Analyzed the assembler source code of the computer game “Prince of Persia”.. More specifically, he analyzed the code and I asked questions about it with interest. I found it very exciting, and this book follows that completely in terms of content. In other words, if you watched the live stream and liked it, the book should also interest you and suit your interests.

Now finally on the book: it has a little over 250 pages (so it is quite concise) and is divided into 25 chapters, which are expanded into five parts. The first part initially covers a number of basic terms and fundamental concepts: how do negative numbers work in the binary system? What is a register? What is the difference between CPU and ALU? What is CISC, what is RISC, what is opcode, what is mnemonic?

The first 70 or so pages are about creating a common language and building a basic understanding of the level at which you work with assembler, but with which you do not often come into contact in everyday life. I knew a lot of it from years ago, but I still found it exciting to read it again because it was a good overview. It highlights well that although assembler is basically the same everywhere, the concrete implementation depends heavily on the processor architecture and the corresponding instruction set. The book covers the open RISC-V standard, but also uses examples to show how things are solved on other architectures. It explains well that you work with assembler at two levels, namely an abstract-conceptual level and a technical-concrete level, which differ from processor to processor.

The second part starts with an overview of the individual modules of RISC-V. This includes the available registers, word sizes, addressing types and then, above all, the actual instruction set. Here the various commands are presented and explained relatively quickly, starting from simple tasks such as loading and saving data, through to the calculation of comparisons, conditions and loops. Attention is also paid to pseudo-commands and special cases, as well as the internal structure of commands. This part goes deeper into the subject matter, and this is both the strength and weakness of the book: on the one hand, you get a complete overview of the RISC-V commands, but on the other hand, this section is more of a reference than a textbook. You read it but don’t practice it, which means you have to go back to the book later and keep jumping back and forth.

Part three is about deepening what you have learned so far by putting together basic building blocks to create larger entities. Of course, you can do this in a simple way as well, but it is advisable to learn from more experienced developers. It covers topics such as:

  • How do I write efficient code?
  • How do I structure the comparisons and branches?
  • How do I write a loop?
  • How do I apply multiplication and division?
  • How do I integrate system calls into assembler and interact with the standard C library?

I found the order of the chapters in this part a bit difficult, as it seems a bit arbitrary. Overall, it still fits, as ultimately it is a mix of various best practices that have no natural order.

This means that 85 to 90 percent of the book has already been read, but there are two more parts: Part four is about specific projects. However, this part includes only 25 pages for at least two projects. In fact, for me this is the biggest weakness of the book: practice has been neglected. For a book with the subtitle “Learning RISC-V in a playful and streamlined way”, I miss the playful aspect. The first 225 pages practically explain the grammar and vocabulary of a new foreign language, but by the end you are not even able to say a simple sentence. I think this is a shame, I would have liked a more practical structure. Because the book has a lot of potential, and I think assembler is an exciting subject, but I want to learn it not only theoretically, but also to be able to apply it practically.

And so that we don’t misunderstand each other here: the book is not bad, but as a textbook it has only limited use. With a detailed section on clean programming in assembly language, it’s more like a reference for reference. I just expected something different based on the title.

Finally, part five comprises only the last ten pages. It is about common mistakes, good style and further links. In this respect it is not a real fifth part, but rather an appendix.

What’s left? Anyone who is interested in assembler, wants to know how a computer and especially a processor works internally, and anyone who is not afraid to tackle low-level topics and has a playful sense of humor can certainly have a lot of fun with the book. If you would like to learn a bit more about assembler for the reasons mentioned, but would rather be given more guidance, then this book might not be quite right for you. Nonetheless, it is a good book.


(May)

C++20: Detecting compiler functions with feature testing macros

NO COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Exit mobile version