Confessions of a Code Addict

Confessions of a Code Addict

Share this post

Confessions of a Code Addict
Confessions of a Code Addict
Building (and Breaking) Your First X86 Assembly Program
Copy link
Facebook
Email
Notes
More

Building (and Breaking) Your First X86 Assembly Program

We build a minimal X86 assembly program, run it… and hit a crash. But that crash is exactly what makes this program worth writing.

Abhinav Upadhyay's avatar
Abhinav Upadhyay
May 16, 2025
∙ Paid
6

Share this post

Confessions of a Code Addict
Confessions of a Code Addict
Building (and Breaking) Your First X86 Assembly Program
Copy link
Facebook
Email
Notes
More
Share

Introduction

Recap from the previous article: In the last couple of articles, we built a simple but complete mental model of how a basic computer executes instructions. We explored how an ALU performs arithmetic operations, how registers serve as fast-access storage, and how the control unit fetches and executes instructions stored in memory. We also introduced the structure of assembly programs, the use of labels, and how data and instructions are laid out in different sections like .text and .data. That article provided the conceptual foundation we need to now dive into real X86-64 assembly code.

This article is part of my series on the basics of X86-64 assembly programming. Until now, we have been working mostly with ideas. We talked about what it means for a computer to execute a program, how computation is carried out by hardware, and how memory is laid out to store data and instructions. We have seen snippets of assembly here and there, but we haven’t written a full program yet. That changes now.

In this article, we will write our first complete (well, almost) assembly program. It won’t do anything exciting, but that’s the point. Like “Hello, world” in high-level languages, this program is just a vehicle to help us understand the mechanics of how an assembly program is written, assembled, linked, and executed. Along the way, we’ll revisit some of the concepts we’ve discussed before and see how they manifest in actual code.

If you haven’t read the previous articles in this series, here’s what you have missed:

Seeing the Matrix: A First-Principles Approach to Computer Architecture

Seeing the Matrix: A First-Principles Approach to Computer Architecture

Abhinav Upadhyay
·
Apr 5
Read full story
The System-Level Foundation of Assembly

The System-Level Foundation of Assembly

Abhinav Upadhyay
·
May 5
Read full story
Binary Arithmetic and Bitwise Operations for Systems Programming

Binary Arithmetic and Bitwise Operations for Systems Programming

Abhinav Upadhyay
·
Apr 12
Read full story

This article is part of a paid subscriber series.
If you’re enjoying the content, please consider upgrading to a paid plan to unlock the rest of this series. Paid subscribers also get access to recordings of past live sessions, early and discounted access to courses and books, and more.

Alternatively, you can purchase an ebook version of this series. (If you're already a paid subscriber, email me for a discounted link.)

I Want the PDF

This post is for paid subscribers

Already a paid subscriber? Sign in
© 2025 Abhinav Upadhyay
Publisher Privacy ∙ Publisher Terms
Substack
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share

Copy link
Facebook
Email
Notes
More