Foreword
Mad-Pascal (MP) is a 32-bit Turbo Pascal compiler for Atari 8-Bit and other MOS 6502 CPU-based computers. By design, it is compatible with the Free Pascal Compiler (FPC) (the -MDelphi switch should be active). This means the possibility of obtaining executable code for Atari 8-bit, Windows, and every other platform for which FPC exists. Mad-Pascal is not a port of FPC. It has been written based on SUB-Pascal (2009) and XD-Pascal (2010), the author of which is Vasiliy Tereshkov.
Mad-Pascal uses 64KB of primary memory. The class TMemoryStream provides access to extended memory. A program that works on Atari 8-Bit might have problems on Windows and other platforms if, for example, the pointers have not been initialized with the address of a variable. Writing via an uninitialized pointer results in an attempt to write to the address 0x0 and causes a memory protection fault.
The strengths of Mad-Pascal include the fast and convenient possibility of including inline assembly. A program using inline ASM only works on platforms with MOS 6502 CPU.
Variable allocation is static. There is no dynamic memory management. Parameters are passed to functions by value, variable, or constant.
The available features are:
IfCaseForWhileRepeatstatements- Compound statements
LabelGotostatements- Arithmetic and boolean operators
- Procedures and functions with up to 8 parameters. The returned value of a function is assigned to a predefined
RESULTvariable - Static local variables
- Primitive data types, all types except the
ShortReal/Realtype, are compatible. Pointers are dereferenced as pointers toWord:CardinalWordByteBooleanStringPCharCharIntegerSmallIntShortIntPointerFileTextShortRealRealfixed-pointFloatSingleFloat16
- One-dimensional and Two-dimensional arrays (with zero lower bound) of any primitive type. Arrays are treated as pointers to their origins (like in C) and can be passed to subroutines as parameters
- Predefined type string
[N], which is equivalent toarray [0..N] of Char Typealiases.RecordsObjects- Separate program modules
- Separate library modules
- Recursion
Folder Structure
In the folder Mad-Pascal, the following files and subfolders are required:
MP\
mp.exe
base\
atari\
c4p\
c64\
common\
neo\
raw\
runtime\
rtl_default.asm
rtl6502_a8.asm
rtl6502_c4p.asm
rtl6502_c64.asm
rtl6502_neo.asm
rtl6502_raw.asm
blibs\
dlibs\
include\
lib\
src\
targets\
wblibs\
Compiling
To compile the sources of Mad-Pascal use the Free Pascal Compiler (FPC), which can be downloaded from freepascal.org.
Launch the installer and choose the folder for the installation of FPC. It is crucial not to use the exclamation mark ! or other nonstandard characters in the folder name. If it fails to compile any file, it is probably the fault of a nonstandard pathname. The command line launching the compilation may look as follows (letter case in parameter names matters):
fpc -Mdelphi -v -O3 mp.pas
-Mdelphiallows for Delphi format file compilation-vshows all error and warning diagnostics-O3performs code optimization