Mad-Pascal
Mad Pascal Compiler for 6502 (Atari XE/XL, C64, C4Plus, Neo6502)
- Active · last change 11-5-2026
- ★ 167 on GitHub
README
Mad-Pascal
English Documentation / Polska Dokumentacja
Full Pascal Programming Crash Course - Basics to Advanced
Introduction
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.
MP 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 MP 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:
IfCaseFor ToFor InWhileRepeatstatements- 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
ShortRealandRealtypes are compatible. Pointers are dereferenced as pointers toWord:CardinalWordByteBooleanIntegerSmallIntShortIntCharStringPCharPointerFileTextShortRealRealfixed-pointFloat16Single/ Float
- 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 TypealiasesRecordsObjects- Separate program modules (
PROGRAM,UNIT,LIBRARY) - Recursion
Compile
src\fpc -MDelphi -vh -O3 mp.pasUsage
Atari 8-Bit
mp.exe filename.pas -ipath:<MadPascalPath>\lib
mads.exe filename.a65 -x -i:<MadPascalPath>\baseBAT
<MadPascalPath>\MP.exe %1 -ipath:<MadPascalPath>\lib -ipath:<MadPascalPath>\blibs
if exist %~dp1%~n1.a65 (
mads.exe "%~dp1%~n1.a65" -x -i:<MadPascalPath>\base
if exist "%~dp1%~n1.obx" altirra "%~dp1%~n1.obx"
)Commodore 64
mp.exe -t c64 filename.pas -ipath:<MadPascalPath>\lib
mads.exe filename.a65 -x -i:<MadPascalPath>\baseCommodore Plus/4
mp.exe -t c4p filename.pas -ipath:<MadPascalPath>\lib
mads.exe filename.a65 -x -i:<MadPascalPath>\baseNeo6502
mp.exe -t neo filename.pas -ipath:<MadPascalPath>\lib
mads.exe filename.a65 -x -i:<MadPascalPath>\baseRAW
mp.exe -t raw filename.pas -ipath:<MadPascalPath>\lib
mads.exe filename.a65 -x -i:<MadPascalPath>\baseTools
Projects in Mad-Pascal
A8 Mad-Pascal Window Library
This text-mode windowing library has window controls and modern gadgets (widgets). The gadgets allow you to build input forms that use buttons, radio buttons, input strings (with scrolled lengths and type restrictions), check boxes, progress bars, etc. This allows you to build applications with "modern" interfaces.
Mad-Pascal libraries
Compression / Decompression
Decompression
- DEFLATE -> unit, sample
- APL -> unit, sample
- LZ4 -> unit, sample
- PACKFIRE -> unit, sample
- POWER PACKER -> unit, sample
- SNAPPY -> unit, sample
- UPKR -> unit, sample
- ZX0 -> unit, sample
- ZX2 -> unit, sample
- ZX5 -> unit, sample
VBXE
Benchmarks
| CC65 | Mad-Pascal | Millfork | |
|---|---|---|---|
| Sieve (less is better) | 602 | 577 | 579 |
| YoshPlus (higher is better) | 41933 | 41933 | 41933 |
| Chessboard (higher is better) | 76 | 88 | 82 |
Floating Point
| iteration x 256 | Atari OS | FastChip | MP Single | MP Real |
|---|---|---|---|---|
| add, sub, mul, div | 232 | 118 | 64 | 99 |
| add, sub, mul, div, sin, cos | 5820 | 2915 | 3728 | 1231 |
- MP Single: IEEE754-32bit
- MP Real: Q24.8 Fixed Point
Suite
Links
- HOME Page
- Mad-Pascal on Atari Age Forum
- Games in Mad-Pascal
- Mad-Pascal examples
- Mad-Pascal on Atari Area Forum
- Mad-Pascal Announcement for WUDSN
- Some advice
- Programowanie w Mad-Pascal dla C+4
- Commodore Plus/4, Mad-Pascal i bitmapy
Pascal related
- Awesome Pascal
- Demoscene samples
- Turbo Pascal vintage collection
- Nero 5 Chess program
- KC Chess
- FreePascal meets SDL
YouTube
- WUDSN IDE Tutorial
- Arcadia
- Flob
- ProHiBan (Sokoban)
- The Hangmad
- gravity
- Block Attack
- Turbo Pascal "Sokoban"
- Tron +4. Mad-Pascal i C+4
- Mad-Pascal Commodore Plus/4 plasma effect with TEDzakker demo music
- Dungeon Adventurer
- Time Wizard

