M68000 Series ELF Topics

This appendix describes topics relevant to GNAT for bareboard M68020 and also presents a tutorial on building, running, and debugging an Ada application in GNATemulator.

Supported Processors and Run-Time Libraries

MC68020

GNAT for bareboard M68020 targets the Motorola MC68020 processor. In addition to software floating-point support GNAT supports hardware accelerated floating-operations through the Motorola MC68881 and MC68882 floating-point coprocessors.

Out of the box GNAT provides run-time support for the the Motorola MVME133 VMEmodule as emulated by GNATemulator. For the MVME133, the following run-time libraries are provided:

  • zfp-m68020

  • zfp-m68020-softfloat

All run-time libraries include the necessary low-level hardware startup and initialization functionality required to run applications on the MVME133 as emulated by GNATemulator. To run on an actual MVME133 board some modification may be required depending on the target bootloader. If your board uses a different configuration, you can modify and rebuild the pre-built run-time to meet your needs. The run-time libraries are largely independent of the underlying hardware, simplifying this process.

Floating-Point Support

GNAT supports both software and hardware floating-point operations. By default GNAT uses hard float unless the soft float runtimes are used. The soft float runtimes are postfixed by -softfloat.

GNAT supports the single, double and extended real data formats offered by the MC68881 and MC68882 floating-point coprocessors when configure for hard float. When configured to use soft float, GNAT only supports the IEEE 754 single and double real data formats. Consequently, the predefine Real types have the following digits of precision:

Digits

Float

Long_Float

Long_Long_Float

Soft Float

6

15

15

Hard Float

6

15

18

Getting Started

Developing with GNAT for bareboard is similar to native GNAT development, with two important differences. First, when building for a bareboard target, you need to specify both the target processor and the run-time library. These can be defined in a project file (either directly or via the project properties dialog in GNAT Studio) or on the command line. For details on how to specify the target and run-time library for your project, see Introduction to GNAT for Cross Platforms. For the MC68020 the target m68020-elf needs to be specified.

For example, the following project file fragment shows both the target and the run-time library specified via their respective attributes. For example:

project Demo is
   ...
   for Runtime ("Ada") use "zfp-m68020";
   for Target use "m68020-elf";
   ...
end Demo;

The second difference is how programs are run and debugged. This is dependent on your setup and the tools you use. In many cases, GNAT Studio can be used to debug your program. See Debugging for details.

Getting Started with GNATemulator

This guide describes how to set up, build, run, and debug an Ada application on GNATemulator. Setup for both Windows and Linux hosts is covered. While this section focuses on GNATemulator, most of the steps contained within this section are independent of the application and the target hardware itself.

To begin this setup, it is assumed that GNAT for bareboard M68020 has been installed and that the install bin directory is in the PATH environment variable.

Once installed, ensure that the installation bin directory (by default /usr/local/bin) is included in your PATH.

Creating a new Project

Launch GNAT Studio:

$ gnatstudio

If this is your first time running GNAT Studio, note that GNAT Studio will create a configuration directory and will alert you via a pop-up dialog box. Press ‘OK’ to close that box and continue. A ‘Tip of the Day’ dialog will appear. Press Close to dismiss it.

When on the Welcome page, click on Create new project and select Simple Ada project, and then click on Next. Change Location and Settings appropriately and press Apply.

The project view is now displayed; it is then possible to edit project properties by right-clicking on the project name in Project tab, and selecting Project->Properties.

The project properties are now displayed. Open the Toolchains tab, and make sure that the m68020-elf toolchain is selected and that the Ada runtime is zfp-m68020. Then click on Save.

You can now navigate the project tree and add your source code.

Building

Within GNAT Studio, build the project using either the Build Main button on the toolbar, or the Build/Project->Build All menu entry. In the latter case, if a pop-up window appears, press the Execute button in order to build with the default settings.

As GNAT Studio builds the project, it will display the Messages view at the bottom of the GNAT Studio window to show information about the build. On a successful build, the Memory Usage view will graphically display the memory usage of the program, unless the preference is disabled. (See the preference Build Targets/Project/Build Main page, among others, containing the Display memory usage check-box.)

Running the Program

Within GNAT Studio, run your program on the emulator using the Run with Emulator toolbar button or the Build/Emulator->Run with Emulator menu entry.

As the program executes, it will display its output, if any, in the m68020-gnatemu view.

Debugging the Program

In GNAT Studio, click on the Debug with Emulator button on the toolbar. This will start a GNAT Studio debug session and launch the necessary tools required to debug the program on the board from GNAT Studio. The emulator will be automatically launched. Debugging a program on the emulator through GNAT Studio is similar to debugging a native program:

  • The program can continue to the next breakpoint by pressing the Continue button on the toolbar or by using the Debug/Continue menu item.

  • The program can be stepped through statements using the corresponding menu items in Debug menu and buttons on the toolbar.

  • The program can be interrupted by pressing <ctrl>-\, or through the Debug/Interrupt menu.

  • Breakpoints can be set via the Breakpoints view, by clicking on the line numbers in the source editor while the program is interrupted or by right-clicking on the desired line and selecting Set breakpoint on line ... from the Debug menu.

  • Variables can be queried from the Variables view or by hovering the mouse over a variable with the program interrupted.

GNAT Studio also provides a Debugger Console view that allows shell access to the underlying GDB client that is debugging the program. Arbitrary GDB commands, including the commands corresponding to the above, can be entered into the console if desired.

The debugging session can be exited via the Debug/Terminate menu or by issuing the quit command in the Debugger Console.