|
@@ -2167,7 +2167,7 @@ MMX operations, so be careful.
|
|
|
|
|
|
The MMX instructions are optimized for multi media (what else?).
|
|
|
So it isn't possible to perform each operation, some operations
|
|
|
-give a type mismatch, see section \ref {se:SupportedMMX} for the supported
|
|
|
+give a type mismatch, see section \ref{se:SupportedMMX} for the supported
|
|
|
MMX operations
|
|
|
|
|
|
An important restriction is that MMX operations aren't range or overflow
|
|
@@ -2301,7 +2301,7 @@ scratch regs. & N/A \\
|
|
|
|
|
|
\begin{FPCltable}{ll}{Motorola 680x0 Register table}{680x0Regs} \hline
|
|
|
Generic register name & CPU Register name \\ \hline
|
|
|
-accumulator & D0 \\
|
|
|
+accumulator & D0\footnotemark \\
|
|
|
accumulator (64-bit) high / low & D0:D1 \\
|
|
|
float result & FP0\footnotemark\\
|
|
|
self & A5 \\
|
|
@@ -2310,7 +2310,10 @@ stack pointer & A7 \\
|
|
|
scratch regs. & D0, D1, A0, A1, FP0, FP1 \\
|
|
|
\end{FPCltable}
|
|
|
|
|
|
-\footnotetext{On simulated FPU's the result is returned in D0}
|
|
|
+\addtocounter{footnote}{-1}\footnotetext{For compatibility with some C compilers, when
|
|
|
+the function result is a pointer and is declared with the cdecl convention,
|
|
|
+the result is also stored in the A0 register}
|
|
|
+\addtocounter{footnote}{1}\footnotetext{On simulated FPU's the result is returned in D0}
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
% Name mangling
|
|
@@ -2717,12 +2720,11 @@ Standard entry code for procedures and functions is as follows on the
|
|
|
move.l sp,a6
|
|
|
\end{verbatim}
|
|
|
|
|
|
-The generated exit sequence for procedure and functions looks as follows:
|
|
|
+The generated exit sequence for procedure and functions looks as follows
|
|
|
+(in the default processor mode):
|
|
|
\begin{verbatim}
|
|
|
unlk a6
|
|
|
- move.l (sp)+,a0 ; Get return address
|
|
|
- add.l #xx,sp ; Remove allocated stack
|
|
|
- move.l a0,-(sp) ; Put back return address on top of the stack
|
|
|
+ rtd #xx
|
|
|
\end{verbatim}
|
|
|
|
|
|
Where \var{xx} is the total size of the pushed parameters.
|
|
@@ -2779,8 +2781,9 @@ parameter actually takes less then 4 bytes to store on the stack (such
|
|
|
as passing a byte value parameter to the stack).
|
|
|
|
|
|
|
|
|
-
|
|
|
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
\section{Processor limitations}
|
|
|
+\label{se:ProcessorLimits}
|
|
|
|
|
|
Certain processors have limitations on the size of the parameters
|
|
|
and local variables in routines. This is shown in \seet{CPULimits}.
|
|
@@ -4835,6 +4838,9 @@ use longword and longint variables.
|
|
|
\item Write your if/then/else statements so that the code in the "then"-part
|
|
|
gets executed most of the time (improves the rate of successful jump prediction).
|
|
|
|
|
|
+\item Do not use ansistrings, widestrings and exception support, as these
|
|
|
+require a lot of code overhead.
|
|
|
+
|
|
|
\item Profile your code (see the -pg switch) to find out where the
|
|
|
bottlenecks are. If you want, you can rewrite those parts in assembler.
|
|
|
You can take the code generated by the compiler as a starting point. When
|
|
@@ -4865,11 +4871,13 @@ about 1 additional instruction after each subroutine call.
|
|
|
\item Use the smartlinking options for all your units
|
|
|
(including the \var{system} unit).
|
|
|
|
|
|
-\item Do not use ansistrings and exception support, as these require
|
|
|
-a lot of code overhead.
|
|
|
+\item Do not use ansistrings, widestrings and exception support, as these
|
|
|
+require a lot of code overhead.
|
|
|
|
|
|
\item Turn off range checking and stack-checking.
|
|
|
|
|
|
+\item Turn off runtime type information generation
|
|
|
+
|
|
|
\end{itemize}
|
|
|
|
|
|
|
|
@@ -5617,17 +5625,18 @@ units as well as generic versions of processor specific routines.
|
|
|
|
|
|
\chapter{Compiler limits}
|
|
|
\label{ch:AppC}
|
|
|
-Although many of the restrictions imposed by the MS-DOS system are removed
|
|
|
-by use of an extender, or use of another operating system, there still are
|
|
|
-some limitations to the compiler:
|
|
|
+There are certain compiler limits inherent to the compiler:
|
|
|
\begin{enumerate}
|
|
|
\item Procedure or Function definitions can be nested to a level of 32.
|
|
|
-\item Maximally 255 units can be used in a program when using the real-mode
|
|
|
-compiler (i.e. a binary that was compiled by Borland Pascal). When using the 32-bit compiler, the limit is set to 1024. You can
|
|
|
-change this by redefining the \var{maxunits} constant in the
|
|
|
-\file{files.pas} compiler source file.
|
|
|
+\item Maximally 1024 units can be used in a program when using the compiler.
|
|
|
+You can change this by redefining the \var{maxunits} constant in the compiler
|
|
|
+source file.
|
|
|
+\item Arrays are limited to 2 GBytes in size in the default processor mode.
|
|
|
\end{enumerate}
|
|
|
|
|
|
+For processor specific compiler limitations refer to the Processor
|
|
|
+Limitations section in this guide (\ref{se:ProcessorLimits}).
|
|
|
+
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
% Appendix D
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
@@ -5653,7 +5662,8 @@ parameters when implementing the function or procedure.
|
|
|
\item PChars are converted to strings automatically.
|
|
|
\end{enumerate}
|
|
|
\section{TP mode}
|
|
|
-This mode is selected by the \var{{\$MODE TP}} switch. On the command-line,
|
|
|
+This mode is selected by the \var{{\$MODE TP}} switch. It tries to emulate,
|
|
|
+as closely as possible, the behavior of Turbo Pascal 7. On the command-line,
|
|
|
this mode is selected by the \var{-So} switch.
|
|
|
|
|
|
\begin{enumerate}
|
|
@@ -5669,7 +5679,8 @@ parameters when implementing the function or procedure.
|
|
|
\item You can not use the cvar type.
|
|
|
\end{enumerate}
|
|
|
\section{Delphi mode}
|
|
|
-This mode is selected by the \var{{\$MODE DELPHI}} switch. On the command-line,
|
|
|
+This mode is selected by the \var{{\$MODE DELPHI}} switch. It tries to emulate,
|
|
|
+as closely as possible, the behavior of Delphi 4. On the command-line,
|
|
|
this mode is selected by the \var{-Sd} switch.
|
|
|
\begin{enumerate}
|
|
|
\item You can not use the address operator to assign procedural variables.
|
|
@@ -6685,14 +6696,13 @@ is on the system. If the compiler should be compiled with the RTL that was
|
|
|
compiled first, this should be \file{../rtl/OS} (replace the OS with the
|
|
|
appropriate operating system subdirectory of the RTL).
|
|
|
\item A define with the processor for which the compiler is compiled for. Required.
|
|
|
-\item \var{-dGDB} is not strictly needed, but is better to add since
|
|
|
-otherwise compiling with debug information will not be possible.
|
|
|
+\item \var{-dGDB}. Required.
|
|
|
\item \var{-Sg} is needed, some parts of the compiler use \var{goto}
|
|
|
statements (to be specific: the scanner).
|
|
|
\end{enumerate}
|
|
|
So the absolute minimal command line is
|
|
|
\begin{verbatim}
|
|
|
-ppc386 -di386 -Sg pp.pas
|
|
|
+ppc386 -di386 -dGDB -Sg pp.pas
|
|
|
\end{verbatim}
|
|
|
|
|
|
Some other command-line options can be used, but the above are the
|
|
@@ -6700,22 +6710,19 @@ minimum. A list of recognised options can be found in \seet{FPCdefines}.
|
|
|
|
|
|
\begin{FPCltable}{ll}{Possible defines when compiling FPC}{FPCdefines}
|
|
|
Define & does what \\ \hline
|
|
|
-USE\_RHIDE & Generates errors and warnings in a format recognized\\
|
|
|
-& by \file{rhide}. \\
|
|
|
TP & Needed to compile the compiler with Turbo or Borland Pascal. \\
|
|
|
-Delphi & Needed to compile the compiler with Delphi from Borland. \\
|
|
|
-GDB & Support of the GNU Debugger. \\
|
|
|
+GDB & Support of the GNU Debugger (required switch). \\
|
|
|
I386 & Generate a compiler for the Intel i386+ processor family. \\
|
|
|
-M68K & Generate a compiler for the M68000 processor family. \\
|
|
|
-USEOVERLAY & Compiles a TP version which uses overlays. \\
|
|
|
+M68K & Generate a compiler for the M680x0 processor family. \\
|
|
|
EXTDEBUG & Some extra debug code is executed. \\
|
|
|
+MEMDEBUG & Some memory usage information is displayed. \\
|
|
|
SUPPORT\_MMX & only i386: enables the compiler switch \var{MMX} which \\
|
|
|
&allows the compiler to generate MMX instructions.\\
|
|
|
EXTERN\_MSG & Don't compile the msgfiles in the compiler, always use \\
|
|
|
& external messagefiles (default for TP).\\
|
|
|
-NOAG386INT & no Intel Assembler output.\\
|
|
|
-NOAG386NSM & no NASM output.\\
|
|
|
-NOAG386BIN & leaves out the binary writer.\\ \hline
|
|
|
+LOGSECONDPASS & Write compiler node information in assembler output. \\
|
|
|
+NOOPT & Do not include the optimizer in the compiler. \\
|
|
|
+\hline
|
|
|
\end{FPCltable}
|
|
|
This list may be subject to change, the source file \file{pp.pas} always
|
|
|
contains an up-to-date list.
|
|
@@ -6750,6 +6757,8 @@ ENDIAN\_LITTLE & Defined when the \fpc target is a little-endian processor \\
|
|
|
& (80x86, Alpha, ARM). \\
|
|
|
ENDIAN\_BIG & Defined when the \fpc target is a big-endian processor \\
|
|
|
& (680x0, PowerPC, SPARC, MIPS). \\
|
|
|
+FPU\_EMULATION & Defined when the \fpc target uses floating-point software \\
|
|
|
+& emulation. \\
|
|
|
FPC\_DELPHI & \fpc is in Delphi mode, either using compiler switch -Sd or \\
|
|
|
& using the \var{\$MODE DELPHI} directive. \\
|
|
|
FPC\_OBJFPC & \fpc is in Delphi mode, either using compiler switch -S2 or \\
|
|
@@ -6762,7 +6771,8 @@ FPC\_GPC & \fpc is in GNU Pascal mode, either using compiler switch -Sp or \\
|
|
|
|
|
|
\begin{remark}
|
|
|
The \var{ENDIAN\_LITTLE} and \var{ENDIAN\_BIG} defines were added
|
|
|
-starting from \fpc version 1.0.5.
|
|
|
+starting from \fpc version 1.0.5. The \var{FPU\_EMULATION} define
|
|
|
+was added starting from \fpc version 1.0.7.
|
|
|
\end{remark}
|
|
|
|
|
|
\begin{FPCltable}{ll}{Possible CPU defines when compiling using FPC}{FPCCPUdefines}
|