Go to the first, previous, next, last section, table of contents.


13.8 Machine Code Insertions

  1. A machine code insertion can be achieved by a call to a subprogram whose sequence_of_statements contains code_statements.

    Syntax

  2. code_statement ::= qualified_expression;
    
    1. A code_statement is only allowed in the handled_sequence_of_statements of a subprogram_body. If a subprogram_body contains any code_statements, then within this subprogram_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).

Name Resolution Rules

  1. The qualified_expression is expected to be of any type.

    Legality Rules

  2. The qualified_expression shall be of a type declared in package System.Machine_Code.
  3. A code_statement shall appear only within the scope of a with_clause that mentions package System.Machine_Code.

    Static Semantics

  4. The contents of the library package System.Machine_Code (if provided) are implementation defined. The meaning of code_statements is implementation defined. Typically, each qualified_expression represents a machine instruction or assembly directive.

    Implementation Permissions

  5. An implementation may place restrictions on code_statements. An implementation is not required to provide package System.Machine_Code.

    NOTES

  6. (15) An implementation may provide implementation-defined pragmas specifying register conventions and calling conventions.
  7. (16) Machine code functions are exempt from the rule that a return_statement is required. In fact, return_statements are forbidden, since only code_statements are allowed.
  8. (17) Intrinsic subprograms, See section 6.3.1 Conformance Rules, can also be used to achieve machine code insertions. Interface to assembly language can be achieved using the features in Annex B, See section B Interface to Other Languages (normative).

    Examples

  9. Example of a code statement:
  10. M : Mask;
    procedure Set_Mask; pragma Inline(Set_Mask);
    
  11. procedure Set_Mask is
      use System.Machine_Code;
      -- assume ``with System.Machine_Code;'' appears somewhere above
    begin
      SI_Format'(Code => SSM, B => M'Base_Reg, D => M'Disp);
      --  Base_Reg and Disp are implementation-defined attributes
    end Set_Mask;
    


Go to the first, previous, next, last section, table of contents.