Chapter 2. Advanced Techniques

Table of Contents
2.1. Using a Custom Start File
2.2. Using a Custom Linker Script File
2.3. How to Get a Map File
2.4. Generating PROM Programming Files
2.5. Using the Debugger
2.6. Using Optimizations
2.7. Working with the Target

Once you have mastered writing and running a small program, you'll want to check out some of the more advanced techniques required to write and run real application programs. In this chapter, we cover the following topics:

2.1. Using a Custom Start File

The start file art0.S contains instructions to initialize the arithmetic unit, floating point unit and timer. The default start file may be suitable for your requirements. You can see the source code in file /opt/m68k-ada-1.7/m68k-coff/src/libc/art0.S. If it is not suitable, make a copy in a working directory, then edit it as necessary.

Example 2-1. Creating a Custom Start File

$ mkdir work
$ cd work
$ cp /opt/m68k-ada-1.7/m68k-coff/src/libc/art0.S .
$ vi art0.S

One of the configuration parameters you may wish to change is the clock speed. The default speed is 25 MHz, which is the clock frequency of the simulator. If your clock runs at (say) 35 MHz, then you should modify the statement in art0.S that defines the clock frequency.

Once you have completed the changes, you must compile art0.S to generate an object code file called art0.0. This is the file that the default linker script will look for. Note that the compiler will select MC68040 by default. If your target is a MC68000, then use the compile-time option -m68000.

The following example gives the command you need:

Example 2-2. Recompiling art0.S

$ m68k-coff-gcc -c art0.S

If you now rebuild your application program, the local file art0.0 will be used in preference to the library file. You can check that your local version has been used in the map file.

Example 2-3. Rebuilding with a Custom art0.S

$ $  m68k-coff-gnatmake -f -g tt3 -largs -nostartfiles art0.S

Note: If you run a program built for 35 MHz on the simulator, be sure to specify a clock frequency of 35 MHz. The default is 25 MHz.