Kick off your book project, get started with GhostAI, get better at marketing, or spend the day doing all three! Free live workshops on Zoom. Saturday, June 27, 2026.

Leanpub Header

Skip to main content

Assembly Arithmetic Algorithms-Linux

32-bit Linux Edition

This book is 70% completeLast updated on 2026-06-25
Personally, I think that the Assembly system of conditional jumps makes a lot of sense. Other programming languages such as BASIC and C have "goto" statements that work like this. For example, `if(eax<ebx){goto less;}`. Modern programming languages tend to discourage the use of goto or not allow it at all. However, these languages still use jumps I have described in this section because it is…

Minimum price

$5.00

$10.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
About

About

About the Book

This book is meant for both new programmers who want to know more about how computers work and also experienced programmers who want a little bit more control over their programs than C or C++ compilers allow. All programs in this book are written for the Linux Operating System on Intel machines. There are some C programs included to aid in understanding what the Assembly programs do. If you enjoyed the DOS edition of this book, which was previously published, then you will probably like this one even more, especially if the Software Freedom and Privacy that Linux provides is important to you.

This book is not just a rewrite of the DOS book. Most of it is written from scratch with a special focus on the POSIX System Calls known as exit, read, write, open, close, and lseek. Learning these calls can allow you to write almost any Linux console application. Even if you don't become an Assembly master, you can still use much of the same information and efficiency when writing code in higher-level languages after coming back with a greater understanding of pointers, conditional loops, and numbers in bases like Binary, Hexadecimal, and Octal.

Right now, this book is still a work in progress, but those who purchase it now will still have access to future updates, and I also ask them to give me feedback on things they would like me to include. I fight for the users and wish to empower people to write the smallest and fastest command-line utilities possible.

Author

About the Author

Contents

Table of Contents

Assembly Arithmetic Algorithms

Preface

Introduction

  1. Required Knowledge
  2. Low Level
  3. Why Linux?

Chapter 1: The First Program

  1. Assemble with FASM
  2. makefile for FASM users
  3. Assemble with NASM
  4. Interrupt FAQ
  5. The General Purpose Registers

Chapter 2: Assembler Choices

  1. chaste-elf-32.nasm
  2. main.asm
  3. NASM makefile
  4. GNU Assembler
  5. main.s
  6. GAS makefile

Chapter 3: Linux System Calls

  1. C Hello World with Write System Call
  2. FASM Hello World with Write System Call

Chapter 4: putstring

  1. C unistd putstring
  2. C stdlib putstring
  3. Assembly putstring
  4. Pointers vs Integers

Chapter 5: intstr and putint

  1. C putint
  2. FASM putint
  3. Side rant on condition jumps
  4. How the intstr function works
  5. Digit Character Table

Chapter 6: Chastity’s Intel Assembly Reference

  1. mov
  2. add
  3. sub
  4. mul
  5. div
  6. cmp
  7. jmp
  8. Conditional Jumps Table
  9. push/pop
  10. Take it slow

Chapter 7: Open and Close System Calls

  1. FASM Create a New File
  2. Syscall Reference
  3. FASM Open Existing File

Chapter 8: User Input

  1. FASM Keyboard Input
  2. FASM Command Line Arguments
  3. What is a Command Line Argument?
  4. Arguments vs Keyboard Input

Chapter 9: Numbers and Strings

  1. Why is this important?
  2. strint function
  3. FASM Add Arguments

Chapter 10: Stack Based Calculator

  1. FASM chastack

Chapter 11 A Note on Portability

  1. Difference between 32 and 64 bit modes
  2. Converting 32 to 64 bit mode
  3. Chastity’s Linux System Call Table
  4. 32-bit Intel System Calls for Linux
  5. 64-bit Intel System Calls for Linux
  6. Actual Conversion Example
  7. FASM chastack 64-bit
  8. chastelib64.asm
  9. Pros and Cons of Conversion to 64 Bits

Chapter 12: The Lseek System Call

  1. FASM cat upper
  2. How it works
  3. File Open Modes and Security

chapter 13 chastext

  1. FASM chastext
  2. seashell.txt
  3. chastext test script
  4. How does chastext work?
  5. Fun Fact About Chastext

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub