This work is created by Perry Kivolowitz, Professor and Chair of Computer Science at Carthage College. It is copyright © 2021 and may be freely shared for educational purposes.
These documents are designed for readers who are familiar with C
or C++
. Each
document bridges the reader's understanding of the higher level language to the
corresponding assembly language.
The AARCH64
ISA is used. That is, the assembly language used is that of the 64 bit ARM processor.
Assembly language text books typically cover the MIPS ISA because it has been around forever and isn't x86. We consider the MIPS processor as having 1.5 feet in the dustbin of history.
A few texts cover the x86. We consider the x86 an abominable mass of poodles jumping through hoops to allow the modern to coexist with the ancient. Poodles jumping through hoops is best viewed on youtube, not in a text book.
The ARM V8 ISA (AARCH64) is current and reasonable.
Linux calling conventions
are used. That is, the assembly language is designed to be run on Linux machines. Even though Macintosh M1 machines are AARCH64
, the conventions they use are specific to the Mac - big surprise.
Some might argue this makes a strange choice of initial chapters. To many, Part 2's material will make more sense to come first. Our choice of putting this material first is born from the desire to bridge the higher level language concepts you already know to the underlying technology. Then we'll go into details hopefully having broken through the common fear of assembly language.
Chapter | Description |
---|---|
Hello World | Demonstrates how close C is to assembly language |
if | Demonstrates implementation of both if and if / else |
while | Demonstrates implementation of a while loop |
for | Demonstrates implementation of a for loop |
Function Calls and Returns | Demonstrates implementation of function calls and returns |
struct | Demonstrates use of struct and by extension, class |
Braces | Focuses on how braces translate into assembly language |
Interop | Calling assembly language from C and C++ |
static and Global Variables |
How static and global variables are defined - also an annotated gdb session |
library functions | Calling C library functions from assembly language |
All the action happens in the registers. Bottom line is that the variables you are accustomed to using in a higher level language are artificial constructs layered on top of the processor's registers. Understanding this is key to understanding assembly language programming.
Chapter | Description |
---|---|
Concept of Registers | What are registers? |
Registers Versus Variables | Thinking differently about your variables |
What Registers Must be Backed Up and Why | Constraints placed on register use |
ldr and Friends |
Review and amplification of the ldr instructions and by extension, the str instructions - with a number of programming examples |
Register Widths | Demonstrated with examples and a gdb session plus a discussion on endianness |
Floating Point Registers | Not written |
Scratch Registers | Not written |
Push and Pop of Registers | Not written |
Here is a first start on floating point chapters.
- Loading 4 floats from memory.
- A NEON (SIMD) operation on all four simultaneously.
- Up-conversion from single to double precision.
- Passing floats to a "C" function (printf in this case)