Terra Datentechnik Home Home · Modula-2

Modula-2 Protected Mode and Standard ROM-Tools



Top of Page

TERRA Modula-2 Standard ROM-Tools for Real Mode

(Revision February 20, 1998)

The TERRA Modula-2 ROM-Tools extend the standard Logitech Modula-2 version 3 system to a powerful set of development tools for programming embedded applications.

Logitech Modula-2 is a widely used, well-known development system for programming 80x86/88 based microcomputers which includes one of the best Modula-2 compilers available today. Because of its Systems programming facilities, Modula-2 is an ideal language for the development of stand alone programs for ROM-based target systems. The standard Logitech Modula-2 compiler can generate ROM-able code, however, additional tools are required to create and test programs for ROM- based 80x86/88 target systems.

The TERRA Modula-2 ROM-Tools include the additional utilities which are needed for creating and testing ROM-able standalone programs. The ROM-Tools allow to cross-develop Modula-2 programs on an IBM PC or compatible host computer for 80x86/88 based target systems with (programmable) read-only memory. The ROM-Tools also include test facilities, which use a serial line between the host and the target system for downloading and testing of Modula-2 programs.


The TERRA Modula-2 Standard ROM-Tools for Real Mode
· allow to locate code and data of Modula-2 programs at specific (absolute) memory addresses
· support the standard Intel 8086 hexadecimal object format (H86), which can be used with most PROM-programmers
· allow for application programs with up to 1 Mb of code and data
· include a Target Monitor and a Target Run-Time Support adaptable to the hardware configuration of the target system
· offer downloading facilities from the host to the target system for easy testing
· provide automatic uploading of a memory dump for high-level debugging of run-time errors
· offer interactive, dynamic, high-level cross-debugging
· do not require any terminal or disk for the target system

Typical System Configuration

The development system consists of an IBM PC or compatible host computer and an 80x86/88 based target system. The host computer and the target system are linked together through a serial line.

The host computer used to develop application programs for the target system is, for instance, a personal computer with a terminal and a harddisk. lt must contain a serial port, through which it can be linked to the target System. The compiler and the other utility programs of the Logitech Modula-2 system run on the host computer in the MS-DOS environment. The target system is typically a single-board computer. Its main components are an 80x86 or 80x88 processor and some (EP)ROM and RAM chips. In addition, there may be some application dependent peripherals. The target system must contain at least one serial port, which will be used for communication with the host.

During the development and test phase, some or all (EP)ROM chips of the target system may be replaced with RAM. Modula-2 programs developed on the host are downloaded into the target system through a serial line. Only the final version of a program is burned into (EP)ROM chips which will reside in the target system.

System Requirements

Host System
· IBM PC or compatible System
· a minimum of 300 K RAM (512 K or more recommended)
· one serial port (RS232) for communication with the target computer
· DOS 2.0 or higher
· Logitech Modula-2 Release 3.40 for MS-DOS

Target System
· any 80x86/88 based computer
· one serial port (RS232) for communication with the host computer

ROM-Tools Components

Target Monitor (TMON)

The TMON resides in the target system. lt initializes and starts the Modula-2 program. During the test phase, it also provides the interface to the host system for downloading and debugging. lt communicates with the host system by means of a serial line. The TMON is an assembler program written in Microsoft Macro Assembler and is provided in source form. Because its code is hardware dependent, it must be adapted to a given target system. In particular, it depends in the memory layout and on the interrupt system of the target computer.
The TMON is burned into (EP)ROM and, in general, resides in the target system even during the test phase. However, it might also be downloaded from the host by the firmware of the target system. The user must supply his own tools for debugging the installation of the Target Monitor.

Target Run-Time Support (TRTS)

The TRTS is a slightly modified version of the regular Modula-2 Run-Time Support (RTS). In particular, it has been modified in order to comply with the requirements of standalone target systems where all program code resides in (EP)ROM. The TRTS is an assembler program written in Microsoft Macro Assembler and is provided in source form. Because some of its code depends an the interrupt hardware of the target computer, it must be adapted to a given target system.

The Absolute Locator (XLOC)

The XLOC utility runs on the host computer and allows to locate linked Modula-2 programs at absolute memory addresses. The code and the data of any module may be placed at specific memory addresses. XLOC takes as input the EXE file containing the code of the linked program and produces an output file containing the code of the program in Intel 8086 hexadecimal object format (H86). The contents of this file may either be downloaded to the target system by means of the XRUN utility, or it can be used to put the code into (EP)ROM.
In addition, XLOC supports the organization of a program into a hierarchy of sub-program layers, similar to the sub-program and overlay concept supported by the Logitech Modula-2 Linker. The code of such a program may be put into (EP)ROM step by step, when testing has been completed for a layer. Lower level layers may already reside in (EP)ROM, while the code of higher level layers may be downloaded for debugging.

XRUN Utility

The XRUN utility runs on the host computer and is used during the test phase only. lt allows to download Modula-2 programs in Intel 8086 hexadecimal object format (H86) from the host to the target system. XRUN uses a serial line between the host and the target system to communicate with the Target Monitor that resides in the target computer. XRUN also allows to execute or restart a program that has been downloaded. If a runtime error occurs, XRUN optionally uploads the memory contents and produces a memory dump file which can be analysed with the standard Logitech Modula-2 symbolic Post-Mortem Debugger (PMD). The user interacts with the XRUN utility from the terminal on the host computer.

Cross Run-Time Debugger (XRTD)

The TERRA Modula-2 Cross Run-Time Debugger is a powerful, high-level debugging tool. lt runs on an IBM PC or compatible host computer and offers dynamic cross-debugging of 80x86/88 standalone programs at source code level. Before using the XRTD, the Modula-2 program to debug must be downloaded to the target system by means of the XRUN utility.
The XRTD provides the features of the standard Logitech Modula-2 Run-Time Debugger. In particular it is possible to dynamically monitor the execution of a program in the target system by setting breakpoints, executing in single-step mode, inspecting and modifying data, etc.
Additional functions of the XRTD allow the user to terminate and restart a program that has been downloaded. lt is also possible to quit the debugger without terminating the program in the target computer. The debugger may then be reconnected later, in order to check whether the program running in the target computer has come across a breakpoint or run-time error.


Many of the library modules provided with the standard, PC resident Logitech Modula-2 system may also be used in a target system. Only the modules that are based on features of the MS-DOS operating system or some PC-specific hardware cannot be used without modification of their source.
A detailed list of the compatibility of the standard library modules with the ROM-Tools is contained in the manual.
In addition, the ROM-Tools include a special implementation of the standard "Storage" module for managing dynamic memory allocation in an operating system independent manner. Also included is a library module that allows to organize the program into a hierarchy of program layers.

Real-Time Applications in ROM

The TERRA Modula-2 Real-Time Kernel can be used with the Standard ROM-Tools. As for the standard library, adaptations to the specific target system may be necessary for some of its modules.

Top of Page

TERRA Modula-2 Protected Mode ROM-Tools

(Revision February 20, 1998)

The TERRA Standard (real mode) ROM-Tools only provide support for the so called "real (address) mode" of the 80x86/88 processor, in which the accessible address space is limited to a total of 1 Mb of memory. For larger application programs, the TERRA Modula-2 Protected Mode ROM-Tools allow to overcome this limitation.

The Protected Mode ROM-Tools are an extension of the Standard real mode ROM-Tools. They require an 80286, 80386, or more advanced compatible processor in the target system and will make use of its so called "protected (address) mode". The Protected Mode ROM-Tools support the creation of ROM-able protected mode programs with Logitech Modula-2 version 3.

The additional features supported by the Protected Mode ROM-Tools are:

· The target Monitor and the application program run in the so-called "protected mode" of the 80286, 80386, or more advanced processor
· Handling of protected mode specific exceptions
· Code and data may occupy up to 16 Mb of physical memory

Apart from a few details, developing Modula-2 application programs with the Protected Mode ROM-Tools is very similar to using the Standard ROM-Tools. Special protected mode versions of the Standard ROM-Tools utility programs are included with the Protected Mode ROM-Tools.

The standard Intel 8086 hexadecimal object format H86 only provides support for (absolute) addresses up to 1 Mb. Therefore, an extended H86 format called H26 is used by the Protected Mode ROM-Tools. The absolute locator XLOC generates output files according to the H26 format when locating for protected mode. This format is also accepted by the XRUN utility for downloading. Also included is a converter utility H26TOMEX, which allows to transform files with ROM-able code from the H26 format to the Motorola EXORmacs format.

The protected mode ROM-Tools do not fully support the use of all protected mode processor features. Some compromises have been taken for the sake of simplicity, and of similarity to the Standard real mode ROM- Tools. The main purpose of using the protected mode is to support addressing of more than 1 Mb of physical memory.

The general concept applied and its restrictions may be summarized as follows:

· All segments are addressed via the Global Descriptor Table (GDT, supported by the processor hardware). No support is provided for using local descriptor tables (LDT).
· All segments must reside in directly addressable physical memory. In the case of the 80286 physical memory is limited by the processor to 16 Mb.
· The size of a segment is limited to 64 Kb also when working with an 80386 or more advanced processor. Because the GDT may contain up to 8192 entries, the total address space is limited to 8192 * 64 Kb = 512 Mb. Note, however, that the current version of the Protected Mode ROM-Tools does not really support physical addresses longer than 24 bits, i.e. larger than 16 Mb.
· There is no support for the 32-bit mode of the 80386 or more advanced processors. In fact, this would primarily need to be supported by the compiler. (All Logitech Modula-2 compilers are 16-bit compilers.)
· Privilege levels are not really used. After switching to protected mode, the target system always runs at privilege level zero (most privileged level). In this respect, no distinction is made between the target monitor and the Modula-2 application program.
· The Target Monitor and the application program share the same GDT. Entry number one of the GDT describes the GDT itself as a writeable data segment. Therefore, the GDT may even be modified by the application program, although this is not recommended.
· In the sense of the tasks scheme supported by the protected mode instruction set of the processor there is only one single task running all the time. Modula-2 processes are implemented (TRANSFER, IOTRANSFER, etc.) basically in the same way as for the standard Logitech Modula-2 system. This means, that a context switch between Modula-2 processes will neither cause a task switch in the sense of the protected mode, nor in any way make use of the corresponding features of the processor.
· Interrupt vectors must be installed by means of the Interrupt Descriptor Table (IDT, supported by the processor hardware). The Modula-2 IOTRANSFER routine is implemented in this way.
· The protected mode exceptions are handled by the Target Monitor. The "regular" exceptions (e.g. division by zero), which may also occur in real mode, are handled by the Modula-2 (Target) Run-Time Support.
· The segments of the Modula-2 application program may be located anywhere in physical memory. Only the segments of the Target Monitor must reside in the first megabyte of memory.
· Programs that are larger than a total of 1 Mb code and data must be split into several (sub-) program layers, such that each layer is smaller than one megabyte. The layer concept provided by module "Layers" is very similar to the overlay concept supported by the Logitech Modula-2 version 3 system.

For details on the general protected mode concepts and features of the 80286, 80386, or more advanced processors (e.g. the GDT or IDT), please refer to the corresponding INTEL manuals, like for instance the "80386 Programmer's Reference Manual".

Top of Page


Licenses and Support

(Revision February 20, 1998)

Licence / Site Licence

The standard licence allows to use of these products on a single CPU. This means editing, compiling, linking, locating and testing on one and the same host computer. Licences for using the products on additional CPUs of the same site are available at reduced prices. Educational and non-profit research institutions are allowed special discounts.
Programs developed with these products are not subject to any licences from TERRA and may be distributed with no fee, even if they include (parts of) the software (libraries) in object form.


The technical assistance with regard to software problem reports is included in the standard licence for a short initial period. Assistance is available by email, fax, phone or regular mail. After the initial period support is available based on an hourly or daily rate. Support may be requested with minimal order formalities and the customer will be billed after his problem has been resolved.

The philosophy of TERRA Datentechnik is based an the satisfaction of the customer, so as to make its best to provide an efficient and professional support.


The Logitech Modula-2 ROM-Tools and the Logitech Modula-2 Real-Time Kernel are well-known tools for industrial Modula-2 applications.
In 1989 TERRA Datentechnik took over the maintenance and distribution of those products from Logitech. They have been marketed as the TERRA Modula-2 product line since.

Top of Page

Von Mensch zu Mensch
Home · Modula-2

 Copyright © TERRA Datentechnik 1996-2006
Alle Rechte vorbehalten.TERRA Datentechnik übernimmt keine Haftung für die Vollständigkeit, Richtigkeit und Aktualität der Angaben!
Rechtliche Hinweise  ·  Firmenprofil
Contact us   Last Updated: 12-November-2002 Webmaster