Exforsys.com
 
Home Tech Articles UNIX
 

Linux Assembly Tutorial Step-by-Step Guide

 

Mainly, the reason for this tutorial is to make assembly programming easier, better and more practical by doing it in Linux instead of DOS. Also, it may teach you a bit of Linux while you're at it (unless you're already at home with it).



This tutorial is an introduction to coding assembly in Linux. There are two "versions" to accommodate various people:


The Step-by-Step Guide: This version explains everything in detail. It assumes that you have done at least a little bit of DOS assembly, and that you have Linux on your computer (although you may not have used it much yet). Since not everyone may know how to use Linux, there are links to sections where I explain how to do basic things like use the terminal and the DOS-equivalent commands.


The Quickstart: If you're in a hurry and just want to see a Linux assembly program, compile it and run it, this is for you. It assumes that you understand basic DOS assembly, and that you know how to use the terminal. Basically, it just points out the differences between a Linux and DOS assembly program with just enough explanation not to confuse you.


The assembler I'll be using is NASM (Netwide Assembler). Lots of the stuff in this tutorial came from other tuts and the NASM documentation – see the References section for more info.


Download as zip File


Quickstart


1. Introduction
2. Why this Tutorial?
3. The Netwide Assembler (NASM)
    3.1 A Note on Assemblers
    3.2 Where do I get NASM?
4. Introduction to Linux Assembly
    4.1 Main Differences Between DOS and Linux Assembly
    4.2 The Parts of an Assembly Program
    4.3 Linux System Calls
        4.3.1 Reading the Manpages
    4.4 "Hello World!" in Linux Assembly
    4.5 Compiling and Linking
5. More Advanced Concepts
    5.1 Command Line Arguments and the Stack
    5.2 "Procedures" and Jumping
6. Conclusion


Appendix A. The terminal is your friend - how to use it
Appendix B. Installing NASM (and other stuff) on Linux
Appendix C. References


A book that covers both these topics and is a useful assembly reference is:


The Revolutionary Guide to Assembly Language
Vitaly Maljugin, Jacov Izrailevich et al
Wrox Press
ISBN: 1-874416-12-5


Table of Contents


Part I - Introduction to the hardware
    Overview of the 80x86 Family
    Representation of numbers in binary
    Registers
    Segments and offsets
    The Stack


Part II - An Introduction to Assembly Instructions
   
Push and Pop: Two Instructions to use the Stack
    Types of Operand
    Some Instructions that you will need to know
    Your first assembly program
    Compilation Instructions


Part III - Input and Control Flow
   
Making things easier
    Keyboard Input
    Printing a Character
    Control Flow
    Jump on Condition Instructions
    Example Program


Part IV - Procedures and Macros
   
Some instructions that you need to know
    Introduction to Procedures
    Procedures that pass parameters
    What are "Memory Models"?
    Macros
    Macros with parameters


Part V - Files
   
File Functions
    How to save the file handle
    Using the FindFirst and FindNext Functions


Part VI - Strings, Shifts and Debuggers
   
String Instructions
    How to find out the DOS Version
    Multiple Pushes and Pops
    The PUSHA/PUSHAD and POPA/POPAD Instructions
    Using Shifts for faster Multiplication and Division
    Loops
    How to use a debugger


Part VII - Writing to the Screen
    More output in text modes
    Mode 13h
    First check that mode 13h is possible
    Setting the Video Mode
    Some Optimizations



 



Read Next: An Introduction to Shell Scripting

 

 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2010 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape