4.2. Compilation

For Ada 83 and Ada 95 the predefined program library is located in a standard place, which is target dependent. The location is /opt/m68k-ada-1.7/lib/gcc-lib/m68k-coff/2.8.1/adalib/.

Ada source files are always compiled in the context of a program library. While M68K Ada does not have a closed library as some other Ada compilers do, it does generate and use library file information. By default this goes in the current directory. Library files use the .ali (Ada library) suffix. Also M68K Ada requires each Ada compilation unit to be in a separate file with the file name the same as the unit name. There must be a file extension which is .ads for a package or subprogram specification and .adb for a body.

Where a source file contains more than one compilation unit, then the program m68k-coff-gnatchop may be used to divide the file. This program will write the output files in the current directory, or (more usefully) into a named directory.

For example:


bash$ m68k-coff-gnatchop big-file.ada src

4.2.1. Format and Content of User Listings

The compiler accepts several command line options to control the format of listings. By default, no listing is generated at all.

-gnatl

Output full source listing with embedded error messages.

-gnatv

Verbose mode. Full error output with source lines to stdout.

-gnatk

Keep going despite syntax errors.


bash$ m68k-coff-gcc -gnatlqv ackermann.adb 
XGC Ada m68k-ada/-1.7/
Copyright 1992-2002 Free Software Foundation, Inc.

Compiling: ackermann.adb (source file time stamp: 2001-04-25 16:57:54)

     1. function Ackermann (m, n : Integer) return Integer is
     2. begin
     3.    if m = 0 then
     4.       return n + 1;
     5.    elsif n = 0 then
     6.       return Ackermann (m - 1, 1);
     7.    else
     8.       return Ackermann (m - 1, Ackermann (m, n - 1));
     9.    end if;
    10. end Ackermann;
    11. 

 11 lines: No errors

The assembler can also generate a listing, as follows:


bash$ m68k-coff-gcc -Wa,-a -O -c ackermann.adb 
   1                            .file   "ackermann.adb"
   2                    gcc2_compiled.:
   3                    __gnu_compiled_ada:
   4                            .text
   5                            .even
   6                    .globl _ada_ackermann
   7                    _ada_ackermann:
   8 0000 4E56 0000             link.w  %a6,#0
   9 0004 2F0A                  move.l  %a2,-(%sp)
  10 0006 226E 0008             move.l  8(%a6),%a1
  11 000a 206E 000C             move.l  12(%a6),%a0
lots of output...

The objdump program can also generate a listing by disassembling the object code.


bash$ m68k-coff-objdump -d ackermann.o
ackermann.o:     file format coff-m68k

Disassembly of section .text:

00000000 <_ada_ackermann>
   0:   4e56 0000       linkw   %fp,#0
   4:   2f0a            movel   %a2,%sp@-
   6:   226e 0008       moveal  %fp@(8),%a1
   a:   206e 000c       moveal  %fp@(12),%a0
...