Annotated Ada Reference Manual (Ada 202y Draft 1)Legal Information
Contents   Index   References   Search   Previous   Next 

C.1 Access to Machine Operations

1/3
{AI05-0299-1} [This subclause specifies rules regarding access to machine instructions from within an Ada program.] 
1.a/2
Implementation defined: Implementation-defined intrinsic subprograms.

Implementation Requirements

2/5
{AI12-0320-1} The implementation shall support machine code insertions (see 13.8) or intrinsic subprograms (see 6.3.1) (or both). The implementation shall allow the use of Ada entities as operands for such machine code insertions or intrinsic subprograms.
2.a/5
Discussion: {AI12-0320-1} Ada entities could be used as operands in machine code insertions and/or intrinsic subprograms using language-defined attributes (such as address), implementation-defined attributes, or could be directly allowed. 

Implementation Advice

3
The machine code or intrinsics support should allow access to all operations normally available to assembly language programmers for the target environment, including privileged instructions, if any.
3.a.1/2
Implementation Advice: The machine code or intrinsics support should allow access to all operations normally available to assembly language programmers for the target environment.
3.a
Ramification: Of course, on a machine with protection, an attempt to execute a privileged instruction in user mode will probably trap. Nonetheless, we want implementations to provide access to them so that Ada can be used to write systems programs that run in privileged mode. 
4/3
{AI05-0229-1} The support for interfacing aspects (see Annex B) should include interface to assembler; the default assembler should be associated with the convention identifier Assembler. 
4.a/2
Implementation Advice: Interface to assembler should be supported; the default assembler should be associated with the convention identifier Assembler.
5
If an entity is exported to assembly language, then the implementation should allocate it at an addressable location, and should ensure that it is retained by the linking process, even if not otherwise referenced from the Ada code. The implementation should assume that any call to a machine code or assembler subprogram is allowed to read or update every object that is specified as exported. 
5.a/5
Implementation Advice: If an entity is exported to assembly language, then the implementation should allocate it at an addressable location even if not otherwise referenced from the Ada code. A call to a machine code or assembler subprogram should be treated as if it can read or update every object that is specified as exported.

Documentation Requirements

6
The implementation shall document the overhead associated with calling machine-code or intrinsic subprograms, as compared to a fully-inlined call, and to a regular out-of-line call. 
6.a/2
Documentation Requirement: The overhead of calling machine-code or intrinsic subprograms.
7
The implementation shall document the types of the package System.Machine_Code usable for machine code insertions, and the attributes to be used in machine code insertions for references to Ada entities. 
7.a/2
Documentation Requirement: The types and attributes used in machine code insertions.
8/3
{AI05-0229-1} The implementation shall document the subprogram calling conventions associated with the convention identifiers available for use with the Convention aspect (Ada and Assembler, at a minimum), including register saving, exception propagation, parameter passing, and function value returning. 
8.a/2
Documentation Requirement: The subprogram calling conventions for all supported convention identifiers.
9
For exported and imported subprograms, the implementation shall document the mapping between the Link_Name string, if specified, or the Ada designator, if not, and the external link name used for such a subprogram. 
9.a/2
This paragraph was deleted.
9.b/2
Documentation Requirement: The mapping between the Link_Name or Ada designator and the external link name.

Implementation Advice

10
The implementation should ensure that little or no overhead is associated with calling intrinsic and machine-code subprograms.
10.a/2
Implementation Advice: Little or no overhead should be associated with calling intrinsic and machine-code subprograms.
11
It is recommended that intrinsic subprograms be provided for convenient access to any machine operations that provide special capabilities or efficiency and that are not otherwise available through the language constructs. Examples of such instructions include: 
12/5
{AI12-0453-1} Atomic read-modify-write operations — for example, test and set, compare and swap, decrement and test, enqueue/dequeue.
13/5
{AI12-0453-1} Standard numeric functions — for example, sin, log.
14/5
{AI12-0453-1} String manipulation operations — for example, translate and test.
15/5
{AI12-0453-1} Vector operations — for example, compare vector against thresholds.
16
Direct operations on I/O ports.
16.a/2
Implementation Advice: Intrinsic subprograms should be provided to access any machine operations that provide special capabilities or efficiency not normally available.

Contents   Index   References   Search   Previous   Next 
Ada-Europe Ada 2005 and 2012 Editions sponsored in part by Ada-Europe