programmers resources  (c)2019
Search :  
Lingua Italiana    English Language   
just an empty assembly space
just an arrow Intel Platform
just an arrow Article & Guides
just an arrow Download Software

23/01/2009 Featured Article: How to remove Buzus Virus (permalink)

Bottone Scambio Directory
Home Page | Articles & Guides | Download | Intel Platform | Contacts


Bookmark and Share
Tell a friend

Assembly language programming under Unix

A small guide for intermediate level programmers

(by g. adam stanislav)

A small guide on assembly programming under FreeBSD with some source code, too.

This article is online from 3810 days and has been seen 15715 times

*** download for full text ***

Assembly language programing under Unix
G. Adam Stanislav

Assembly language programing under Unix is highly undocumented. It
 is generally assumed that no one would ever want to use it becaus
e various Unix systems run on different microprocessors, so everyt
hing should be written in C for portability.

In reality, C portability is quite a myth. Even C programs need to
 be modified when ported from one Unix to another, regardless of w
hat processor each runs on. Typically, such a program is full of c
onditional statements depending on the system it is compiled for.

Even if we believe that all of Unix software should be written in 
C, or some other high-level language, we still need assembly langu
age programmers: Who else would write the section of C library tha
t accesses the kernel?

In this tutorial I will attempt to show you how you can use assemb
ly language writing Unix programs, specifically under FreeBSD.

This tutorial does not explain the basics of assembly language. Th
ere are enough resources about that (for a complete online course 
in assembly language, see Randall Hyde’s Art of Assembly Language;
 or if you prefer a printed book, take a look at Jeff Duntemann’s 
Assembly Language Step-by-Step). However, once the tutorial is fin
ished, any assembly language programmer will be able to write prog
rams for FreeBSD quickly and efficiently.

Chapter 1 – The Tools
1.1. The Assembler
1.2. The Linker
Chapter 2 – System Calls
2.1. Default Calling Convention
2.2. Alternate Calling Convention
2.3. Which Convention Should You Use?
2.4. Call Numbers
2.4.1. The syscalls File
Chapter 3 – Return Values
3.1. Man Pages
3.2. Where Are the Return Values?
3.3. Where Is errno?
3.4. Determining an Error Occurred
Chapter 4 – Creating Portable Code
4.1. Dealing with Function Numbers
4.2. Dealing with Conventions
4.3. Dealing with Other Portability Issues
4.4. Using a Library
4.5. Using an Include File
Chapter 5 – Our First Program
5.1. Assembling the Code
5.1.1. Installing nasm
Chapter 6 – Writing Unix Filters
Chapter 7 – Buffered Input and Output
7.1. How to Unread a Character
Chapter 8 – Command Line Arguments
Chapter 9 – Unix Environment
9.1. How to Find Environment Variables
9.2. webvars
9.2.1. CGI: A Quick Overview
9.2.2. The Code
Chapter 10 – Working with Files
10.1.Finite State Machine
10.1.1. The Final State
10.1.2. The Output Counter
10.2. Implementing FSM in Software
10.3.Memory Mapped Files
10.4. Determining File Size
10.5. Changing the File Size
10.6. ftuc
Chapter 11 – One-Pointed Mind
11.1. CSV
11.1.1. The Dark Side of Buffering
12.1. Organization of the FPU
12.1.1. The Packed Decimal Format
12.2. Excursion to Pinhole Photography
12.2.1. The Camera
12.2.2. The Pinhole
12.2.3. Focal Length
12.2.4. The F–Number
12.2.5. Normalized F–Number
12.2.6. The F–Stop
12.3. Designing the Pinhole Software
12.3.1. Processing Program Input
12.3.2. Offering Options
12.3.3. The Output
12.4. FPU Optimizations
12.5. pinhole—The Code
12.6. Using pinhole
12.7. Scripting
Chapter 13 – Caveats
13.1. Unix Is Protected
13.2. Unix Is an Abstraction
Appendix A – Assembly Language Pearls
Appendix B – BSD Style Copyright
Appendix C – Change Log


*** download for full text ***

Tell a friend
Bookmark and Share

Similar Articles

64-Bit - Programming and Assembly Issues
Brief intro on 64 bit architecture and programming
(by Thorsten Schneider)

8080/8085 Assembly Language Programming
Assembly Language Programming Manual
(by Intel Corporation)

8085 TRS 80 Model 100 Assembly Programming
Brief guide on 8085 architecture and programming
(by Mike Berro - BCS Software)

Adam's Assembler Tutorial 1.0
A tutorial in 9 lessons on Assembler
(by Adam)

AMD64 Architecture Programmer’s Manual Volume 3
General-Purpose and System Instructions
(by AMD)

AMD64 Architecture Programmer’s Manual Volume 4
128-Bit Media Instructions
(by AMD)

AMD64 Architecture Programmer's Manual Volume 2
System Programming
(by AMD)

AMD64 Architecture Programmer's Manual Volume 5
64-Bit Media and x87 Floating-Point Instructions R
(by AMD)

AMD64 Programmer’s Manual Volume 1
Application Programming
(by AMD)

Assembler Tutorial 1996 Edition
A guide from Guadalahara University
(by Hugo Perez Univ.Guadalajara)

Assembly Language Programming
A 14 page intro for beginners using NASM
(by Archis Gore)

Brennan's Guide to Inline Assembly
A guide to inline Unix assembly programming
(by Brennan)

Extending DOS Executables
How to modify a Windows executable relocating code
(by Digital Alchemist)

A guide about Assembler in 8 parts
(by Gavin Estey)

IBM Personal Computer Assembly Language Tutorial
A guide that introduces main topics of asm lang
(by Joshua Auerbach)

Intro to Assembler
An intro to Intel ASM programming
(by VLA)

Masm 5 Instructions, Directives and Interrupts
A 30 page listing for assembly programmers
(by n/d)

Optimizations for Intel's 32-Bit Processors
A 49 page guide on Intel Asm Code Optimization
(by Bev Zaharie)

PC Assembly Language Manual
A book to learn basic Assembly in 195 pages (pdf)
(by Paul Carter)

PCI Interrupts for x86 Machines under FreeBSD
A guide for interrupt programming under Unix
(by John H. Baldwin)

Programming from the ground up
EBook on Linux Assembler programming
(by Jonathan Bartlett)

Protected Mode Tutorial v.0.02
Tutorial for Protected Mode programming in asm
(by Till Gerken)

Sk00l m3 ASM!!#@$!@#
An assembly programming guide
(by Ralph (AWC))

Static Detection of Vulnerabilities in x86 Code
Analysis of assembly code for security problems
(by M.Cova V.Felmetsger G.Banks G.Vigna)

A collection of 85 asm programming documents
(by various)

Win32 asm
Manage win32 projects in assembly language
(by unknown)

Win32 Course in 35 Lessons
Una guida con codice d'esempio per w32asm
(by Iczelion)

x86 ASM Programming for Linux
Intro to assembly programming on Linux using NASM
(by mammon_)

X86 Assembly Tips And Tricks
Asm coding programming tricks
(by Laura Fairhead)

x86 Quick Reference Instruction Manual
8086/80186/80286/80386/80486 Instruction Set
(by thenet)

 Tags: asm tutorial, unix

webmaster jes
writers rguru, tech-g, aiguru, drAx

site optimized for IE/Firefox/Chrome with 1024x768 resolution

Valid HTML 4.01 Transitional


hosting&web -

find rguru on
... send an email ...
Your name

Destination email


captcha! Code