Linux Assembly HOWTO

Version 0.7

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1; with no Invariant Sections, with no Front-Cover Texts, and no Back-Cover texts.

$Date: 2015-01-24 13:46:03 +0100 (Sat, 24 Jan 2015) $

Abstract

This is the Linux Assembly HOWTO, version 0.7 This document describes how to program in assembly language using free programming tools, focusing on development for or from the Linux Operating System, mostly on IA-32 (i386) platform. Included material may or may not be applicable to other hardware and/or software platforms.


Table of Contents

1. Introduction
2. Do you need assembly?
Pros and Cons
The advantages of Assembly
The disadvantages of Assembly
Assessment
How to NOT use Assembly
General procedure to achieve efficient code
Languages with optimizing compilers
General procedure to speed your code up
Inspecting compiler-generated code
Linux and assembly
3. Assemblers
GCC Inline Assembly
Where to find GCC
Where to find docs for GCC Inline Asm
Invoking GCC to build proper inline assembly code
Macro support
GAS
Where to find it
What is this AT&T syntax
Intel syntax
16-bit mode
Macro support
NASM
Where to find NASM
What it does
Other Assemblers
AS86
YASM
FASM
OSIMPA (SHASM)
AASM
TDASM
HLA
TALC
Free Pascal
Win32Forth assembler
Terse
Non-free and/or Non-32bit x86 assemblers
4. Metaprogramming
External filters
CPP
M4
Macroprocessing with your own filter
Metaprogramming
Backends from compilers
The New-Jersey Machine-Code Toolkit
TUNES
5. Calling conventions
Linux
Linking to GCC
ELF vs a.out problems
Direct Linux syscalls
Hardware I/O under Linux
Accessing 16-bit drivers from Linux/i386
DOS and Windows
Your own OS
6. Quick start
Introduction
Tools you need
Hello, world!
Program layout
NASM (hello.asm)
GAS (hello.S)
Building an executable
Producing object code
Producing executable
MIPS Example
7. Resources
8. Frequently Asked Questions
A. History
B. Acknowledgements
C. Endorsements
D. GNU Free Documentation License