Lady Ada

Ada '83 Language Reference Manual

Copyright 1980, 1982, 1983 owned by the United States Government. Direct reproduction and usage requests to the Ada Information Clearinghouse.


13.5. Address Clauses

[PREVIOUS][UP][NEXT]

An address clause specifies a required address in storage for an entity.

      address_clause ::= for simple_name use at simple_expression;

The expression given after the reserved word at must be of the type ADDRESS defined in the package SYSTEM (see 13.7); this package must be named by a with clause that applies to the compilation unit in which the address clause occurs. The conventions that define the interpretation of a value of the type ADDRESS as an address, as an interrupt level, or whatever it may be, are implementation-dependent. The allowed nature of the simple name and the meaning of the corresponding address are as follows:

  1. Name of an object: the address is that required for the object (variable or constant).

  2. Name of a subprogram, package, or task unit: the address is that required for the machine code associated with the body of the program unit.

  3. Name of a single entry: the address specifies a hardware interrupt to which the single entry is to be linked.
If the simple name is that of a single task, the address clause is understood to refer to the task unit and not to the task object. In all cases, the address clause is only legal if exactly one declaration with this identifier occurs earlier, immediately within the same declarative part, package specification, or task specification. A name declared by a renaming declaration is not allowed as the simple name.

Address clauses should not be used to achieve overlays of objects or overlays of program units. Nor should a given interrupt be linked to more than one entry. Any program using address clauses to achieve such effects is erroneous.

Example:

    for CONTROL use at 16#0020#; -- assuming that SYSTEM.ADDRESS is an integer 
    type

Notes:

The above rules imply that if two subprograms overload each other and are visible at a given point, an address clause for any of them is not legal at this point. Similarly if a task specification declares entries that overload each other, they cannot be interrupt entries. The syntax does not allow an address clause for a library unit. An implementation may provide pragmas for the specification of program overlays.

References: address predefined type, apply, compilation unit, constant, entity, entry, erroneous, expression, library unit, name, object, package, pragma, program unit, reserved word, simple expression, simple name, subprogram, subprogram body, system package, task body, task object, task unit, type, variable, with clause.

Rationale references: 13.2.8 Interrupts, 15.4.4 Address Clauses

Style Guide references: 5.9.4 Multiple Address Clauses

Sub-topics:

13.5.1. Interrupts

[UP]

An address clause given for an entry associates the entry with some device that may cause an interrupt; such an entry is referred to in this section as an interrupt entry. If control information is supplied upon an interrupt, it is passed to an associated interrupt entry as one or more parameters of mode in; only parameters of this mode are allowed.

An interrupt acts as an entry call issued by a hardware task whose priority is higher than the priority of the main program, and also higher than the priority of any user-defined task (that is, any task whose type is declared by a task unit in the program). The entry call may be an ordinary entry call, a timed entry call, or a conditional entry call, depending on the kind of interrupt and on the implementation.

If a select statement contains both a terminate alternative and an accept alternative for an interrupt entry, then an implementation may impose further requirements for the selection of the terminate alternative in addition to those given in section 9.4.

Example:

      task INTERRUPT_HANDLER is
        entry DONE;
        for DONE use at 16#40#; assuming that SYSTEM.ADDRESS is an integer 
          type
        end INTERRUPT_HANDLER;

Notes:

Interrupt entry calls need only have the semantics described above; they may be implemented by having the hardware directly execute the appropriate accept statements.

Queued interrupts correspond to ordinary entry calls. Interrupts that are lost if not immediately processed correspond to conditional entry calls. It is a consequence of the priority rules that an accept statement executed in response to an interrupt takes precedence over ordinary, user-defined tasks, and can be executed without first invoking a scheduling action.

One of the possible effects of an address clause for an interrupt entry is to specify the priority of the interrupt (directly or indirectly). Direct calls to an interrupt entry are allowed.

References: accept alternative, accept statement, address predefined type, allow, conditional entry call, entry, mode, parameter of a subprogram, priority of a task, select alternative, select statement, system package, task, terminate alternative, timed entry call.

Style Guide references: 4.1.7 Tasks, 5.9.4 Multiple Address Clauses

[INDEX][CONTENTS]


[Ada Information Clearinghouse]

Address any questions or comments to adainfo@sw-eng.falls-church.va.us.