mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-08 10:48:12 +02:00
+ applied some changes by carl.
This commit is contained in:
parent
35c2815722
commit
c635ab47c7
72
docs/ref.tex
72
docs/ref.tex
@ -98,7 +98,7 @@ Shortint & -127 .. 127 & 1\\
|
||||
Integer & -32768 .. 32767 & 2 \\
|
||||
Word & 0 .. 65535 & 2 \\
|
||||
Longint & -2147483648 .. 2147483648 & 4\\
|
||||
Cardinal\footnote{The cardinal type support is buggy until version 0.9.3} & 0..4294967296 & 4 \\ \hline
|
||||
Cardinal\footnote{The cardinal type support is buggy until version 0.99.6} & 0..4294967296 & 4 \\ \hline
|
||||
\end{FPCltable}
|
||||
|
||||
\fpc does automatic type conversion in expressions where different kinds of
|
||||
@ -115,12 +115,13 @@ as \var{\%11111111}.
|
||||
|
||||
\subsection{Real types}
|
||||
\fpc uses the math coprocessor (or an emulation) for al its floating-point
|
||||
calculations. The native type for the coprocessor is \var{Double}. Other
|
||||
than that, all Turbo Pascal real types are supported. They're listed in
|
||||
calculations. The Real native type for is processor dependant,
|
||||
but it is either Single or Double. Only the IEEE floating point type are
|
||||
supported, and these depend on the target processor and emulation options .
|
||||
The true Turbo Pascal compatible types are listed in
|
||||
\seet{Reals}.
|
||||
\begin{FPCltable}{lccr}{Supported Real types}{Reals}
|
||||
Type & Range & Significant digits & Size\footnote{In Turbo Pascal.} \\ \hline
|
||||
Real & 2.9E-39 .. 1.7E38 & 11-12 & 6 \\
|
||||
Single & 1.5E-45 .. 3.4E38 & 7-8 & 4 \\
|
||||
Double & 5.0E-324 .. 1.7E308 & 15-16 & 8 \\
|
||||
Extended & 1.9E-4951 .. 1.1E4932 & 19-20 & 10\\
|
||||
@ -128,9 +129,8 @@ Extended & 1.9E-4951 .. 1.1E4932 & 19-20 & 10\\
|
||||
\end{FPCltable}
|
||||
|
||||
Until version 0.9.1 of the compiler, all the real types are mapped to type
|
||||
\var{Double}, meaning that they all have size 8. From version 0.9.3, the
|
||||
\var{Extended} and \var{single} types are defined with the same suze as in
|
||||
Turbo Pascal. The \seef{SizeOf} function is your friend here.
|
||||
\var{Double}, meaning that they all have size 8. The \seef{SizeOf} function
|
||||
is your friend here.
|
||||
|
||||
\subsection{Character types}
|
||||
\subsubsection{Char}
|
||||
@ -291,6 +291,9 @@ be called, which may have strange side-effects.
|
||||
\end{verbatim}
|
||||
Here \var{Func} is a function which returns a \var{Boolean} type.
|
||||
|
||||
{\em Remark:} The wordbool, longbool and bytebool were not supported
|
||||
by \fpc until version 0.99.6.
|
||||
|
||||
\subsection{Arrays}
|
||||
\fpc supports arrays as in Turbo Pascal, multi-dimensional arrays
|
||||
and packed arrays are also supported.
|
||||
@ -1008,7 +1011,7 @@ valid for both.
|
||||
Function overloading simply means that you can define the same function more
|
||||
than once, but each time with a different set of arguments.
|
||||
|
||||
When the compiler encounters a unction call, it will look at the function
|
||||
When the compiler encounters a function call, it will look at the function
|
||||
parameters to decide which od the defined function
|
||||
This can be useful if you want to define the same function for different
|
||||
types. For example, if the RTL, the \var{Dec} procedure is
|
||||
@ -1061,18 +1064,9 @@ procedures which accept arrays of fixed length.
|
||||
|
||||
\section{Using assembler in your code}
|
||||
\fpc supports the use of assembler in your code, but not inline
|
||||
assembler. assembly functions (i.e. functions declared with the
|
||||
\var{Assembler} keyword) are supported as of version 0.9.7.
|
||||
|
||||
{\em Remark :}
|
||||
\fpc issues AT\&T assembly language, as understood by most
|
||||
unix assemblers (most notably : GNU \var{as}).
|
||||
Intel assembler syntax is available as of version 0.9.8 but the Intel
|
||||
support isn't complete in the sense that it is converted to AT\&T syntax,
|
||||
and some constructions aren't supported by the conversion mechanism (see
|
||||
assembler macros. Assembly functions (i.e. functions declared with the
|
||||
\var{Assembler} keyword) are supported as of version 0.9.7. (see
|
||||
\progref for more information about this).
|
||||
Therefore all examples of assembly language will be given in AT\&T syntax,
|
||||
as it is the 'native' assembly from \fpc.
|
||||
|
||||
The following is an example of assembler inclusion in your code.
|
||||
\begin{verbatim}
|
||||
@ -1080,20 +1074,21 @@ The following is an example of assembler inclusion in your code.
|
||||
Statements;
|
||||
...
|
||||
Asm
|
||||
Movl 0,%eax
|
||||
your asm code here
|
||||
...
|
||||
end;
|
||||
...
|
||||
Statements;
|
||||
\end{verbatim}
|
||||
|
||||
The assembler instructions between the \var{Asm} and \var{end} keywords will
|
||||
be inserted in the assembler generated by the compiler.
|
||||
|
||||
You can still use comditionals in your assembler, the compiler will
|
||||
You can still use conditionals in your assembler, the compiler will
|
||||
recognise it, and treat it as any other conditionals.
|
||||
|
||||
Contrary to Turbo Pascal, it isn't possible (yet) to reference variables by
|
||||
their names in the assembler parts of your code.
|
||||
\emph{ Remark: } Before version 0.99.1, \fpc did not support
|
||||
reference to variables by their names in the assembler parts of your code.
|
||||
|
||||
\section{Modifiers}
|
||||
\fpc doesn't support all Turbo Pascal modifiers, but
|
||||
@ -1325,7 +1320,7 @@ powerful tool for making externally accessible object files.
|
||||
\subsection{[RegisterList]}
|
||||
This modifier list is used to indicate the registers that are modified by an
|
||||
assembler block in your code. The compiler stores certain results in the
|
||||
registers. If you modify theregisters in an assembly block, the compiler
|
||||
registers. If you modify the registers in an assembly block, the compiler
|
||||
should, sometimes, be told about it.
|
||||
The prototype syntax of the \var{Registerlist} modifier is:
|
||||
\begin{verbatim}
|
||||
@ -1333,7 +1328,7 @@ asm
|
||||
statements
|
||||
end; ['register1','register2',...,'registern'];
|
||||
\end{verbatim}
|
||||
Where \var{'register'} is one of \var{'EAX',EBX',ECX','EDX'} etc.
|
||||
Where is register one of any of the available processor registers.
|
||||
|
||||
|
||||
\subsection{Unsupported Turbo Pascal modifiers}
|
||||
@ -1372,14 +1367,6 @@ byte = 0..255;
|
||||
word = 0..65535;
|
||||
\end{verbatim}
|
||||
|
||||
The following Real types are declared:
|
||||
\begin{verbatim}
|
||||
double = real;
|
||||
{$ifdef VER0_6}
|
||||
extended = real;
|
||||
single = real;
|
||||
{$endif VER0_6}
|
||||
\end{verbatim}
|
||||
|
||||
And the following pointer types:
|
||||
\begin{verbatim}
|
||||
@ -1399,17 +1386,21 @@ Const
|
||||
|
||||
filemode : byte = 2;
|
||||
\end{verbatim}
|
||||
Further, the following general-purpose constants are also defined:
|
||||
Further, the following non processor specific general-purpose constants
|
||||
are also defined:
|
||||
\begin{verbatim}
|
||||
const
|
||||
test8086 : byte = 2; { always i386 or newer }
|
||||
test8087 : byte = 3; { Always 387 or higher. emulated if needed. }
|
||||
erroraddr : pointer = nil;
|
||||
errorcode : word = 0;
|
||||
{ max level in dumping on error }
|
||||
max_frame_dump : word = 20;
|
||||
\end{verbatim}
|
||||
|
||||
\emph{ Remark: } Processor specific global constants are named Testxxxx
|
||||
where xxxx represents the processor number (such as Test8086, Test68000),
|
||||
and are used to determine on what generation of processor the program
|
||||
is running on.
|
||||
|
||||
\subsection{Variables}
|
||||
The following variables are defined and initialized in the system unit:
|
||||
\begin{verbatim}
|
||||
@ -2007,10 +1998,10 @@ arguments were given to the running program, \var{0} is returned.
|
||||
be between \var{0} and \var{Paramcount}, these values included.
|
||||
The zeroth argument is the name with which the program was started.
|
||||
}
|
||||
{Under Linux, command-line arguments may be longer than 255 characters. In
|
||||
that case, the string is truncated. If you want to access the complete
|
||||
string, you must use the \var{argv} pointer to access the real values of the
|
||||
command-line parameters.}
|
||||
{ In all cases, the command-line will be truncated to a length of 255,
|
||||
even though the operating system may support bigger command-lines. If you
|
||||
want to access the complete command-line, you must use the \var{argv} pointer
|
||||
to access the real values of the command-line parameters.}
|
||||
{\seef{Paramcount}}
|
||||
|
||||
For an example, see \seef{Paramcount}.
|
||||
@ -2097,7 +2088,6 @@ If \var{F} is a typed file, then each of the variables must be of the type
|
||||
specified in the declaration of \var{F}. Untyped files are not allowed as an
|
||||
argument.}
|
||||
{If no data is available, a run-time error is generated. This behavior can
|
||||
|
||||
be controlled with the \var{\{\$i\}} compiler switch.}
|
||||
{\seep{Readln}, \seep{Blockread}, \seep{Write}, \seep{Blockwrite}}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user