
Free Pascal Programmers’ manual Programmers’ manual for Free Pascal, version 2.0.4 Document version 2.0 August 2006 Michaël Van Canneyt Contents 0.1 About this document .................................. 12 1 Compiler directives 13 1.1 Local directives ..................................... 13 1.1.1 $A or $ALIGN : Align Data .......................... 13 1.1.2 $ASMMODE : Assembler mode (Intel 80x86 only) ............... 13 1.1.3 $B or $BOOLEVAL : Complete boolean evaluation .............. 14 1.1.4 $C or $ASSERTIONS : Assertion support ................... 14 1.1.5 $CALLING : Specify calling convention .................... 14 1.1.6 $CHECKPOINTER : Check pointer values ................... 15 1.1.7 $CODEALIGN : Set the code alignment .................... 15 1.1.8 $COPERATOR : Allow C like operators .................... 15 1.1.9 $DEFINE : Define a symbol .......................... 16 1.1.10 $ELSE : Switch conditional compilation ................... 16 1.1.11 $ELSEC : Switch conditional compilation ................... 16 1.1.12 $ENDC : End conditional compilation ..................... 16 1.1.13 $ENDIF : End conditional compilation .................... 16 1.1.14 $ERROR : Generate error message ....................... 17 1.1.15 $EXTENDEDSYM: Ignored ........................... 17 1.1.16 $F : Far or near functions ........................... 17 1.1.17 $FATAL : Generate fatal error message .................... 18 1.1.18 $FPUTYPE : Select coprocessor type ..................... 18 1.1.19 $GOTO : Support Goto and Label ...................... 18 1.1.20 $H or $LONGSTRINGS : Use AnsiStrings .................. 19 1.1.21 $HINT : Generate hint message ........................ 19 1.1.22 $HINTS : Emit hints .............................. 19 1.1.23 $HPPEMIT: Ignored .............................. 19 1.1.24 $IF : Start conditional compilation ...................... 19 1.1.25 $IFC : Start conditional compilation ..................... 19 1.1.26 $IFDEF Name : Start conditional compilation ................ 19 1.1.27 $IFNDEF : Start conditional compilation ................... 20 1 CONTENTS 1.1.28 $IFOPT : Start conditional compilation .................... 20 1.1.29 $IMPLICITEXCEPTIONS : Do not generate finalization code ....... 20 1.1.30 $INFO : Generate info message ........................ 20 1.1.31 $INLINE : Allow inline code. ......................... 20 1.1.32 $INTERFACES : Specify Interface type. ................... 21 1.1.33 $I or $IOCHECKS : Input/Output checking .................. 21 1.1.34 $I or $INCLUDE : Include file ........................ 21 1.1.35 $I or $INCLUDE : Include compiler info ................... 22 1.1.36 $I386_XXX : Specify assembler format (Intel 80x86 only) ......... 23 1.1.37 $J or $WRITABLECONSTS : Allow typed consts .............. 23 1.1.38 $L or $LINK : Link object file ......................... 23 1.1.39 $LINKLIB : Link to a library ......................... 24 1.1.40 $M or $TYPEINFO : Generate type info .................... 24 1.1.41 $MACRO : Allow use of macros. ........................ 24 1.1.42 $MAXFPUREGISTERS : Maximum number of FPU registers for variables . 25 1.1.43 $MESSAGE : Generate info message ...................... 25 1.1.44 $MMX : Intel MMX support (Intel 80x86 only) ................ 25 1.1.45 $NODEFINE : Ignored ............................. 26 1.1.46 $NOTE : Generate note message ........................ 26 1.1.47 $NOTES : Emit notes .............................. 26 1.1.48 $OBJECTCHECK : Check Object ....................... 26 1.1.49 $OUTPUT_FORMAT : Specify the output format ............... 27 1.1.50 $PACKENUM : Minimum enumeration type size ................ 27 1.1.51 $PACKRECORDS : Alignment of record elements ............... 27 1.1.52 $Q $OVERFLOWCHECKS: Overflow checking ................ 28 1.1.53 $R or $RANGECHECKS : Range checking ................... 28 1.1.54 $R or $RESOURCE : Include resource ..................... 28 1.1.55 $SATURATION : Saturation operations (Intel 80x86 only) .......... 29 1.1.56 $SETC : Define and assign a value to a symbol ................ 29 1.1.57 $STATIC : Allow use of Static keyword. ................. 29 1.1.58 $STOP : Generate fatal error message ..................... 29 1.1.59 $T or $TYPEDADDRESS : Typed address operator (@) ........... 30 1.1.60 $UNDEF : Undefine a symbol ......................... 30 1.1.61 $V or $VARSTRINGCHECKS : Var-string checking ............. 30 1.1.62 $W or $STACKFRAMES : Generate stackframes ................ 30 1.1.63 $WAIT : Wait for enter key press ....................... 30 1.1.64 $WARNING : Generate warning message ................... 31 1.1.65 $WARNINGS : Emit warnings ......................... 31 1.2 Global directives .................................... 31 1.2.1 $APPID : Specify application ID. ....................... 31 2 CONTENTS 1.2.2 $APPID : Specify application name. ..................... 31 1.2.3 $APPTYPE : Specify type of application. ................... 31 1.2.4 $CALLING : Default calling convention .................... 32 1.2.5 $CODEPAGE : Set the source codepage .................... 33 1.2.6 $COPYRIGHT specify copyright info ..................... 33 1.2.7 $D or $DEBUGINFO : Debugging symbols .................. 33 1.2.8 $DESCRIPTION : Application description .................. 33 1.2.9 $D $DEBUGINFO : Include debug info .................... 33 1.2.10 $E : Emulation of coprocessor ......................... 33 Intel 80x86 version ............................... 33 Motorola 680x0 version ............................ 34 1.2.11 $G : Generate 80286 code ........................... 34 1.2.12 $INCLUDEPATH : Specify include path. ................... 34 1.2.13 $INTERFACES : Default interface type .................... 34 1.2.14 $L or $LOCALSYMBOLS : Local symbol information ............ 34 1.2.15 $LIBRARYPATH : Specify library path. .................... 35 1.2.16 $M or $MEMORY : Memory sizes ........................ 35 1.2.17 $MODE : Set compiler compatibility mode ................... 35 1.2.18 $N : Numeric processing ........................... 36 1.2.19 $O : Overlay code generation ......................... 36 1.2.20 $OBJECTPATH : Specify object path. ..................... 36 1.2.21 $P or $OPENSTRINGS : Use open strings .................. 36 1.2.22 $PROFILE : Profiling ............................. 36 1.2.23 $S : Stack checking .............................. 36 1.2.24 $SCREENNAME : Specify screen name .................... 37 1.2.25 $SMARTLINK : Use smartlinking ....................... 37 1.2.26 $THREADNAME : Set thread name in Netware ................. 37 1.2.27 $THREADING : Allow use of threads. ..................... 37 1.2.28 $UNITPATH : Specify unit path. ....................... 37 1.2.29 $VERSION : Specify DLL version. ...................... 38 1.2.30 $WEAKPACKAGEUNIT : ignored ....................... 38 1.2.31 $X or $EXTENDEDSYNTAX : Extended syntax ................ 38 1.2.32 $Y or $REFERENCEINFO : Insert Browser information ........... 39 2 Using conditionals, messages and macros 40 2.1 Conditionals ....................................... 40 2.1.1 Predefined symbols ............................... 41 2.2 Macros ......................................... 41 2.3 Compile time variables ................................. 43 2.4 Compile time expressions ................................ 43 3 CONTENTS 2.4.1 Definition .................................... 43 2.4.2 Usage ...................................... 44 2.5 Messages ........................................ 48 3 Using Assembly language 50 3.1 Using assembler in the sources ............................. 50 3.2 Intel 80x86 Inline assembler .............................. 51 3.2.1 Intel syntax ................................... 51 3.2.2 AT&T Syntax .................................. 54 3.3 Motorola 680x0 Inline assembler ............................ 55 3.4 Signaling changed registers ............................... 56 4 Generated code 57 4.1 Units ........................................... 57 4.2 Programs ........................................ 58 5 Intel MMX support 59 5.1 What is it about? .................................... 59 5.2 Saturation support .................................... 60 5.3 Restrictions of MMX support .............................. 60 5.4 Supported MMX operations .............................. 61 5.5 Optimizing MMX support ............................... 61 6 Code issues 62 6.1 Register Conventions .................................. 62 6.1.1 accumulator register .............................. 62 6.1.2 accumulator 64-bit register ........................... 62 6.1.3 float result register ............................... 62 6.1.4 self register ................................... 62 6.1.5 frame pointer register .............................. 62 6.1.6 stack pointer register .............................. 63 6.1.7 scratch registers ................................. 63 6.1.8 Processor mapping of registers ......................... 63 Intel 80x86 version ............................... 63 Motorola 680x0 version ............................ 63 6.2 Name mangling ..................................... 64 6.2.1 Mangled names for data blocks ........................ 64 6.2.2 Mangled names for code blocks ........................ 65 6.2.3 Modifying the mangled names ......................... 67 6.3 Calling mechanism ................................... 67 6.4 Nested procedure and functions ............................. 68 4 CONTENTS 6.5 Constructor and Destructor calls ............................ 68 6.5.1 objects ..................................... 68 6.5.2 classes ....................................
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages159 Page
-
File Size-