A machine code insertion can be achieved by a call to a procedure whose sequence of statements contains code statements.
code_statement ::= type_mark'record_aggregate;
A code statement is only allowed in the sequence of statements of a procedure body. If a procedure body contains code statements, then within this procedure body the only allowed form of statement is a code statement (labeled or not), the only allowed declarative items are use clauses, and no exception handler is allowed (comments and pragmas are allowed as usual).
Each machine instruction appears as a record aggregate of a record type that defines the corresponding instruction. The base type of the type mark of a code statement must be declared within the predefined library package called MACHINE_CODE; this package must be named by a with clause that applies to the compilation unit in which the code statement occurs. An implementation is not required to provide such a package.
An implementation is allowed to impose further restrictions on the record aggregates allowed in code statements. For example, it may require that expressions contained in such aggregates be static expressions.
An implementation may provide machine-dependent pragmas specifying register conventions and calling conventions. Such pragmas must be documented in Appendix F.
M : MASK procedure SET_MASK; pragma INLINE(SET_MASK); procedure SET_MASK is use MACHINE_CODE; begin SI_FORMAT'(CODE => SSM, B => M'BASE_REG, D => M'DISP); -- M'BASE_REG and M'DISP are implementation-specific predefined attributes end;
References: allow, apply, comment, compilation unit, declarative item, exception handler, inline pragma, labeled statement, library unit, package, pragma, procedure, and 6.1, procedure body, record aggregate, record type, sequence of statements, statement, static expression, use clause, with clause.
Rationale references: 15.7 Interface with Other Languages
Style Guide references: 7.1.5 Encapsulating Implementation Dependencies, 7.6.3 Machine Code Inserts
Address any questions or comments to email@example.com.