www.delorie.com/gnu/docs/gcc/gnat_ug_251.html   search  
Buy the book!

Untitled Document

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

24. Inline Assembler

If you need to write low-level software that interacts directly with the hardware, Ada provides two ways to incorporate assembly language code into your program. First, you can import and invoke external routines written in assembly language, an Ada feature fully supported by GNAT. However, for small sections of code it may be simpler or more efficient to include assembly language statements directly in your Ada source program, using the facilities of the implementation-defined package System.Machine_Code, which incorporates the gcc Inline Assembler. The Inline Assembler approach offers a number of advantages, including the following:

This chapter presents a series of examples to show you how to use the Inline Assembler. Although it focuses on the Intel x86, the general approach applies also to other processors. It is assumed that you are familiar with Ada and with assembly language programming.

24.1 Basic Assembler Syntax  
24.2 A Simple Example of Inline Assembler  
24.3 Output Variables in Inline Assembler  
24.4 Input Variables in Inline Assembler  
24.5 Inlining Inline Assembler Code  
24.6 Other Asm Functionality  
24.7 A Complete Example  

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003