/***************************************************************************** * CONFIGURATION SECTION * If one of the following options is not available with the selected * compiler, the corresponding macro is ignored. * If one of the options is not selectable within the source text, but may be * selected global, e.g. HM2: ``$i/$w'' --> __LONG_WHOLE__, the global * setting and the macro have to correspond! * Otherwise the options are set automatically corresponding to the following * macros together with other default switches by the macros __DEF_SWITCHES__ * and __IMP_SWITCHES__ (see definitions at the end of this file). *****************************************************************************/ /* function results on stack (#if 1) or in register D0/D1 (#if 0) */ #if 0 /* HM2 */ #define __RES_ON_STACK__ #endif /* CARDINAL/INTEGER are compatible with LONGCARD/INT (#if 1) or SHORTCARD/INT (#if 0) */ #if 1 /* HM2, MM2 */ #define __LONG_WHOLE__ #endif /* REAL is compatible with LONGREAL (#if 1) or SHORTREAL (#if 0) */ #if 0 /* HM2 */ #define __LONG_REAL__ #endif /* Use register vars if __REG__ (#if 1) or not (#if 0) */ #if 1 /* HM2, MM2 */ #define __REG_VARS__ #endif /* Produce Rangechecks for __DEBUG__ (#if 1) or not (#if 0) */ #if 0 /* HM2, MM2, TDIM2 */ #define __RANGE_CODE__ #endif /* Produce Stackchecks for __DEBUG__ (#if 1) or not (#if 0) */ #if 0 /* HM2, MM2, TDIM2 */ #define __STACK_CODE__ #endif /* Produce Debugcode for __DEBUG__ (#if 1) or not (#if 0) */ #if 0 /* HM2, MM2 */ #define __DEBUG_CODE__ #endif /**************************************************************************** * one of the following macros specifying the compiler must be defined (with * commandline option -D): * * LPRM2 : LPR-Modula, Version 1.4 * SPCM2 : SPC-Modula, Version 2.0 (treated like LPRM2) * HM2 : Haenisch-Modula, Version >= 5.10, 13.4.93 * MM2 : Megamax-Modula, Version >= 4.2 * TDIM2 : TDI-Modula, Version 3.01 *****************************************************************************/ #if !( (defined LPRM2)\ || (defined SPCM2)\ || (defined MM2)\ || (defined HM2)\ || (defined TDIM2)\ ) # error *** compiler not (yet) supported #endif #if (defined LPRM2) || (defined SPCM2) || (defined MM2) || (defined TDIM2) \ || (defined HM2) || (defined FTLM2) # define __GEMDOS__ #endif #if (defined TSM2_1) || (defined TSM2_2) || (defined TSM2_3) # define TSM2 #endif #if (defined FSTM2) || (defined TSM2) || (defined LM2) # define __PCDOS__ #endif #if 0 # define __UNIX__ #endif #if 0 /* sad, but true... */ # define ISOM2 #endif /* Within the declaration of a procedure, parameters may be of the procedure * type itself (ISO), i.e. the procedure type may be used before fully * declared. */ #define ISO_recursive_proc_decl \ ((defined ISOM2) || (defined MM2) || (defined HM2)) /* Values of equal procedure types may be tested for equality (ISO). */ #define ISO_proc_compare \ ((defined ISOM2) || (defined MM2) || (defined HM2)) /* Values of equal opaque types may be tested for equality (ISO). */ #define ISO_opaque_compare \ ((defined ISOM2) || (defined MM2) || (defined HM2) || (defined LPRM2) || \ (defined SPCM2)) /* Opaque types may be declared as an imported type in the corresponding * implementation module, i.e. they don't have to be fully specified (ISO). */ #define ISO_opaque_far_imp \ ((defined ISOM2) || (defined LPRM2) || (defined SPCM2) || (defined HM2)) /* Procedure constants are available (ISO). */ #define ISO_proc_const \ ((defined ISOM2) || (defined FTLM2) || (defined TSM2)) /* Array and record constructors are available (ISO). */ #define ISO_value_constructor \ ((defined ISOM2) || (defined MM2) || (defined HM2)) /* VAL is universal converting function (ISO), e.g. VAL(REAL,) * is equivalent to FLOAT(). */ #define ISO_val \ ((defined ISOM2) || (defined MM2) || (defined HM2)) /* Identifiers may contain underscores (underlines?) at any position (ISO). */ #define ISO_underscore \ ((defined ISOM2) || (defined MM2) || (defined HM2)) /* Type PACKEDSET for sets of bits is available (ISO). */ #define ISO_packedset \ ((defined ISOM2) || (defined HM2)) /* ISO-procedures for arithmetic on pointers are available (ISO). */ #define ISO_ptr_arith \ ((defined ISOM2)) /* Functions may return arrays and records (ISO). */ #define ISO_struct_return \ ((defined ISOM2) || (defined MM2) || (defined HM2) || (defined FTLM2)) /* SET OF CHAR may be defined (ISO). */ #define ISO_char_set \ ((defined ISOM2) || (defined MM2) || (defined HM2) || (defined TDIM2) || \ (defined FTLM2)) /* Type SYSTEM.LOC is available (ISO). */ #define ISO_loc \ ((defined ISOM2) || (defined (MM2) || (defined HM2)) /* Types COMPLEX and LONGCOMPLEX are available (ISO) */ #define ISO_complex 0 /* Element 0 is most significant bit (only sets with no more than 32 elements). */ #define reverse_set \ (defined FTLM2) /* Sets may have 32 elements. */ #define long_set \ ((defined ISOM2) || (defined HM2) || (defined SPCM2) || (defined MM2) || \ (defined TDIM2) || (defined FTLM2)) /* No colon necessary with tagless variants (PIM2). */ #define no_empty_tag_colon 0 /* Only subranges are valid index types. */ #define only_subrange_index \ ((defined LPRM2) || (defined SPCM2)) /* Standard procedures MIN and MAX are not available. */ #define no_MIN_MAX 0 /* Parameter type REF is available. */ #define has_REF \ (defined MM2) /* Exportlist in definition module is necessary (PIM2). */ #define export 0 /* Problems with reexported identifiers. */ #define no_reexport \ (defined FTLM2) #define odd_arrays \ ((defined MM2) || (defined TDIM2)) #define align_byte_after_odd 0 /* Only parameters of type ARRAY OF CHAR are concerned */ #if (defined TDIM2) # define REF VAR #elif !has_REF # define REF #endif #if !ISO_packedset # define PACKEDSET SET #endif /* If there is a special notation for LONGCARD/INT-constants */ #if (defined LPRM2) || (defined SPCM2) # define LC(_NUM) _NUM ## D # define LIC(_NUM) _NUM ## D #elif (defined TDIM2) # define LC(_NUM) LONGCARD(_NUM) # define LIC(_NUM) LONGINT(_NUM) #else # define LC(_NUM) _NUM # define LIC(_NUM) _NUM #endif /* If there is a special notation for LONGREAL-constants */ #if (defined LPRM2) || (defined SPCM2) # define LRC(_MANT,_EXP) _MANT ## D ## _EXP #elif (defined TDIM2) /* not for CONST-declarations, only single precision */ # define LRC(_MANT,_EXP) LONG(_MANT ## E ## _EXP) #else # define LRC(_MANT,_EXP) _MANT ## E ## _EXP #endif #if no_empty_tag_colon # define TAG_COLON #else # define TAG_COLON : #endif /* If VAL has to be imported from SYSTEM */ #if (defined LPRM2) || (defined SPCM2) # define VAL_INTRINSIC FROM SYSTEM IMPORT VAL; #else # define VAL_INTRINSIC #endif #if (defined FTLM2) || (defined TDIM2) /* 32 bit --> 16 bit does not work with FTLM2 version 1.18 ! */ # define VAL(_TYPE,_EXPR) _TYPE(_EXPR) #endif /* Emulation of ISO-function CAST */ #if (defined ISOM2) || (defined MM2) || (defined HM2) # define CAST_IMPORT FROM SYSTEM IMPORT CAST; #elif (defined LPRM2) || (defined SPCM2) # define CAST_IMPORT # define CAST(_TYPE,_EXPR) VAL(_TYPE,_EXPR) #else # define CAST_IMPORT # define CAST(_TYPE,_EXPR) _TYPE(_EXPR) #endif /* Emulation of ISO-function INT */ #if (defined FTLM2) # define INT(_EXPR) SHORT(LONGINT(_EXPR)) #elif !((defined ISOM2) || (defined HM2)) # define INT(_EXPR) VAL(INTEGER,_EXPR) #endif /* If NEW and DISPOSE are not available */ #if (defined LPRM2) /* # define Storage Heap */ /* # define ALLOCATE Allocate */ /* # define DEALLOCATE Deallocate */ # define NEW(_PTR) ALLOCATE(_PTR,SIZE(_PTR ## ^)) # define DISPOSE(_PTR) DEALLOCATE(_PTR,SIZE(_PTR ## ^)) #elif (defined SPCM2) # define NEW(_PTR) ALLOCATE(_PTR,SIZE(_PTR ## ^)) /* # define DISPOSE(_PTR) DEALLOCATE(_PTR) only with original 'Storage' */ # define DISPOSE(_PTR) DEALLOCATE(_PTR,SIZE(_PTR ## ^)) #endif /* Arithmetic with pointers */ #if ISO_ptr_arith # define PTR_ARITH_IMPORT FROM SYSTEM IMPORT ADDADR,SUBADR,DIFADR,MAKEADR; #elif (defined LPRM2) || (defined SPCM2) # define PTR_ARITH_IMPORT # define ADDADR(_PTR,_ADD) (VAL(ADDRESS,_PTR)+VAL(ADDRESS,_ADD)) # define SUBADR(_PTR,_SUB) (VAL(ADDRESS,_PTR)-VAL(ADDRESS,_SUB)) # define DIFADR(_PTR1,_PTR2) (VAL(LONGINT,_PTR1)-VAL(LONGINT,_PTR2)) # define MAKEADR(_EXPR) VAL(ADDRESS,_EXPR) #elif (defined HM2) # define PTR_ARITH_IMPORT # define ADDADR(_PTR,_ADD) (ADDRESS(_PTR)+VAL(LONGCARD,_ADD)) # define SUBADR(_PTR,_SUB) (ADDRESS(_PTR)-VAL(LONGCARD,_SUB)) # define DIFADR(_PTR1,_PTR2) (LONGINT(_PTR1)-LONGINT(_PTR2)) # define MAKEADR(_EXPR) VAL(ADDRESS,_EXPR) #elif (defined MM2) # define PTR_ARITH_IMPORT # define ADDADR(_PTR,_ADD) (ADDRESS(_PTR)+VAL(LONGCARD,_ADD)) # define SUBADR(_PTR,_SUB) (ADDRESS(_PTR)-VAL(LONGCARD,_SUB)) # define DIFADR(_PTR1,_PTR2) (LONGINT(_PTR1)-LONGINT(_PTR2)) # define MAKEADR(_EXPR) ADDRESS(VAL(LONGCARD,_EXPR)) #elif (defined FTLM2) # define PTR_ARITH_IMPORT # define ADDADR(_PTR,_ADD) (ADDRESS(_PTR)+LONGCARD(_ADD)) # define SUBADR(_PTR,_SUB) (ADDRESS(_PTR)-LONGCARD(_SUB)) # define DIFADR(_PTR1,_PTR2) (LONGINT(_PTR1)-LONGINT(_PTR2)) # define MAKEADR(_EXPR) ADDRESS(_EXPR) #elif (defined TDIM2) # define PTR_ARITH_IMPORT # define ADDADR(_PTR,_ADD) (ADDRESS(_PTR)+ADDRESS(_ADD)) # define SUBADR(_PTR,_SUB) (ADDRESS(_PTR)-ADDRESS(_SUB)) # define DIFADR(_PTR1,_PTR2) (LONGINT(_PTR1)-LONGINT(_PTR2)) # define MAKEADR(_EXPR) ADDRESS(_EXPR) #endif /* Imports for os-inline-calls */ #if (defined LPRM2) || (defined SPCM2) # define OSCALL_IMPORT FROM SYSTEM IMPORT WORD, INLINE, SETREG, REG; # define CODE INLINE #elif (defined MM2) # define OSCALL_IMPORT FROM SYSTEM IMPORT CALLSYS, CODE, LOAD, STORE, ASSEMBLER; #elif (defined HM2) # define OSCALL_IMPORT FROM SYSTEM IMPORT CODE, LOAD, STORE; #elif (defined TDIM2) # define OSCALL_IMPORT FROM SYSTEM IMPORT PUSH, CODE, SETREG, REGISTER; #elif (defined FTLM2) # define OSCALL_IMPORT FROM SYSTEM IMPORT CODE, SETREG, GETREG; #elif (defined TSM2_1) # define OSCALL_IMPORT FROM SYSTEM IMPORT Registers, Seg, Ofs; \ FROM AsmLib IMPORT Dos; #elif (defined LM2) # define OSCALL_IMPORT FROM SYSTEM IMPORT DOSCALL; #endif #define INLINE_CODE_IMPORT OSCALL_IMPORT /* Read/write from/to cpu registers * _VAR : only (UN)SIGNEDWORD, (UN)SIGNEDLONG or ADDRESS, and simple, * local variable! */ #if (defined LPRM2) || (defined SPCM2) # define REGISTER_IMPORT FROM SYSTEM IMPORT REG, SETREG; # define SETREG(_REG,_EXPR) SETREG(_REG,VAL(LONGCARD,_EXPR)) # define GETINTREG(_REG,_VAR) _VAR:=VAL(INTEGER,REG(_REG)) # define GETSWREG(_REG,_VAR) _VAR:=VAL(INTEGER,REG(_REG)) # define GETCARDREG(_REG,_VAR) _VAR:=VAL(CARDINAL,REG(_REG)) # define GETUWREG(_REG,_VAR) _VAR:=VAL(CARDINAL,REG(_REG)) # define GETLREG(_REG,_VAR) _VAR:=REG(_REG) # define GETREGADR(_REG,_VAR) _VAR:=VAL(ADDRESS,REG(_REG)) #elif (defined MM2) || (defined HM2) # define REGISTER_IMPORT FROM SYSTEM IMPORT LOAD, STORE; # define SETREG(_REG,_EXPR) LOAD(_EXPR,_REG) # define GETINTREG(_REG,_VAR) STORE(_REG,_VAR) # define GETSWREG(_REG,_VAR) STORE(_REG,_VAR) # define GETCARDREG(_REG,_VAR) STORE(_REG,_VAR) # define GETUWREG(_REG,_VAR) STORE(_REG,_VAR) # define GETLREG(_REG,_VAR) STORE(_REG,_VAR) # define GETREGADR(_REG,_VAR) STORE(_REG,_VAR) #elif (defined TDIM2) # define REGISTER_IMPORT FROM SYSTEM IMPORT REGISTER, SETREG; # define SETREG(_REG,_EXPR) SETREG(_REG,_EXPR) # define GETINTREG(_REG,_VAR) _VAR:=INTEGER(REGISTER(_REG)) # define GETSWREG(_REG,_VAR) _VAR:=INTEGER(REGISTER(_REG)) # define GETCARDREG(_REG,_VAR) _VAR:=CARDINAL(REGISTER(_REG)) # define GETUWREG(_REG,_VAR) _VAR:=CARDINAL(REGISTER(_REG)) # define GETLREG(_REG,_VAR) _VAR:=LONGCARD(REGISTER(_REG)) # define GETREGADR(_REG,_VAR) _VAR:=REGISTER(_REG) #elif (defined FTLM2) # define REGISTER_IMPORT FROM SYSTEM IMPORT SETREG, GETREG; # define SETREG(_REG,_EXPR) SETREG(_REG,LONGCARD(_EXPR)) /* GETREG works only with 16-bit-vars in version 1.18 !! */ # define GETINTREG(_REG,_VAR) GETREG(_REG,_VAR) # define GETSWREG(_REG,_VAR) GETREG(_REG,_VAR) # define GETCARDREG(_REG,_VAR) GETREG(_REG,_VAR) # define GETUWREG(_REG,_VAR) GETREG(_REG,_VAR) # define GETLREG(_REG,_VAR) GETREG(_REG,_VAR) # define GETREGADR(_REG,_VAR) GETREG(_REG,_VAR) #endif #if (defined MM2) # define REFADR CADR #else # define REFADR ADR # define CADR ADR #endif #if (defined LPRM2) || (defined SPCM2) # define PROCADR(_P) ADR(_P) #else # define PROCADR(_P) CAST(ADDRESS,_P) #endif /* Various compiler options */ #if (defined MM2) /* B-: Remove module body during optimized linking if no procedures needed * D-: Don't produce debug code * E-: Don't produce procedure trace * K+: Assignment := is possible * L+: Produce procedure frames * M-: Don't produce procedure names * R-: Don't produce range checks * S-: Don't produce stack checks * T+: Enumerations in ascending order * U+: Sets with no more than 32 elements in BITSET format * W-: No warnings with REF-parameters * * I+/-: CARDINAL/INTEGER same as LONGCARD/LONGINT or SHORTCARD/SHORTINT * Z+/-: Function results in register or on stack */ # ifdef __RES_ON_STACK__ # ifdef __LONG_WHOLE__ # define __DEF_SWITCHES__ (*$I+,Z-*) # define __IMP_SWITCHES__ (*$B-,K+,T+,U+,W-,I+,Z-*) # else # define __DEF_SWITCHES__ (*$I-,Z-*) # define __IMP_SWITCHES__ (*$B-,K+,T+,U+,W-,I-,Z-*) # endif # else # ifdef __LONG_WHOLE__ # define __DEF_SWITCHES__ (*$I+,Z+*) # define __IMP_SWITCHES__ (*$B-,K+,T+,U+,W-,I+,Z+*) # else # define __DEF_SWITCHES__ (*$I-,Z+*) # define __IMP_SWITCHES__ (*$B-,K+,T+,U+,W-,I-,Z+*) # endif # endif # define __PROCFRAME_OFF__ (*$L-*) # define __PROCFRAME_ON__ (*$L+*) # define __DRIVER__ (*$B+*) #ifdef __REG_VARS__ # define __REG__ (*$Reg*) #else # define __REG__ #endif # define __STACKCHECK_ON__ (*$S+*) # define __STACKCHECK_OFF__ (*$S-*) # define __STACKCHECK_PREV__ (*$S=*) # define __RANGECHECK_ON__ (*$R+*) # define __RANGECHECK_OFF__ (*$R-*) # define __RANGECHECK_PREV__ (*$R=*) # define __DEBUG_ON__ (*$D+,E+,M+*) # define __DEBUG_OFF__ (*$D-,E-,M-*) # define __DEBUG_PREV__ (*$D=,E=,M=*) #elif (defined HM2) /* B-: * C-: Don't produce range checks for CARDINAL-operations * D-: Don't produce debug code * E-: Don't produce entry code for local procedures * G-: Strings don't need to be terminated by 0C * H-: Produce warnings if using HM2-specific constructs * I-: Don't initialize local vars with -1 * K-: Called procedure removes it's arguments * L-: Don't use 4 bytes as the minimal storage for enumerations * M-: Remove module body during optimized linking if no procedures needed * N-: Don't produce range checks for REAL-operations * P-: Produce procedure frames * Q-: Warnings enabled * S-: Don't produce stack checks * T-: Don't produce index and range checks * V-: Don't produce range checks on INTEGER/aritmetic operations * W-: Don't use 2 bytes as the minimal storage for enumerations * X-: Don't make static checks (RETURN, CASE) * Y-: Don't produce runtime checks (RETURN, CASE) */ # define __DEF_SWITCHES__ (*$K-*) # define __IMP_SWITCHES__ (*$B-,$E-,$G-,$H-,$K-,$L-,$M-,$Q-,$W-,$X-*) # define __PROCFRAME_OFF__ (*$P+*) # define __PROCFRAME_ON__ (*$P-*) # define __DRIVER__ (*$M+*) #ifdef __REG_VARS__ # define __REG__ (*$R+*) #else # define __REG__ #endif # define __STACKCHECK_ON__ (*$S+*) # define __STACKCHECK_OFF__ (*$S-*) # define __STACKCHECK_PREV__ (*$S=*) # define __RANGECHECK_ON__ (*$C+,$N+,$T+,$V+,$Y+*) # define __RANGECHECK_OFF__ (*$C-,$N-,$T-,$V-,$Y-*) # define __RANGECHECK_PREV__ (*$C=,$N=,$T=,$V=,$Y=*) # define __DEBUG_ON__ (*$D+,$I+*) # define __DEBUG_OFF__ (*$D-,$I-*) # define __DEBUG_PREV__ (*$D=,$I=*) #elif (defined TDIM2) /* N-: Don't produce nil checks on dereferencing of pointers * P+: produce procedure frames * Q+: Within a module use BSR instead of JSR * R-: Don't produce range checks * S-: Don't produce stack checks * T-: Don't produce index checks * V-: Don't produce overflow checks */ # define __DEF_SWITCHES__ # define __IMP_SWITCHES__ (*$Q+*) # define __PROCFRAME_OFF__ (*$P-*) # define __PROCFRAME_ON__ (*$P+*) # define __DRIVER__ # define __REG__ # define __STACKCHECK_ON__ (*$S+*) # define __STACKCHECK_OFF__ (*$S-*) # define __STACKCHECK_PREV__ (*$S=*) # define __RANGECHECK_ON__ (*$N+,$R+,$T+,$V+*) # define __RANGECHECK_OFF__ (*$N-,$R-,$T-,$V-*) # define __RANGECHECK_PREV__ (*$N=,$R=,$T=,$V=*) # define __DEBUG_ON__ # define __DEBUG_OFF__ # define __DEBUG_PREV__ #else # define __DEF_SWITCHES__ # define __IMP_SWITCHES__ # define __PROCFRAME_OFF__ # define __PROCFRAME_ON__ # define __DRIVER__ # define __REG__ # define __STACKCHECK_ON__ # define __STACKCHECK_OFF__ # define __STACKCHECK_PREV__ # define __RANGECHECK_ON__ # define __RANGECHECK_OFF__ # define __RANGECHECK_PREV__ # define __DEBUG_ON__ # define __DEBUG_OFF__ # define __DEBUG_PREV__ #endif #ifdef __STACK_CODE__ # define __stack__ __STACKCHECK_ON__ #else # define __stack__ __STACKCHECK_OFF__ #endif #ifdef __RANGE_CODE__ # define __range__ __RANGECHECK_ON__ #else # define __range__ __RANGECHECK_OFF__ #endif #ifdef __DEBUG_CODE__ # define __debug__ __DEBUG_ON__ #else # define __debug__ __DEBUG_OFF__ #endif #define __DEBUG__ __range__ __stack__ __debug__