Open-source project
pkivolowitz/asm_book avatar
pkivolowitz/asm_book

asm_book: a capital S decides whether the C preprocessor ever runs

A book teaching assembly language programming on the ARM 64 bit ISA. Along the way, good programming practices and insights into code development are offered which apply directly to higher level languages.

3,351 stars185 forksAssemblyNOASSERTION

At a glance

What is it?
This is a free textbook on 64 bit ARM assembly that assumes you already write C, and its most useful material is mechanical: which tool runs when, why it calls the C runtime instead of the kernel, and what the file extension has to do with the preprocessor. The front matter spells those out in the order a beginner hits them, with two small typos left in place.
Who is it for?
asm_book earns its place for anyone moving from C down to the instruction set, because the bridge it builds is the calling convention and the build chain rather than the instruction catalogue, and those are the two things a compiler has been hiding from you. Three things to check before you plan a course or a reading schedule around it.
Can I use it commercially?
Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
Is it still maintained?
Activity is slowing. The repository last received commits 7 months ago.
What is it written in?
Mainly Assembly, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 24, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • pkivolowitz/asm_book3,351 ★ · +17
Star history
Repository2026-09-242026-11-24
pkivolowitz/asm_book3.3k3.4k

17 Stars in the last 61 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

The book starts from C and walks backwards toward the instruction set

The premise is stated in the first paragraph and it narrows the audience sharply. What makes the introduction gentle is that it assumes the reader is already comfortable with C or C++, and that assumed knowledge is used to bridge backwards toward the low-level instruction set architecture rather than forwards from it.

The front matter repeats the assumption in plainer terms: if you are already familiar with C, or with languages descended from it such as C++, the book begins with what you already know. Later chapters go into the corners and recesses of the ARM V8 instruction set, aimed at readers who want to master the instruction set of 64 bit ARM processors. So the shape is a book with two audiences in sequence, one being carried by familiarity and the other by the depth of the later sections.

Two practical notes come with it. The book says outright that it can be used in courses covering assembly language, without qualification, and the repository is organised in numbered section directories rather than by chapter file, which is the arrangement to look for when you want to see how much of the plan exists.

Portability across macOS and Linux is handled by macros, not by the text

Assembly is unusually sensitive to its host, and the book names that as a fact rather than a difficulty. The hardware architecture plays the main role and the host operating environment plays an outsized one, and a calling convention is defined as how functions are called and how parameters are passed. Two systems with the same instruction set can disagree about all of that.

The history of this book is the history of the problem. It originally taught only the ARM Linux conventions. Over time a suite of macros was developed to make code easier to write for either macOS or Linux, and that suite lives in its own directory with documentation of its own, linked from the front matter. A separate chapter covers Apple Silicon assembly language programming.

So the portability story is a layer above the language: you write the dialect the book teaches and let the macros absorb the convention differences. Anyone porting code should read that macros directory rather than assuming the examples travel unchanged, because the alternative is to discover the difference in a debugger.

The book calls the C runtime instead of the kernel, and gives the reason

One design decision shapes most of the examples. Rather than making operating system system calls directly, the code calls functions from the C runtime. The example given is `write`, which the text contrasts with the operating system call of the same name: the version being called is a wrapper built into the C runtime, and that wrapper handles the lower-level details of performing the actual system call. A linked chapter covers what happens inside those wrappers.

The reason given is portability. Differences between distributions and between architectures are masked by going through the wrappers, so code written this way is more portable than code that issues system calls directly. That is a real argument and it is also a trade, because you give up the ability to see the actual syscall at the boundary and inherit whatever the runtime does instead.

For a reader arriving from C this is the least surprising choice available, since it is the same path a C program takes. It is worth knowing where the book makes the choice for you, because a reader who later wants to write a syscall by hand will find no example of one in these chapters.

gcc is an umbrella over four steps, and the file lists what it invokes

The book spends a page dismantling the word compiler, because it uses gcc to assemble code and that needs explaining. What people call the compiler is an umbrella covering four steps: a preprocessor that acts on `#` commands such as `#include`, the actual compiler that turns high level languages into assembly, the assembler that turns assembly into machine code not yet ready to run, and finally the linker, which combines object files with library files, statically linked on Linux and Windows and dynamically linked as shared objects or dynamic libraries.

Then it shows the actual program list. On Ubuntu running on ARM, driving gcc to compile a program calls five of them:

text
/usr/bin/cpp
/usr/lib/gcc/aarch64-linux-gnu/11/cc1
/usr/bin/as
/usr/lib/gcc/aarch64-linux-gnu/11/collect2 which is...
/usr/bin/ld

Note the fourth line. The entry has an editorial gloss attached inside the block, unfinished, so this is a hand-marked listing rather than captured output. And the sentence that follows it begins explaining that cpp is the C preprocessor and is a general tool used by other languages as well, then stops in the middle of a parenthesis. The link to a video explaining the same process is offered alongside.

A capital S is the whole preprocessor rule, and one fence ends with a colon

The preprocessor detail that matters in practice is the file extension. The rule is that gcc will invoke the C preprocessor if your assembly file ends in a capital S, and it may or may not be invoked for a lowercase s or any other extension depending on the system. The book states it as a pair of commands so the difference is unmissable: `gcc main.s` will not go through the preprocessor, while `gcc main.S` will.

That is the mechanism behind a lot of confusion for newcomers, since a file can be assembled perfectly and still lose its `#include` lines without an error.

Three build recipes are given. Everything at once, `gcc main.c asm.S`, which writes a.out and removes the intermediate files without showing them. Modularly, compiling each file with `-c` and then linking the `.o` files, which leaves them on disk. And the assembly-only case, `gcc main.S`, for when main is implemented in assembly and the file is self-contained. For debugging, the same command with `-g`, because without it the debugger may not operate properly. The snippet for that last one is printed with a trailing colon after the command, which is a typo in the file rather than shell syntax.

ARM's naming is called horrid, so the book fixes two names and moves on

There is a short section in the front matter about vocabulary, and it is unusually blunt. The book says that as commendable as the ARM designs are, the naming conventions for their intellectual properties are horrid, and that in this text AARCH64 and ARM V8 are treated as synonyms for the 64 bit ARM instruction set architecture.

The stated reason for that decision is documentation search. With so many versions, so many names for the same thing and so much documentation in general, finding the right page on the vendor's site is described as maddening. The book responds by fixing the vocabulary internally and linking only where a page is germane, with one main instruction set page linked as an example of what it means by a page being findable.

That is a small thing to build a section around and a useful one for a reader who has just spent an afternoon looking for the right manual. The chapter titles use the fixed names consistently, so a reader who arrives from vendor documentation has to make the same substitution once.

Three section directories, a not-written-yet document, and everything kept in two formats

The tree shows how a book in progress is laid out. There are three section directories, section_1, section_2 and section_3, plus a document named not_written_yet that exists in both a Markdown file and a PDF. That pairing is the clearest signal in the repository about how much of the plan is written, and anyone assigning reading should check it first.

The same pattern runs through the rest of the tree. The README, the license and the not-written-yet document each exist as both a Markdown file and a PDF, and there are two shell scripts at the top level, counts.bash and make_all_pdf.bash, alongside a scripts directory and a python directory, which together account for the generated artefacts.

Content directories sit alongside them: macros for the portability layer, more for the additional chapters, debugging, projects and reference_material. A markdownlint configuration and a .vscode directory indicate the editing setup.

One licensing detail to note rather than assume. GitHub records no recognised license identifier for this repository, while the tree carries both a LICENSE.md and a LICENSE.pdf, and the file itself says nothing about terms. What applies is what those two files say, so read them before reusing anything.

Editorial conclusion

asm_book earns its place for anyone moving from C down to the instruction set, because the bridge it builds is the calling convention and the build chain rather than the instruction catalogue, and those are the two things a compiler has been hiding from you. Three things to check before you plan a course or a reading schedule around it. The audience assumption is strict, since the book starts from knowledge of C and will not teach you programming from the beginning. Portability is handled by macros rather than by the book itself, so read the macros documentation before porting anything to macOS or Apple Silicon. And the text is incomplete by design in one respect, since a not-written-yet document and only three section directories are in the tree, so check which chapters exist before assigning a reading path. The tooling advice is the part most likely to save you an afternoon.

Frequently asked questions

Who is the asm_book textbook written for?

Readers already comfortable with C or a language descended from it such as C++. The book begins with what those readers already know and bridges backwards toward the instruction set, with later chapters going deeper into the ARM V8 instruction set of the 64 bit ARM processors.

Can the asm_book be used to teach a course?

The front matter answers that directly and without qualification: yes, absolutely, it can be used in courses covering assembly language.

Which platforms do the asm_book examples cover?

The book originally taught only the ARM Linux calling conventions, and later added a suite of macros so code can be written for either macOS or Linux, with a separate chapter on Apple Silicon assembly language programming.

What tools does asm_book need on Linux and macOS?

On Linux, build-essential and gdb from apt, installed with sudo apt update followed by sudo apt install build-essential gdb. On a Mac, xcode-select --install, where the book notes gdb is replaced by lldb.

How does asm_book explain compiling assembly language?

It treats the compiler as an umbrella over four steps: a preprocessor, the actual compiler, the assembler and the linker. That is why gcc is used to assemble, and why a source file ending in a capital S is needed for the C preprocessor to run on it.

Official sources

  1. Issues
  2. pkivolowitz/asm_book on GitHub
  3. README
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/pkivolowitz-asm-book.svg)](https://hysenlabs.com/projects/pkivolowitz-asm-book)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/pkivolowitz-asm-book.svg)](https://hysenlabs.com/projects/pkivolowitz-asm-book)

Was this useful?