Last Update: 10-July
This document answers frequently asked questions about FPK-Pascal.
Document Index:
FPK-Pascal is a 32 bit Pascal compiler for DOS, OS/2 and Linux (OS/2 only in version 0.5.2, Linux planned for the near future).
The compiler is written in Pascal and is able to compile the own sources. The sources are included. FPK-Pascal requires at least a 386 processor and XMS memory. It is reported to run on a 386 SX (25 MHz) with 2 Megabyte RAM. Suggested configuration is a 486 with 4 or 8 Megabyte.
short history: 6/93 project start 10/93 first little programs work 3/95 the compiler compiles the own sources
But I'am working only may be 5 hours a week.
The compiler is available via FTP and WWW:
The compiler supports OOP. Maybe there are some bugs look at BUGS (listing not yet available)
It's true, the compiler don't support (* ... *).
It's not easy to do this. But the compiler supports nested comments like
{ This is a comment {{ ... }}}
It works like TP. The first keyword in the file must be UNIT (not case sensitive). The compiler will generate two files: XXX.PPU and XXX.O. The PPU file contains the interface informations for the compiler and the O-file the machine code (unix a.out styled object file). The main programs must contain a keyword USES.
A port of TV for FPKPascal will be done. It will be completly rewritten for 32 bit. For information have a look at FreeVision home page
For recompiling the system unit, change to the directory SOURCE/RTL/DOS Then type the following: PPC386 -Us -q- -OGa -Sg system Now copy the new SYSTEM.PPU to BIN and SYSTEM.O to LIB The compiler switches do the following: -Us generate a system unit -q- print some statistics -OGa easy optimizations for speed -Sg allow GOTO and LABEL (I think not required for the system unit
If you have some problems with PPC386 (Segment violation errors occur), try it with other compiler switches, if this not works send me please a bug report:
fnklaemp@cip.ft.uni-erlangen.deProgram crashes with a segment violation error.
This error occurs mostly if the program accesses a memory location, which should not be accessed by the program.
FPKPascal has nothing to do with GNU Pascal. But it's using the GNU AS and the DOS Extender of DJ Delorie from GNU C for DOS.
function overloading is implemented, like in C++:
procedure a(i : integer); begin end; procedure a(s : string); begin end; begin a('asdfdasf"); a(1234); end.
C calling conventions are implemented: The compiler pushes the parameters from right to left, but the procedure must clear the stack. For calling the C function strcmp declare the following:
function _strcmp(s1 : pchar;s2 : pchar) : integer; [ SYSTEM ];
or (since version 0.6.0):
function _strcmp(s1 : pchar;s2 : pchar) : integer; [ C ];
I'am having some problems with DJGPP 2.0. And a second disavantage, in my opinion, is, that DJGPP 2.0 needs DPMI.
Look at InitGraph
The syntax is different from the one in Borland Pascal.
A description of the syntax can be found in the DJGPP FAQ
http://www.delorie.com/djgpp/v2faq/faq102.html#Syntax
or in Brennan's Guide to Inline Assembly
http://www.rt66.com/~brennan/djgpp/djgpp_asm.html.
Plus you can use this convertor program
The DOS memory is mapped to $e0000000 by the memory manager.
type pbyte = ^byte; var mem,txt : pbyte; begin mem:=pbyte($e0000000); { DOS memory } txt:=pbyte($e00b8000); { VGA text } { read the first 3 characters from top left of the screen } writeln(chr(txt[0]),chr(txt[2]),chr(txt[4])); { access BIOS data area, this example reads out memory size } writeln (mem[$40*16 + $13] + mem[$40*16 + $14] * 256); end.
Writing to the graphics screen should be possible with: (code untested!)
procedure putpixel (x,y,color:byte); var p : pointer; begin p := $e00a0000; (p+x+320*y)^ := color; end;
or
screen := pointer($E00A0000); move(buffer,screen^,64000);
The compiler and all compiled programs require a math coprocessor, but it's possible to include an emulator. This is done by setting the GO32 environment variable.
SET GO32=driver [your grdriver] emu [path to PPVBINV]EMU387
Example: with a vanilla VGA card and FPK-pascal installed to C:VPP, you would insert the following to your SET_PP.BAT :
SET GO32=DRIVER C:\PP\DRIVERS\VGA.GRD EMU C:\PP\BIN\EMU387
There is a problem with the compiler and Win 95 with computers with less than 16 MB. First set in the properties of the DOS box the DPMI memory size to max value. Now try to start a demo program in the dos box, like HELLO (the start goes some time). If this works you can get the compiler work, you must recompile the compiler with a lower heap size, perhaps 2 or 4 MB (option -Chxxxx).
FPK is set to normally only allocate 4 meg. If it just allocated all it could get, people running windows would have problems as windows increased the swap file size to give the program more memory, on and on until the swap file drive is full.
You can while compiling specify the size of the heap with -Chxxxx.
The default value is -Ch4000000. Try -Ch10000000 (with enough swap space!)
You have to use assembly language, which is AT&T style. You would type something like:
asm movw PORTNUM,%dx movw DATA,%ax outw %ax,%dx end;
Where portnum is the port you want to send to and data is the data to send. If either of these are absolute numbers, include a dollar ($) sign before the number.
If there's something missing here, please tell Klaus Hartnegg, klaus@mailserv.brain.uni-freiburg.de
> How do you make colored text?
Well, like in TP:
uses crt;
begin textcolor(red); textbackground(blue); writeln('Hello world'); end.
For more color contants look to the source of the CRT unit.
> > How do you add a graphic (in a certain position)?
Which OS do you use ?
> When i compile my program TEST.PP and make TEST. to .EXE and delete the .O > .S . files my program does not work. Displays only : > > go32.exe: usuage: go32.....etc
Do ppc386 test.pp go32 test
or (to get a DOS executable)
ppc386 test.pp aout2exe test
and run the exe file with a simple test