The CODE/EDOC facility

In this section:

This item is about CODE/EDOC when compiling in 32-bit mode. For a discussion of 64-bit CODE/EDOC see here.

The CODE statement switches the compiler into a mode in which it accepts Intel 32-bit assembler instructions rather than Fortran statements. The compiler is returned to normal by the EDOC statement. A CODE/EDOC sequence may appear anywhere that an executable Fortran statement is permitted. For example:

    CHARACTER*10 L
    CODE
    LEA EDI%,L ;EDI gets address of L
    MOVB AL%,='*' ;Asterix in AL
    MOV ECX%,=10 ;Count in ECX
    REP ;Rep prefix coded as
   + ; a separate instruction
    STOSB ;This fills L with aster isks
    JMP $10 ;Jump to label 10
    EDOC
    PRINT *,'This should not be printed'
    STOP
    10 PRINT *,'L = ',L
    END

This example is artificial in that there is no real point in performing operations in assembler that can be done in Fortran, however it illustrates that code is written according to the following conventions:

  • Instructions refer to Fortran objects or explicitly to the registers

  • Register names are followed by a '%' to distinguish them unambiguously from variable names.

  • Instructions must start in column 7 or beyond.

  • Only numeric (Fortran) labels are permitted.

  • Comments may be included provided they are preceded by a semi-colon character (;)

  • Some mnemonics are followed by an 'H' to indicate halfword (16-bit) operation or by 'B' to indicate a byte operation. This is discussed in more detail below.

 

 

Basket
Empty
 
Copyright © 1999-2024 Silverfrost Limited