Chapter 1 Compiler Support Modules 1 Introduction

Дата канвертавання24.04.2016
Памер49.77 Kb.
CHAPTER 1 Compiler Support Modules 1.1 Introduction. <<<.... to be filled in later ....>>> 1.2 Threaded Code. When threaded code is generated by the compiler, the "compiled code" produced by the compiler is a list symbolic names and arguments. The symbolic names are entry points into modules in the Fortran Object Time System (OTS). Consider the following example (from the RT-11/RSTS/E Fortran User's Guide, page 1-14): Statement #0007 000034 ISN$ 000036 MOF$MS $DATA+#000004 000042 DIF$IS #040400 000046 CDF$ 000050 ADD$MS $DATAP+#000020 000054 MOD$SM $DATA+#000020 This code corresponds to the Fortran statement DBLE=REAL/2. + 3.1415926535D0 at Internal Statement Number (ISN) 0007 of the source program. Here DBLE is declared Real*8 and REAL is declared REAL*4. When executing threaded code, the OTS treats register R4 as a virtual program counter. By loading the address of the first threaded code module into R4 and executing a JMP @(R4)+ instruction, control is passed to the first module and the "program counter" is incremented to point at the next word in memory. If the threaded code requires arguments (as for MOF$MS above), the arguments follow in memory after the entry point name. These arguments are then FORTRAN IV OTS (Draft) Page 1-2 Compiler Support Modules referenced with suitable auto-increment address modes in the OTS module, so that when the OTS module completes its function, a single "JMP @(R4)+" instruction will transfer control to the next module. Using the above example, the following occurs when statement 7 is executed. First, the internal statement number is incremented ($ISN routine). Next a value is moved from memory to the stack (MOF$MS); the address of the value to move is $DATA+#000004, i.e., the variable REAL (see load map on page 1-14 of User's Guide). Next a floating point divide is performed (DIF$IS); the numerator is on top of the stack and the denominator follows immediately in memory (#040400 is the first word of the floating point constat 2.0). Next the value on top of the stack is converted to Real*8 by the module CDF$. Now a double precision add of the double precision constant 3.1415926535D0 to the top of stack is performed (ADD$MS). Note that only constants which fit in one 16-bit word are stored inline; here a memory location in the $DATAP PSECT contains the value. Finally the (Real*8) value on top of the stack is moved to location DBLE ($DATA+#000020) by the module MOD$SM. 1.3 Compiled Code Routines. The symbolic names produced by the compiler are entry points into OTS modules residing in the system library. Entry points are grouped into modules containing similar code. For example, the MOD$SM entry point is in the module $DMOV7 together with the entry point MOD$SP. Such grouping occurs for two reasons. 1. Several entry points may perform essentially the same function, differing only in how arguments are passed to them. Such grouping saves substantially on code size. 2. Certain entry points are likely to be used together. Therefore, grouping into a single module reduces linker overhead when searching the library for unresolved references. 1.3.1 Entry Point Naming Convention. To allow the generated threaded code to be readable, entry point names follow naming conventions which are similar to that of a simple assembly language. The majority of the entry point names follow the form: mmt$xx where mm - the "op code", e.g. MO for move, AD for add, etc. t - the data type, e.g., F for real, I for integer, etc. xx - the "address mode" of the instruction. The following table summarizes the op-codes for the instructions which FORTRAN IV OTS (Draft) Page 1-3 Compiler Support Modules follow this format. OP-CODE OPERATION AD Addition CC Convert to complex CD Convert to double CF Convert to floating CI Convert to integer CL Convert to logical CM Compare CO Logical complement CP Copy DE Decriment DI Divide IC Increment JM Jump MO Move MU Multiply NG Negate the argument NM DO loop index modification NP DO loop index modification SA Subscript calculations SU Subtract SV Subscript calculations TA Transfer array operators TS Logical tests (compares agains zero) TV Variable transfer X? Raise to a power The data type (t) of an operation is determined from the following table. SYMBOL DATA TYPE C Complex D Real*8 F Real*4 I Integer (*2 or *4) L Logical (*1 or *4 unless noted) Q R Most of the modules which follow this naming convention have two arguments. The location of these arguments is specified by the "address mode" part of the symbolic name. Operands may reside on the stack (S), follow in immediately in memory (I), reside in memory (M), be a subroutine parameter (P), or be an intermediate result stored at a particular temporary address (A). The following table shows all combinations which occur in the OTS; not all combinations are permitted with every op-code and data type. Note that special entry points exist for commonly occurring sequences involving the constants 0 and 1 in various data types. FORTRAN IV OTS (Draft) Page 1-4 Compiler Support Modules ADDRESS MODES SECOND ARGUMENT ------------------------------------------------------------------ | Argument Argument Address Parameter Address | | on stack in next in next in next on stack| | word word word | ------------------------------------------------------------------ |Argument | SS | SI | SM | SP | SA | |on stack | | | | | | ------------------------------------------------------------------ |Argument | IS | II | IM | IP | IA | F |in next | | | | | | I |word | | | | | | R ------------------------------------------------------------------ S |Address | MS | MI | MM | MP | MA | T |in next | | | | | | |word | | | | | | ------------------------------------------------------------------ A |Parameter*| PS | PI | PM | PP | PA | R |in next | | | | | | G |word | | | | | | U ------------------------------------------------------------------ M |Moves 0 | 0S | | 0M | 0P | 0A | E |into 2nd | | | | | | N |argument | | | | | | T ------------------------------------------------------------------ |Moves R0 | RS | | RM | RP | RA | |into 2nd | | | | | | |argument | | | | | | ------------------------------------------------------------------ |Increments| 1S | 1I | 1M | 1P | 1A | |or decre- | | | | | | |ments 2nd | | | | | | |argument | | | | | | ------------------------------------------------------------------ |Address | VS | | | | | |in R0 | | | | | | ------------------------------------------------------------------ 1.4 Additional Routines. Although the majority of threaded code routines follow the above naming conventions, many do not. The following is a list of routines which do not follow the above naming conventions. Whereas most of the above modules are referenced only if threaded code is selected, many of the following routines are used for both threaded and inline code. In some cases, the same module has two entry points: one for use with threaded code, and one for use with inline code. The following list is by entry point. A cross-reference listing of entry points and modules may be found in Appendix B. FORTRAN IV OTS (Draft) Page 1-5 Compiler Support Modules 1.4.1 GOTO Statements Conditional branches are used for constructs of the form IF(...) GOTO... where the logical IF has been previously evaluated using one of the Compare or Test modules. BEQ$ : Branch if equal to zero BGE$ : Branch if greater than or equal BGT$ : Brach if greater than BLE$ : Branch if less than or equal BLT$ : Branch if less than BNE$ : Branch if not equal BRA$ : Unconditional branch (GOTO) JMC$ : Computed GOTO statement 1.4.2 Subroutine Support Modules CAI$ : CALL statement (subroutine name is parameter) CAL$ : CALL statement (normal) RET$ : Return from a subprogram $OTIS : Subroutine initialization (threaded code) $$OTIS : Subroutine initialization (inline code) 1.4.3 Logical Operators. LEQ$ : Equal to zero LGE$ : Greater than or equal LGT$ : Greater than LLE$ : Lessthan or equal LLT$ : Lessthan LNE$ : Not equal AND$ : Logical AND EQV$ : Logical function IOR$ : Inclusive OR XOR$ : Exclusive OR 1.4.4 Data Type Converstion. <<>> 1.4.5 I/O Conversion Routines. DCO$ : Formatted real and double output conversions ECO$ : Formatted real and double output conversions FCO$ : Formatted real and double output conversions GCO$ : Formatted real and double output conversions ICO$ : Formatted integer output conversion FORTRAN IV OTS (Draft) Page 1-6 Compiler Support Modules LCI$ : Logical input convertions LCO$ : Logical output convertions OCI$ : Formatted octal input conversions OCO$ : Formatted octal output conversions RCI$ : Formatted real and double input conversion 1.4.6 I/O Statement Support Routines. BKS$ : Backspace routine DEC$ : Decode routine DEF$ : Random access I/O DEO$ : Object time decode routine ENC$ : Encode routine ENO$ : object time encode routine EOF$ : End of file processor EOL$ : End of I/O list operator FND$ : Find for random I/O IBR$ : Object time read routine IBW$ : Object time write routine IFR$ : Initialize formatted read IFR$$: Initialize formatted read (not used in RT-11) IFW$ : Initilize formatted write IFW$$: Initialize formatted write (not used in RT-11) ILR$ : List directed input ILW$ : List directed output IRR$ : Random access I/O read IRW$ : Random access I/O write IUR$ : Unformatted I/O read IUW$ : Unformatted I/O write RWD$ : Rewind file ERR$ : ERR=... exit on READ/WRITE statements. END$ : END=... exit on READ/WRITE statements. 1.4.7 Miscellaneous. AIF$ : Arithmetic IF statement STK$ : Arithmetic Statement Function Returns FUD$ : Compiler generated error BAH$ : Pause processor END$ : End operation codes FOO$ : Stop processor ISN$ : Adjust ISN counter (unlabeled statement) LSN$ : Adjust ISN counter (labeled statement) PSE$ : Pause processor REL$ : Same as MOL$IS STP$ : Stop processor FORTRAN IV OTS (Draft) Page 1-7 Compiler Support Modules 1.5 Comparison of Inline and Threaded Code. An overview of the differences between inline and threaded code is contained in Chapter 2 of the RT-11/RSTS/E Fortran IV User's Guide. The following discussion contains additional details on the differences between the two types of generated code. 1.5.1 Program Size. <<>> 1.5.2 Execution Speed. <<>> 1.5.3 Hardware Considerations. <<>> 1.6 Details of Generated Threaded Code. As mentioned above, one of the chief advantages of threaded code over inline code is that it generally produces smaller sized executable code. Occasionally, very large programs may require "only a little more space" to fit in memory and execute. Assuming all of the standard techniques of suppressing ISN's, overlaying (including OTS modules as described in Chapter x), and other "tricks" have been employed, it may be possible to gain some space by modifying code sequences to avoid loading of some OTS modules. The following sections give Simple examples of Fortran statements and the threaded code entry point each generates. These entry points are grouped by module. By eliminating all coding sequences which generate symbols in a given module, it may be possible to suppress loading of that module. Obvious examples involve the replacement of complex arithmetic if only a few complex operations are needed. Less obvious, is the replacement of subroutine parameters by common blocks, to suppress loading of modules which operate on subroutine parameters. These examples are not exhaustive. It may require several tries to remove references to certain types of coding sequences. Consult Appendix A on module sizes to assess the possible gain from changes in code. In some cases (e.g., complex arithmetic), it may be that the resulting Fortran code requires more space without complex arithmetic than is taken up by the complex modules in the OTS. Note also, that arithmetic modules are always loaded since they are used internally by other OTS routines. FORTRAN IV OTS (Draft) Page 1-8 Compiler Support Modules Variable names in the following examples indicate data type according to: C - complex B - logical*1 D - double precision I - integer L - logical*4 R - real The code for logical*1 is also applicable for logical*4, however, only the first byte of the logical*4 will be affected. The letter P following any of the above letters means that the variable of that type is a subroutine parameter. The number appearing in parentheses refers to the note at the end of the section. 1.6.1 Multiplication and Division. For division, the first letter of the address mode is the location of the denominator; the second letter is the location of the numerator. For multiplication, the first and second letters correspond to the second and first factors of the multiplication, respectively. MODULES $CDIV - Complex divide DIC$SS C=(C-2)/(C1-3) (1) DIC$IS C=C/2 DIC$MS C=(C-3)/C1 (1) DIC$PS C=(C-3)/CP (1) $CMUL - Complex multiply MUC$SS C=(C-2)*(C1-3) (1) MUC$IS C=C*3 MUC$MS C=C*(C1-3) (1) MUC$PS C=(C-3)*CP (1) $DDIV - Double precision divide DID$SS D=(D-2.)/(D1-3.) (1) DID$IS D=D/2. DID$MS D=(D-3.)/D1 (1) DID$PS D=(D-3.)/CP (1) $DMUL - Double precision multiply MUD$SS D=(D-2)*(D1-3) (1) MUD$IS D=D*3 MUD$MS D=D*(D1-3) (1) MUD$PS D=(D-3)*DP (1) $FDIV - Real divide DIF$SS R=(R-2.)/(R1-3.) (1) DIF$IS R=R/2. DIF$MS R=(R-3.)/R1 (1) FORTRAN IV OTS (Draft) Page 1-9 Compiler Support Modules DIF$PS R=(R-3.)/RP (1) $FMULS - Real multiply MUF$SS R=(R-2.)*(R1-3.) (1) MUF$IS R=R*3. MUF$MS R=R*(R1-3.) (1) MUF$PS R=(R-3.)*RP (1) $IDIVS - Integer divide DII$SS I=(I-2)/(I1-3) (1) DII$IS I=I/2 DII$MS I=(I-3)/I1 (1) DII$PS I=(I-3)/IP (1) $IMUL - Integer multiply MUI$SS I=(I-2)*(I1-3) (1) MUI$IS I=I*3 MUI$MS I=I*(I1-3) (1) MUI$PS I=(I-3)*IP (1) 1 - Value in parenthesis is on the stack 1.6.2 Addition and Subtraction. The first letter of the address mode refers to the second operand; the second letter to the first operand. MODULES $ADDA - Real add to memory via address ADF$IA ADF$SA ADF$MA ADF$PA SUF$IA SUF$SA SUF$MA SUF$PA $ADDM - Real add to memory ADF$IM R=R+2. ADF$SM R=R+I (1) ADF$MM R=R1+R ADF$PM R=R+RP SUF$IM R=R-2 SUF$SM SUF$MM R=R-R1 SUF$PM $ADDP - Real add to parameter ADF$IP RP=RP+3 FORTRAN IV OTS (Draft) Page 1-10 Compiler Support Modules ADF$SP RP=(R+1.0)+RP (6) ADF$MP RP=RP+R1 ADF$PP RP=RP+RP1 SUF$IP RP=RP-3 SUF$SP SUF$MP RP=RP-R1 SUF$PP RP=RP-RP1 $CADD - Complex add and subtracts ADC$IS C=C+2. ADC$MS C=C+.1 (2) ADC$SS C=(C1+C2)+(C3+C4) (6) ADC$PS C=CP1+(C3+C4) (6) SUC$IS C=C-2. SUC$MS SUC$SS C=(C+1)-5. (5,6) SUC$PS $DADD - Double precision add and subtract ADD$IS D=D+2. ADD$MS D=D+.1 (3) ADD$SS D=(D1+D2)+(D3+D4) (6) ADD$PS D=DP+(D1+D2) (6) SUD$IS D=D-2. SUD$MS D=D-D1 SUD$SS D=(D1+D2)-(D3+D4) (6) SUD$PS $FADD - Real addition ADF$IS R=1.0+(R1+R2) (6) ADF$MS R=R1+R2+(R3+R4) (6) ADF$SS R=(R1+R2)+(R3+R4) (6) ADF$PS R=RP+(R1+R2)(6) SUF$IS R=(R+1)-5. (6) SUF$MS SUF$SS R=(R1+R2)-(R3+R4) (6) SUF$PS $IADDS - Integer adds ADI$SS I=(I+2)+(I1+3) (6) ADI$SA ADI$SM I=I+(I1+3) (6) ADI$IS I=L+1 (4) ADI$IA ADI$IM I=I+2 ADI$MS I=(I2+3)+I (6) ADI$MA ADI$MM I=I+I1 $IPADD - Integer adds with arguments ADI$SP IP=IP+(I+3) (6) ADI$IP IP=IP+3 ADI$MP IP=IP+I ADI$PS I=IP+(I1+I2) (6) ADI$PM I=IP+I FORTRAN IV OTS (Draft) Page 1-11 Compiler Support Modules ADI$PA ADI$PP IP1=IP1+IP2 $IPSUB - Integer subtracts with arguments SUI$SP IP1=(I+I1)-IP1 (6) SUI$IP IP1=3-IP1 SUI$MP IP1=I-IP1 SUI$PS I2=IP1-(I1+I2) (6) SUI$PM I=IP1-I SUI$PA SUI$PP IP1=IP1-IP2 $ISUBS - Integer subtracts SUI$SS I2=(I1+I2)-(I3-I4) (6) SUI$SA SUI$SM I2=(I2+I3)-I4 (6) SUI$IS I2=1-(I1+I2) (6) SUI$IA SUI$IM I=I-2 SUI$MS I=I1-(I2-I4) (6) SUI$MA SUI$MM I=I-I1 1 - I has been converted to real so is on the stack, R is in memory 2 - .1 is converted to complex so is on the stack, C is in memory 3 - .1 has been converted to double so is on the stack, D is in memory 4 - L has been converted to integer so is on the stack, 1 is immediate 5 - Must convert 5. to complex 6 - Value in parenthasis is on the stack 1.6.3 Relational Operators. In the following, code produced for Logical*1 variables would also be produced for Logical*4 variables, since only the low-order byte of a Logical*4 variable contains a value. Note that comparisons against the constants 0, 0.0, 0.0D0 and .FALSE. generate special (more efficient) code. However, this efficiency in execution is at the expense of loading another OTS module, which can cause an increase in program size. MODULES $CMPD - Double precision comparisons CMD$SS B=(D1+D2).LT.(D3+D4) CMD$IS B=3.DO.LT.(D3+D4) CMD$MS B=D1.LT.(D3+D4) CMD$PS B=DP1.LT.(D3+D4) CMD$SI B=(D4+D5).LT.3.0 CMD$II B=3.DO.LT.2.DO FORTRAN IV OTS (Draft) Page 1-12 Compiler Support Modules CMD$MI B=D.LT.3.DO CMD$PI B=DP1.LT.3.DO CMD$SM B=(D1+D7).LT.D CMD$IM B=3.DO.LT.D CMD$MM B=D.LT.D1 CMD$PM B=DP1.LT.D CMD$SP B=(D1+D8).LT.DP1 CMD$IP B=3.DO.LT.DP1 CMD$MP B=D.LT.DP1 CMD$PP B=DP1.LT.DP2 $CMPF - Real comparisons CMF$SS B=(R1+R2).LT.(R3+R4) CMF$IS B=3.0.LT.(R3+R4) CMF$MS B=R1.LT.(R3+R4) CMF$PS B=RP1.LT.(R3+R4) CMF$SI B=(R4+R5).LT.3.0 CMF$II B=3.0.LT.2.0 CMF$MI B=R.LT.3.0 CMF$PI B=RP1.LT.3.0 CMF$SM B=(R1+R7).LT.R CMF$IM B=3.0.LT.R CMF$MM B=R.LT.R1 CMF$PM B=RP1.LT.R CMF$SP B=(R1+R8).LT.RP1 CMF$IP B=3.0.LTRP1 CMF$MP B=R.LT.RP1 CMF$PP B=RP1.LT.RP2 $ICMPS - Integer comparisons CMI$SS B=(I1+I2).LT.(I3+I4) CMI$SI B=(I4+I5).LT.3 CMI$SM B=(I1+I7).LTI CMI$IS B=3.LT.(D3+D5) CMI$II B=3.LT.2 CMI$IM B=3.LT.I CMI$MS B=D1.LT.(D3+D4) CMI$MI B=I.LT.3 CMI$MM B=I.LT.I1 $IPCMP - Integer parameter comparisons CMI$PI B=IP1.LT.3 CMI$PM B=IP1.LT.I CMI$PP B=IP1.LT.IP2 CMI$PS B=IP1.LT.(I3+I5) CMI$MP B=I.LT.IP1 CMI$IP B=3.LT.IP1 CMI$SP B=(I1+I8).LT.IP1 $LCMPI - Immediate logical*1 comparisons CML$SI B=(B1.OR.B2).LT..TRUE. CML$MI B=B.LT..TRUE. $LCMPP - Logical*1 comparisons to parameter CML$SP B=(B1.OR.B2).LT.BP FORTRAN IV OTS (Draft) Page 1-13 Compiler Support Modules CML$IP B=.TRUE..LT.BP CML$MP B=B.LT.BP CML$PP B=BP1.LT.BP2 $LCMPS - Logical*1 comparisons to stack CML$SS B=(B1.OR.B2).LT.(B3.OR.B4) CML$MS B=B1.LT.(B2.OR.B3) CML$IS B=.TRUE..LT.(B1.OR.B2) CML$SM B=(B1.OR.B2).LT.B CML$MM B=(B.LT.B1 CML$IM B=.TRUE..LT.B $LPCMPS - Logical*1 parameter comparisons CML$PS B=BP.LT.(B1.OR.B2) CML$PI B=BP.LT..TRUE. CML$PM B=BP.LT.B $LTEST - Logical*1 test operators TSL$S B=(B.OR.B1).EQ..FALSE. TSL$M B=B.EQ..FALSE. TSL$I B=.FALSE..EQ..FALSE. TSL$P B=BP.EQ..FALSE. $TESTC - Complex test operators TSC$S B=(C+C1).LT.(0.0,0.0) TSC$M B=C.LT.(0.0,0.0) TSC$I B=(0.0,0.0).LT.(0.0,0.0) TSC$P B=BP.LT.(0.0,0.0) $TESTS - Integer, real, and double tests against 0 TSI$S B=(I+I1).LT.0 TSI$M B=I.LT.0 TSI$I B=0.LT.0 TSI$P B=IP.LT.0 TSF$S B=(R+R1).LT.0.0 TSF$M B=R.LT.0.0 TSF$I B=0.0.LT.0. TSF$P B=RP.LT.0.0 TSD$S B=(D+D1).LT.0.0D0 TSD$M B=D.LT.0.0D0 TSD$I B=0.0 D0.LT.0.0D0 TSD$P B=DP.LT.0.0D0 1.6.4 Exponentiation MODULES $XCI - Complex ** Integer XCI$ C=C**I (1) $XDD - Double precision ** Double Precision FORTRAN IV OTS (Draft) Page 1-14 Compiler Support Modules XDD$ D=D**D XFD$ R=R**D XDF$ D=D**R (2) $XDI - Double precision ** Integer XDI$ D=D**I (1) $XFF - Real ** Real XFF$ R=R**R (1) $XFI - Real ** Integer XFI$ R=R**I (1) $XII - Integer ** Integer XII$ I=I**I (1) 1 - The exponent is pointed to by the top of the stack, and the base is 2nd on the stack 2 - The exponent is on the top of the stack, and the base is 2nd on the stack 1.6.5 Move Operations Move operations typically account for a major part of most Fortran program generated code. Therefore, significantly more modularity and code optimization exists within the various modules for move operations. In particular, a special copy operation exists for duplicating an argument on the stack, and special modules for commonly used constant values exist. Again, execution speed is enhanced at the expense of program size. MODULES $COPY - Create copy of argument CPI$SM I1=(I+3)*(I+3) CPL$SM B1=(B+3)*(B+3) CPF$SM R1=(R+3)*(R+3) CPD$SM D1=(D+3)*(D+3) $DMOV1 - Move double precision immediate to stack MOD$IS D=10.D1+10.D2 $DMOV2 - Move double precision to R0 MOD$0S $DMOV3 - Move double precision zero or immediate to second argument MOD$0P MOD$0A D(J)=0 MOD$0M D=0 MOD$IP DP=1. MOD$IA D(J)=10.D1 MOD$IM D=1. FORTRAN IV OTS (Draft) Page 1-15 Compiler Support Modules $DMOV4 - Move double precision from stack via address MOD$SA D(J)=D(I) $DMOV5 - Move double precision to stack MOD$MS D=D+1. (1) MOD$SS MOD$PS DP=DP-1 MOD$VS $DMOV6 - Move double precision from memory and parameter MOD$MA D(J)=D2 MOD$MM D=D1 MOD$MP MOD$PA MOD$PM MOD$PP DP=DP2 $DMOV7 - Move double precision from stack MOD$SP DP=DP+1 MOD$SM D=D+1. (1) $DMOVR - Move double precision from R(0)-R(3) MOD$RS MOD$RM MOD$RP MOD$RA $FMOV1 - Move real stack to stack MOF$SS $FMOV2 - Move real to stack MOF$IS MOF$0S $FMOV3 - Move real to stack MOF$MS I=.1 (2) MOF$PS R=(RP*2)+1 $FMOV4 - Move real from stack MOF$SA RP(J)=RP(I) $FMOV5 - Move real from immediate MOF$IA R(J)=1 $FMOV6 - Move real from stack MOF$SM R=I (3) MOF$SP RP=RP/R $FMOV7 - Move real from immediate MOF$IM R=1. MOF$IP RP=1. $FMOV8 - Move real zero to second argument MOF$0M R=0 FORTRAN IV OTS (Draft) Page 1-16 Compiler Support Modules MOF$0A R(J)=0 MOF$0P RP=0 $FMOV9 - Move real from memory and parameter MOF$MM R=R1 MOF$MA R(J)=R(2) MOF$MP MOF$PM R=RP-1 MOF$PA RP=RP2 MOF$PP RP=RP2 $FMOVR - Move real from R(0)-R(1) MOF$RS R(J)=ROOT(R) (7) MOF$RM MOF$RA MOF$RP $IMOVR - Move integer from R(0) MOI$RS R=R2-ROOT(I) (7) MOI$RM R=ROOT(M) (7) MOI$RA MOI$RP MOL$RS $IMOVS - Integer move MOI$SS MOI$SM I=.1 (4) MOI$SA I(I1)=I(I2) (6) MOI$IS MOI$IM J=I+5 MOI$IA I(J)=1 MOI$MS R=I (5) MOI$MM I=I1 MOI$MA I(J)=K MOI$0S MOI$0M I=0 MOI$0A I(J)=0 MOI$1S MOI$1M I=1 MOI$1A $IPMOV - Integer and pararmeter moves MOI$SP IP=IP+1 MOI$IP IP=1 MOI$MP IP=I MOI$PS IP=IP+1 MOI$PM I=IP MOI$PA IP(I)=IP2 MOI$PP IP=IP2 MOI$0P IP=0 MOI$1P IP=1 $LMOVR - Moves of logical*1 results MOL$RA MOL$RP FORTRAN IV OTS (Draft) Page 1-17 Compiler Support Modules MOL$RM $LMOVS - Logical*1 moves MOL$SM B=B+1 MOL$SA B(I)=B(I2) MOL$SP BP=BP+1 MOL$IM B=.true. MOL$IP BP=I MOL$IA B(J)=0 MOL$MP MOL$MM B=B1 MOL$MA B(J)=B2 MOL$MP MOL$MS MOL$PM MOL$PA MOL$PP BP=BP2 MOL$PS BP=BP+1 1 - 1. has been converted to double so is on the stack, D in memory 2 - .1 is being put on stack for conversion to integer 3 - I was on stack for conversion to real, is now being moved into R in memory 4 - .1 was on stack for conversion to integer, is now being moved into memory 5 - I was on stack for conversion to real is now being moved to memory 6 - The value of I(I2) is on the stack and the address of X(I1) is on the stack 7 - ROOT is a function 1.6.6 Subscript Calculations Subscript calculations differ according to the dimension of the array, use of subscript vectoring for multidimensional arrays, and the size of the data elements. In addition module sizes vary slightly according to whether bounds checking has been incorporated or not. <<<<< examples will be revised to better distinguish SA vs. SV>>>>> MODULES $DVEC - Double precision subscript operators SAD$IM FORTRAN IV OTS (Draft) Page 1-18 Compiler Support Modules SAD$MM D(J)=D2 SAD$SM D2=D(I+J) SVD$IM SVD$MM D(J)=D(I) SVD$SM D2=D(I+J) $FVEC - *4 subscript operators SAF$IM SAF$MM R(I)=R2 (1) SAF$SM R(I+J)=R2 SVF$IM SVF$MM R(J)=R(I) (2) SVF$SM R2=R(I+J) $IVEC - Integer subscript operators SAI$IM SAI$MM I(J)=I(2) SAI$SM SVI$IM SVI$MM I(J)=I(J2) SVI$SM $LVEC - Logical*1 subscript operators SAL$IM SAL$MM L(J)=L2 SAL$SM SVL$IM SVL$MM SVL$SM $DVECC - Double precision subscript operators involving parameters SAD$IP DP(24)=D2 SAD$MP SAD$SP DP(I+J)=D2 SVD$IP D2=DP(24) SVD$MP SVD$SP D2=DP(I+J) $FVECC - Real subscript operators involving parameters SAF$IP DP(24)=D2 SAF$MP SAF$SP RP(I+J)=R2 SVF$IP R2=RP(24) SVF$MP SVF$SP R2=RP(I+J) $IVECC - Integer subscript operators involving parameters SAI$IP IP(24)=I2 SAI$MP SAI$SP IP(K+J)=I2 SVI$IP I2=I(22) SVI$MP SVI$SP I2=IP(J+K) $LVECC - Logical*1 subscript operators involving parameters FORTRAN IV OTS (Draft) Page 1-19 Compiler Support Modules SAL$IP BP(22)=B2 SAL$MP SAL$SP BP(I+J)=B2 SVL$IP B2=BP(24) SVL$MP SVL$SP B2=BP(I+J) $DVECP - Double subscript operators involving parameters SAD$PM D(IP)=D1 SAD$PP SVD$PM D1=D(IP) SVD$PP $FVECP - Real subscript operators involving parameters SAF$PM R(IP)=R2 SAF$PP SVF$PM R2=R(IP) SVF$PP $IVECP - Integer subscript operators involving parameters SAI$PM I(IP)=I2 SAI$PP SVI$PM I2=I(IP) SVI$PP $LVECP - Logical*1 subscript operators involving parameters SAL$PM B(IP)=B1 SAL$PP SVL$PM B1=B(IP) SVL$PP $QPVEC - Logical*4 and integer*4 subscript operators involving parameters SVQ$PM SVQ$PP $QVEC - Logical*4 and integer*4 subscript operators SVQ$IM SVQ$SM SVQ$MM $QVECP - Logical*4 and integer*4 subscript operators involving parameters SVQ$IP SVQ$SP SVQ$MP 1 - The address of R(J) is on the stack 2 - The value of X(I) is on the stack FORTRAN IV OTS (Draft) Page 1-20 Compiler Support Modules 1.6.7 Miscellaneous Operations MODULES $CNEG - Negate complex value NGC$M C=-C NGC$S C=-C+C2 (1) NGC$P CP1=-CP2 NGC$A $FNEG - Negate real value NGF$S R=-R+R2 NGF$M R=-R NGF$A NGF$P RP1=-RP2 NGD$S D=-D+D2 NGD$M D=-D NGD$A NGD$P DP1=-DP2 $INEG - Negate integer value NGI$S I=-I+I2 NGI$M I=-I NGI$A NGI$P IP1=-IP2 $INCR - Increment and decrement integer values ICI$S I=(I+1)*8 ICI$M I=I+1 ICI$A ICI$P IP1=IP1+1 DCI$S I=(I-1)*8 DCI$M I=I-1 DCI$A DCI$P IP2=IP2-1 $LNOTS - Logical not operators COI$S I=.NOT.(I+I1) COI$M I=.NOT.I COI$P COI$A COL$S B=.NOT.(B.OR.B1) COL$M B=.NOT.B COL$P COL$A 1 - C is first moved to the stack for later adition to c2 CHAPTER 2 Fortran Library Functions All functions in FORTRAN assume that R5 points to an argument block that contains the number of arguments passed followed by the addresses of the arguments. Functions return via the RTS PC instruction. The value is returned via the registers. For example, an integer function returns a value in R0, and a double precision function returns a value in registers R0-R3. The compiler sets up the argument block by generating a series of REL$ calls to put arguments onto the stack. It then generates a CAL$ call followed by the number of arguments given and the name of the function (the function name is a global). A move is then generated to move the result out of the register(s). The following is a list of the FORTRAN functions. MODULE gives the name of the module in which the function is defined. REFERENCES lists entrypoints, external to the module, that are referenced by the module when the function is called. In some cases these entrypoints are called only under certain hardware configurations, these are noted by a conditional statement such as "If no FPU:". FUNCTION MODULE REFERENCES ABS $ABS AIMAG $AIMAG AINT $AINT ALOG $ALOG If no FPU: $ADR,$DVR,$IR,$MLR,$SBR ALOG10 $ALOG If no FPU: $ADR,$DVR,$IR,$MLR,$SBR AMAX0 $AMIN0 $IR,$POPR3 AMAX1 $AMAX1 $CMR,$RI AMIN0 $AMIN0 $IR,$POPR3 AMIN1 $AMAX1 $CMR,$RI AMOD $AMOD $DVR,$INTR,$MLR,$POPR3,$SBR ATAN $ATAN If no FPU: $ADR,$DVR,$MLR,$POPR3,$SBR ATAN2 $ATAN If no FPU: $ADR,$DVR,$MLR,$POPR3,$SBR CCOS $CSIN COS,EXP,SIN,$ADR,$DVR,$FCALL,$MLR,$SBR CEXP $CEXP COS,EXP,MOF$RS,SIN,$FACLL,$MLC,$MLR,$POPR4,$SBR CLOG $CLOG ALOG,ATAN2,CABS,$FCALL CONJC $CONJC COS $SIN If no FPU: $ADR,$DVR,$INTR,$MLR,$SBR CSIN $CSIN COS,EXP,SIN,$ADR,$DVR,$FCALL,$MLR,$SBR FORTRAN IV OTS (Draft) Page 2-2 Fortran Library Functions CSQRT $CSQRT $ABS,$ADR,$IVR,$FCALL DABS $DABS SQR,$ADR,$DVR,$FCALL,$MLR DATAN $DATAN If no FPU: $ADD,$DVD,$MLD,$POPR4,$SBD DATAN2 $DATAN If no FPU: $ADD,$DVD,$MLD,$POPR4,$SBD DBLE* $DBLE DCOS $DSIN If no FPU: $ADD,$DINT,$DVD,$MLD,$POPR4,$SBD DEXP $DEXP If no FPU: $ADD,$DI,$DVD,$ID,$MLD,$POPR4,$SBD DIM $DIM $SBR DLOG $DLOG If no FPU: $ADD,$DVD,$ID,$MLD,$POPR4,$SBD DLOG10 $DLOG If no FPU: $ADD,$DVD,$ID,$MLD,$POPR4,$SBD DMAX1 $DMIN1 $CMD DMIN1 $DMIN1 $CMD DMOD $DMOD $DVD,$DINT,$MLD,$SBD DSIGN $DSIGN DSIN $DSIN If no FPU: $ADD,$DINT,$DVD,$MLD,$POPR4,4SBD DSQRT $DSQRT If no FPU: $ADD,$DVD EXP $EXP If no FPU: $ADR,$DVR,$IR,$MLR,$RI,$SBR FLOAT* $FLOAT $IR,$POPR3 IABS $IABS IDIM $IDIM IDINT** $INT $RI IFIX* $IFIX $RI INT** $INT $RI ISIGN $ISIGN MAX0 $MAX0 MAX1 $AMAX1 $CMR,$RI MIN0 $MIN0 MIN1 $AMAX1 $CMR,$RI MOD $MOD $DVI,$MLI RAN $RAN REAL $REAL SIGN $SIGN SIN $SIN If no FPU: $ADR,$DVR,$INTR,$MLR,$SBR SNGLE $SNGLE SQRT $SQRT If FIS: $ADR,$DVR TANH $TANH EXP,MOF$RS,$ADR,$DVR,$FCALL,$MLR,$SBR * These routines exist but are never called. Instead the compiler calls the appropriate conversion routine directly. ** These functions generate blocks of code that can be avoided by direct conversions. For example, FORTRAN programs should use I=R instead of I=INT(R) or in MACRO simply call $RI. CHAPTER 3 Use of Compiled Code Support Routines 3.1 Introduction Many of the modules for compiled code support may also be used by the Assembly Language programmer to perform common operations. Examples include data type conversion and routines for emulating floating point arithmetic on machines without floating point hardware. This chapter provides the necessary information to use these support modules from assembly language code. 3.2 OTS Initialization <<< to be completed later>>> 3.3 Data Type Conversion Modules exist within the OTS for performing data conversions. The code within these modules is hardware dependent. Therefore by using these modules for data conversion, the assembly language programmer accomplishes two things. First the resulting code is transportable to machines with different hardware configurations (object files must simply be re-linked with the appropriate OTS). Second, the resulting code will typically be smaller since code already loaded and used by the Fortran part of a program is being used, rather than duplicating functionality in special subroutines. <<< remainder to be completed>>>> APPENDIX A OTS Module Sizes The following table list OTS module size by PSECT. If a module contains code or data in more than one PSECT, each is listed. In this case, the total module size is that obtained by adding the contribution to each PSECT. The sizes are in decimal words. A.1 OTSCOM (Hardware Independent Modules). Mod Psect Size Mod Psect Size Mod Psect Size $ABS OTS$I 7 $AIF OTS$I 6 $AIMAG OTS$I 6 $AMAX1 OTS$I 60 $AMIN0 OTS$I 24 $AMOD OTS$I 23 $ASFRE OTS$I 8 $ASSIG OTS$I 138 $AOTS OTS$S 1 $BACKS OTS$I 100 $BITDI OTS$I 12 $BRAS OTS$I 22 $CABS OTS$I 74 $CALL OTS$I 15 $CEXIT OTS$I 2 $CEXP OTS$I 36 $CLOG OTS$I 34 $CLOSE OTS$I 178 OTS$P 20 CLOSTM OTS$I 39 $CLS OTS$I 10 $CMPD OTS$I 88 OTS$D 4 $CMPF OTS$I 67 $CMPLX OTS$I 9 $CNEG OTS$I 16 $CONJG OTS$I 10 $CONV5 OTS$I 18 $CONV6 OTS$I 31 $CONVI OTS$I 131 $CONVL OTS$I 35 OTS$P 20 OTS$P 20 $COPY OTS$I 14 $CSIN OTS$I 120 $CSQRT OTS$I 69 $DABS OTS$I 9 $DATE OTS$I 65 $DBLE OTS$I 7 $DIM OTS$I 20 $DMIN1 OTS$I 46 $DMOD OTS$I 31 $DMOV1 OTS$I 5 $DMOV2 OTS$I 5 $DMOV3 OTS$I 19 $DMOV4 OTS$I 8 $DMOV5 OTS$I 12 $DMOV6 OTS$I 19 $DMOV7 OTS$I 8 $DMOVR OTS$I 16 $DSIGN OTS$I 14 $DUMPL OTS$I 43 $ENCOD OTS$I 65 $ENDER OTS$I 26 EOF OTS$I 56 $EOL OTS$I 83 ERRS OTS$I 960 OTS$P 19 $ERRSN OTS$I 16 ERRSS OTS$I 139 $ERRTS OTS$I 35 EXTEND OTS$P 21 $FCALL OTS$I 7 OTS$I 40 $FCHNL OTS$I 33 $FIND OTS$I 69 $FIO OTS$I 484 $FLOAT OTS$I 8 OTS$P 20 $FMOV1 OTS$I 5 $FMOV2 OTS$I 6 $FMOV3 OTS$I 7 $FMOV4 OTS$I 6 $FMOV5 OTS$I 4 $FMOV6 OTS$I 6 $FMOV7 OTS$I 8 $FMOV8 OTS$I 8 $FMOV9 OTS$I 17 $FMOVR OTS$I 11 $FNEG OTS$I 15 $FUD OTS$I 5 $GETFI OTS$I 15 $GETRE OTS$I 68 $GOTO OTS$I 16 $IABS OTS$I 8 OTS Module Sizes Page A-2 Mod Psect Size Mod Psect Size Mod Psect Size $IADDS OTS$I 18 $IBR OTS$I 25 $IBW OTS$I 27 $ICMPS OTS$I 18 $IDATE OTS$I 37 $IDIM OTS$I 10 $IFIX OTS$I 11 $IFR OTS$I 26 $IFW OTS$I 39 $LISTI OTS$I 361 $LISTO OTS$I 240 $IMOVR OTS$I 7 OTS$P 20 OTS$P 20 $IMOVR OTS$I 7 $IMOVS OTS$I 33 $INCR OTS$I 14 $INEG OTS$I 7 $INITI OTS$I 37 $INT OTS$I 11 $IPADD OTS$I 19 $IPCMP OTS$I 19 $IPMOV OTS$I 26 $IPSUB OTS$I 19 $ISIGN OTS$I 12 $ISNLS OTS$I 56 $ISUBS OTS$I 18 $LCMPS OTS$I 13 $LCMPI OTS$I 4 $LCMPP OTS$I 9 $LMOVR OTS$I 5 $LMOVS OTS$I 39 $LNOTS OTS$I 16 $LOADS OTS$I 12 $LPCMP OTS$I 10 $LTEST OTS$I 10 $MAX0 OTS$I 10 $MIN0 OTS$I 10 $MOD OTS$I 15 $NOVIR OTS$I 1 $NXT1 OTS$I 28 $NXT2 OTS$I 28 $NXT3 OTS$I 30 $NXT4 OTS$I 24 $OBJEN OTS$I 31 $OBJFM OTS$I 339 $OPEN OTS$O 271 OPNCLO OTS$I 77 OPNSTM OTS$I 299 $PAUSE OTS$I 50 $POPR OTS$I 8 OTS$D 18 $PSHD1 OTS$I 28 $PSHD2 OTS$I 18 $PSHD3 OTS$I 20 $PSHF1 OTS$I 20 $PSHF2 OTS$I 12 $PSHF3 OTS$I 14 $PUTRE OTS$I 97 $QPVEC OTS$I 14 OTS$P 20 $QVEC OTS$I 8 $QVECP OTS$I 8 $RAN OTS$I 42 $RANDU OTS$I 45 $REAL OTS$I 5 $RETD OTS$I 19 $RETDS OTS$I 13 $RETS OTS$I 20 $REWIN OTS$I 37 $RIO OTS$I 210 $RWBLK OTS$I 140 $SAVRE OTS$I 56 $SAV4R OTS$I 26 $SETER OTS$I 21 $SIGN OTS$I 12 SIMRT OTS$P 20 $SNGL OTS$I 14 $STOP OTS$I 55 $STACK 64 OTS$P 20 OTS$S 97 $SUBR OTS$I 41 $TANH OTS$I 121 OTS$I 553 $TCMPL OTS$I 45 $TESTC OTS$I 14 $TESTS OTS$I 13 $TRARY OTS$I 88 $TVIRD OTS$I 86 $TVIRF OTS$I 85 $TVIRI OTS$I 78 $TVIRL OTS$I 78 $TVIRQ OTS$I 92 $TVIRC OTS$I 111 $UIO OTS$I 252 OTS$P 20 $UIO OTS$I 252 $USERE OTS$I 10 $VCTRA OTS$I 40 OTS$P 20 $VINTX OTS$I 1 $VINTN OTS$I 91 $VIRDN OTS$I 103 $VIRFN OTS$I 88 OTS$D 1 $VIRIN OTS$I 79 $VIRLN OTS$I 88 OTS$P 21 $VIRQN OTS$I 79 $VINTP OTS$I 65 $VIRDP OTS$I 116 $VIRFP OTS$I 100 OTS$D 1 $VIRIP OTS$I 88 $VIRLP OTS$I 87 $VIRQP OTS$I 90 $VTRAN OTS$I 61 WAIT OTS$I 17 $XCI OTS$I 138 $XDD OTS$I 95 $XFF OTS$I 54 A.1.1 Hardware Dependent Modules. When determining the size of OTS modules for NHD/EAE/EIS hardware, it is usually necessary to include the following modules: $DADD if any Real*8 additon/subtraction $DDIV if any Real*8 division $DMUL if any Real*8 multiplication $FADD if any Real*4 addition/subtraction OTS Module Sizes Page A-3 $FDIV if any Real*4 divsion $FMULS if any Real*4 multiplication These modules contain the emulation code for the respective arithmetic operations and are referenced by other OTS modules requiring such arithmetic (e.g., SQRT function). Mod Psect Size for each hardware NHD EAE EIS FIS FPU $ADDA OTS$I 27 27 27 54 46 $ADDM OTS$I 28 28 28 46 46 $ADDP OTS$I 28 28 28 45 54 $AINT OTS$I 39 41 33 33 15 $ALOG OTS$I 120 120 120 120 59 $ATAN OTS$I 215 215 215 215 115 $CADD OTS$I 83 83 83 83 53 $CDIV OTS$I 129 129 129 129 46 $CMUL OTS$I 82 82 82 82 35 $CONV1 OTS$I 12 12 12 12 10 $CONV2 OTS$I 55 59 53 53 30 $CONV3 OTS$I 43 43 43 43 17 $CONV4 OTS$I 18 18 18 18 12 $CONVF OTS$I 485 485 503 503 503 OTS$P 20 20 20 20 20 $DADD OTS$I 326 371 323 323 49 $DATAN OTS$I 361 361 361 361 154 $DDIV OTS$I 247 247 247 247 24 $DEXP OTS$I 226 226 226 226 114 $DINT OTS$I 53 55 41 41 11 $DLOG OTS$I 194 194 194 194 92 $DMUL OTS$I 222 296 289 289 23 $DSIN OTS$I 184 184 184 184 97 $DSQRT OTS$I 66 66 66 66 41 $EXP OTS$I 112 112 112 112 74 $FADD OTS$I 176 176 176 36 49 $FDIV OTS$I 105 145 138 17 18 $FMULS OTS$I 114 142 127 17 17 $IDIVS OTS$I 42 19 15 15 15 $IMUL OTS$I 30 19 14 14 14 OTINIT . ABS. 16 16 16 16 16 OTS$I 582 591 582 614 633 OTS$D 3 3 3 3 3 OTS$P 21 21 21 21 21 $SIN OTS$I 125 125 125 125 66 $SQRT OTS$I 62 62 62 44 30 $XDI OTS$I 132 132 132 132 40 $XFI OTS$I 92 92 92 92 38 $XII OTS$I 67 67 49 49 49 OTS Module Sizes Page A-4 A.1.2 Subscript Calculations. Mod Psect Size Mod Psect Size Bounds No Bounds Bounds No Bounds $DPVEC OTS$I xxx xxx $DVEC OTS$I xxx xxx $DVECP OTS$I xxx xxx $FPVEC OTS$I xxx xxx $FVEC OTS$I xxx xxx $FVECP OTS$I xxx xxx $IPVEC OTS$I xxx xxx $IVEC OTS$I xxx xxx $IVECP OTS$I xxx xxx $LPVEC OTS$I xxx xxx $LVEC OTS$I xxx xxx $LVECP OTS$I xxx xxx #######################################################################################################################################################################################################################################################################################################################################################################################################

База данных защищена авторским правом © 2016
звярнуцца да адміністрацыі

    Галоўная старонка