Resources

projects:
; various UNIX projects written in assembly language
; of course all of them feature extremely small size
; if you’re looking for source code and examples, here they are

name short description platform OS assembler
asmutils miscellaneous utilities, small libc IA32 Linux, *BSD (Unixware, Solaris, AtheOS, BeOS) nasm
libASM assembly library (lots of various routines) IA32 Linux nasm
e3 WordStar-like text editor IA32 Linux, *BSD, AtheOS, BeOS, Win32 nasm
ec64 Commodore C64 emulator IA32 Linux nasm
lib4th Forth kernel implemented as shared library IA32 Linux nasm
Tiny Programs tiny Linux executables IA32 Linux nasm
Softer Orange terminal emulator IA32 Linux nasm
ta traffic accounting daemon IA32 Linux nasm
cpuburn CPU loading utilities IA32 Linux, FreeBSD gas
H3sm 3-stack Forth-like language
(and other stuff from Rick Hohensee)
IA32 Linux gas
F4 x86 Linux fig-Forth IA32 Linux gas
eforth eforth converted to nasm/asmutils IA32 Linux nasm
eforth original Linux eforth IA32 Linux gas
ASMIX several command-line utilities IA32, PPC, SPARC, PDP11 Linux, FreeBSD, LynxOS, Solaris, Unixware, SunOS gas
Bizarre Source, Corp several system utilities IA32 Linux gas
VMW Assembly tricks linux_logo and other ASCII tricks in assembly IA32, IA64, Alpha, PPC, SPARC, S390 Linux gas
acid small textmode intro IA32, ARM Linux nasm, gas
asm-toys few utilities IA32 Linux gas
smallutils few small utils in assembly and C IA32, SPARC Linux gas

There are quite a lot of mixed C-assembly projects, like GNU MP library, ATLAS/BLAS, OpenGUI, FreeAmp, just to name few. Also see source code of your kernel and libc. All this will provide you examples of assembly programming on different hardware platforms.

documentation:
; Various documents on the topic
; Some of them are mustread

Linux Assembly HOWTO

List of Linux/i386 system calls, also this one and this one. Linux Kernel Internals provides useful information too,
read at least particular How System Calls Are Implemented on i386 Architecture? chapter.

Using the GNU Assembler ( gas manual )

; CPU manuals and assembly programming guides (also see this list)

IA-32 (x86): sandpile.org, x86.org, Intel, AMD, Cyrix, x86 bugs, optimization
x86-64: AMD x86-64(tm) technology
IA-64: Intel Itanium manuals, IA-64 Linux
ARM: ARM Assembler Programming
Alpha: Compaq Tru64 UNIX 5.1, Digital UNIX 4.0, other manuals, old Digital Documentation Library
SPARC: SPARC International Standard Documents Repository, Technical SPARC CPU Resources
PA-RISC: PA-RISC technical documentation
PPC: Beginners Guide to PowerPC Assembly Language, Introduction to assembly on the PowerPC
MIPS: MIPS Online Publications Library

; Executable formats

Current ELF draft

Older System V ABIs

Kickers of ELF

Programmer’s File Format Collection

; Books

The Art Of Assembly
by Randall Hyde. Classic book on x86 assembly programming, Windows and Linux (32bit) and DOS (16bit).

PC Assembly Language
by Paul Carter. 32bit protected mode programming, Windows and Linux (NASM).

Programming from the Ground Up
by Jonathan Bartlett. Introduction to programming based on Linux and assembly language (GAS).

Assembler for DOS, Windows and UNIX
by Sergey Zubkov. ISBN 5-89818-019-2, 637 pages, 1999. In Russian language.

Inner Loops : A Sourcebook for Fast 32-Bit Software Design
by Rick Booth. ISBN: 0201479605, 364 pages, 1997; Addison-Wesley Pub Co

Assembly Language Step-By-Step; Programming with DOS and Linux with CDROM
by Jeff Duntemann. ISBN: 0471375233, 612 pages, 2000; John Wiley & Sons

Linux Assembly Language Programming
by Bob Neveln. ISBN: 0130879401, 350 pages, 2000; Prentice Hall Computer Books

Linux Assembly
by Peter Berends. x86 assembly programming in Linux environment. In Dutch language.

Introduction to RISC Assembly Language Programming
by John Waldron. ISBN: 0201398281

SPARC Architecture, Assembly Language Programming, and C
by Richard Paul.

; Articles

Startup state of a Linux/i386 ELF binary

Self-modifying code under Linux

Using the framebuffer device under Linux

Using the audio device under Linux

Using the raw keyboard mode under Linux

Using Mode X via direct VGA access under Linux

Using virtual terminals under Linux

tutorials:
; If you’re new to UNIX assembly programming, this is where you begin

Introduction to UNIX assembly programming ( nasm; Linux, *BSD, BeOS )

Using Assembly Language in Linux ( AT&T and Intel syntax, gcc inline assembly )

Introductory Linux Assembler Tutorial ( gas and the Co )

Writing A Useful Program With NASM ( nasm )

Linux assembly tutorial ( gas, gdb )

Linux socket/network programming ( gas )

How do I write “Hello, world” in FreeBSD assembler? ( as )

FreeBSD Assembly Programming tutorial ( nasm )

Inline assembly for x86 in Linux ( gas and gcc inline assembly )

DJGPP QuickAsm Programming Guide ( gas and gcc inline assembly )

Brennan’s Guide to Inline Assembly ( gcc inline assembly )

Introduction to GCC Inline Asm ( gcc inline assembly )

SPARC assembly “Hello world” ( NetBSD, SunOS, Solaris )

GNOME application in IA32 assembly ( nasm, gcc )

A Whirlwind Tutorial on Creating Really Teensy ELF Executables for Linux

another tiny example illustrating a tiny ELF header ( nasm )

links:
; Links to somehow related projects

; tools

NASM x86 assembler with Intel syntax
FASM another promising x86 assembler with Intel syntax
OTCCELF tiny C compiler, generates a dynamically linked ELF file
ALD Assembly Language Debugger
BASTARD Bastard Disassembly Environment
DUDE Despotic Unix Debugging Engine
BIEW console hex viewer/editor with built-in disassembler
HTE viewer/editor/analyzer for text, binary, and executable files
UPX Ultimate Packer for eXecutables
Intel2gas converter between AT&T and Intel assembler syntax
A2I converter from AT&T to Intel assembler syntax
TA2AS converter from TASM to AT&T assembler syntax
SPARC ASM SPARC v8 assembler & disassembler
binutils as they are: gas, ld, ar, etc

; sites

Jan’s Linux & Assembler page various source code examples
H-Peter Recktenwald’s page “The Int80h page”
Karsten Scheibler’s page “Unused Inode”
G. Adam Stanislav’s page FreeBSD related material
Bruce Ediger’s page SPARC assembly related material
Michael Blomgren’s page
Assembly Programming Journal
Phrack Magazine

How To

Linux Assembly HOWTO is available in several formats, choose the one that suits you best.

Actually you can:

  • read it online
  • download compressed html tarball and read it offline
  • download compressed sgml source (DocBook DTD) and render it to whatever you want

You can get this HOWTO in other formats (like PDF, PostScript or plain text) from the LDP repository.

Just get all the HOWTOs (you need only the `LDP’ one), copy, for each format:

# cp LDP/h19* /wherever/documentation # cd /wherever/documentation;packages=’docbook docbook-dtd42′; \ for i in $packages; do (cd $i && zcat ../$i.gz >$i); done

This will produce all formats in ./<format>.

On Debian GNU/Linux you’ll also have to install docbook packages, but this will be handled automatically when you use dselect or aptitude programs.

For more info about DocBook installation check out http://www.debian.org .

The files are compressed using gzip program.

We’ll now present the HOWTO with screenshots, you can visit this page with any graphical browser or just ssh to your Linux machine and use lynx command with the -dump option:

# ipkg install xfonts-scalable # cd /usr/share/X11/fonts/truetype # wget http://linuxassembly.org/art.ttf # mkdir ttf # mv art.ttf ttf # ln -s ttf/art.ttf ./* -R && cp LDP/*html* ./ && cd .. && tar cfz linux-assembly-howto.tgz linux-assembly-howto/*

You need to have the X Window System installed on your machine.

You need also TrueType fonts support in your Linux installation, which can be obtained by installing xfonts-scalable package.

We’ll assume that you downloaded the linux-assembly-howto.tgz file in ~/Downloads directory and you uncompressed it in /usr/share/X11/fonts/truetype .

Here’s what you get when you use lynx command with the -dump option:

# cd # ls -lart total 968 drwxr-xr-x 11 root wheel 1024 Feb 16 00:55 LDP -rw-r–r– 1 jdike jdike 51644 Jun 7 2004 linux-assembly-howto.tgz -rw-r–r– 1 jdike jdike 493 Jan 28 2004 LDPLASTCHANGE -rwxr-xr-x 1 root wheel 1024 Feb 3 13:17 LICENSE -rw——- 1 jdike jdike 3088 Jul 29 2003 config.guess drwx—— 2 jdike jdike 512 Mar 12 22:09 fbset lrwxrwxrwx 1 root wheel 5 Mar 15 19:50 howto -> ../../doc/HOWTO -rw——- 1 root bin 63872 Aug 21 2002 install.sub drwx—— 2 root wheel 2048 Jun 16 02:05 info drwxr-xr-x 3 root wheel 2048 Mar 10 14:19 install drwx—— 2 jdike jdike 1024 Mar 9 02:10 linux.png -rw——- 1 root wheel 9216 Jan 27 2004 microemacs.css drwx—— 2 root wheel 512 Nov 7 2003 nano -rw——- 1 root wheel 5468850 Apr 3 12:45 new2dir lrwxrwxrwx 1 root wheel 4 May 30 22:59 sfd -> ../../doc/HOWTOs/Linux+IP+Tunneling+Over+SerialLine -rw——- 1 jdike jdike 8204 Jul 23 2002 spiped.html -rw——- 1 jdike jdike

Introduction to UNIX assembly programming

Introduction to UNIX assembly programming is available in several formats, choose the one that suits you best.

Actually you can:

  • read it online
  • download compressed html tarball and read it offline
  • download RTF file and read it or print it
  • download compressed sgml source (DocBook DTD) and render it to whatever you want

You can also download source and binary examples described in the document here.

The tarball is the largest file (about 1.5 MB in size).

If you don’t want to download it but still read it online, here are some frame-based links that expose all the examples in separate frames:

This document contains many screenshots that help understand what’s going on. You can also see them when reading the text online by clicking on the images. The docbook source comes with a Makefile that will compile all your favorite formats from just one source file. Just copy and paste the following lines into a console window:      cd doc       make html pdf xps This would compile HTML, PDF and XPS documents from single XML source file for UNIX systems For Windows users there is a precompiled binary that can be used as a command-line tool to render XML source into whatever you want. Just copy and paste these lines into a console window:      cd doc      make winhelp

UNIX assembly programming pdf manual is available in several formats, choose the one that suits you best.

Actually you can:

read it online

download pdf file and read it or print it

You can also download source and binary examples described in the document here. The pdf file is about 1.5 MB in size so it’s a bit bigger than other format files from this article. Here are some frame-based links that expose all the examples at once: This document contains many screenshots for better understanding how things work.

Asmutils

Asmutils is a set of Linux utilities that make the installation and use of an advanced Asynchronous File System (A file system with asynchronous I/O) significantly easier.

Asmutils consists of:  *   asmoperfs: tool to manage per-thread or application specific POSIX async per-operation mode;  *   asmon: daemon for monitoring asynchronous I/O usage by applications;  *   asmutil(8): tool to see status information and change parameters in running applications;  *   libasyncns: A library implementing the consolidation API.

If you want to build this package, you will need gcc 4.7 and pkg-config 0.28 or higher.

Asmutils is mostly used by the Skyfire web browser for Android.

What is this all about?

Asmutils (Linux utilities for Asynchronous I/O) makes it easier to enable and use asynchronous I/O in applications that use POSIX async per-operation mode. These utilities can be installed using a package manager or built from source code and then installed into each application as needed.

Who is this for? People who have applications that they want to compile Asmutils into, so the programs themselves will be able to take advantage of asynchronous I/O without changing anything about how their own program works.

What does this all mean? In an asynchronous file system when you begin a read or write operation, the request is queued up but control returns immediately to your program so there’s no waiting around for data since it’s coming in as fast as the hardware can support.

How does this work? The install is either done through a package manager or is built from source code and installed into each application. Applications like Skyfire mobile web browser use Asmutils to take advantage of asynchronous I/O for improved performance and responsiveness on devices with slow storage and an overloaded CPU, such as mobile ones with Flash disks or slow hard drives.

Where is this useful? Skyfire mobile web browser running on Android.

Why is this useful? By installing Asmutils into an application, you get the benefits of asynchronous I/O (increased performance and responsiveness) but without having to change anything about how your program itself works.

Who did this? The developers of Asmutils: Erez Zadok, Nir Soffer, and John Vilk; homepage: http://asmutils.sourceforge.net/ *   git repository: https://github.com/agallade/asmutils

What license is it under? GNU General Public License v2 (from the project website).

How does one go about using it? People install Asmutils into their applications so that these programs can do asynchronous I/O themselves if they are designed for it.