In this section:
It is always inconvenient to have to descend to assembler, even in the form of a CODE/EDOC sequence, and a number of special Fortran constructions have been introduced for convenience.
The intrinsic functions CCORE1, CORE1, CORE2, CORE4, FCORE4, DCORE8, XCORE10, ZCORE8, ZCORE16, and ZCORE20 are available to examine the contents of a given location.
Each function takes an INTEGER(KIND=7) argument which is an address and returns the following value at that address.
|
CCORE1 |
CHARACTER |
|
CORE1 |
INTEGER(KIND=1) |
|
CORE2 |
INTEGER(KIND=2) |
|
CORE4 |
INTEGER(KIND=3) |
|
FCORE4 |
REAL(KIND=1) |
|
DCORE8 |
REAL(KIND=2) |
|
XCORE10 |
REAL(KIND=3) |
|
ZCORE8 |
COMPLEX(KIND=1) |
|
ZCORE16 |
COMPLEX(KIND=2) |
|
ZCORE 20 |
COMPLEX(KIND=3) |
These functions may also be used on the left hand side of an assignment. For example:
CORE2(L)
= CORE2(L)+1
CCORE1(P)=' '
CORE1(PTR)=123
If an argument to a routine is one of these functions the actual address is passed, for example:
INTEGER(7)
L
INTRINSIC LOC,CORE2
K = 4
L = LOC(K)
CALL FRED(CORE2(L))
PRINT *,K
END
SUBROUTINE FRED(M)
M = M + 2
END
would print 6.
A special form of the SUBROUTINE statement is available for x86 (Win32) thus:
SPECIAL SUBROUTINE JACK
Special routines must have no arguments, and contain no preamble to set EBX%,EBP% etc. They can only really be followed by CODE/EDOC sequences, and no reference to dynamic variables must be made in such a routine. Static variables may be referenced and will use the full address form of the instruction (rather than EBX% relative). Special subroutines may contain additional entry points coded as special entries:
SPECIAL ENTRY BILL
Special routines may not contain ordinary entry points and vice-versa. The return from a special subroutine must be via a RET instruction and not as a result of executing a RETURN or END statement. The main purpose of the special subroutine is as a routine which can be called from assembler without altering the contents of the registers.
An additional use of this facility is in conjunction with the SET_TRAP@ routine. A control break or floating point fault can take place at an arbitrary point in a program, and it is important to be able to save the registers etc. before they are overwritten. Although this can be done with an interrupt subroutine without the use of CODE/EDOC, the latter offers the ability to inspect and alter the contents of the registers if desired.
Circular shifts are available as intrinsic functions and thus do not require the use of assembler.
The LOC intrinsic function returns the address of its argument as a 32 bit number (64 bit for x64).