Introduction

MADS is oriented towards users of QA, XASM, and FA. The syntax is borrowed from QA, some macro commands and syntax come from XASM and Sparta DOS X (SDX) support is inherited from FA. Additional characters are allowed in label names. Support has been added for the WDC 65816 CPU, macros, procedures, memory partitioning into virtual memory banks and nested label names.

The maximum number of labels and macros is only limited by the amount memory on your PC. Specifically, you can have 2147483647 INTEGER entries in dynamic arrays. I am sure that this amount is sufficient :-).

Arithmetic operations are performed with values of type INT64 (signed 64-bit), with the result represented as value of type CARDINAL (unsigned 32-bit). One line can be up to 65535 bytes long, which is also the length limit for label names. However, I did not have the opportunity to check such long labels and lines :-).

Compilation

Mad-Assembler (MADS) is a 32-bit Windows application written in Delphi. Most cross-assemblers are written in C, so to be different I used Delphi 7.0 ;-). The latest sources are available on GitHub.

To compile them, you can use the Delphi compiler if you have Delphi 7.0 or later installed. Thanks to the free Free Pascal Compiler (FPC) it is possible to compile MADS also for other operating system platforms, such as Linux, macOS and more.

Download the Free Pascal Compiler (FPC) package from the Free Pascal site and run the installer.

When you run the installer, you select the directory where FPC will be installed. It is important not to use the exclamation mark ! or other non-standard characters in the directory path. If the compiler fails to compile any file, the reason is most likely a non-standard directory path. Use the following command line to compile MADS. Note that option names are case sensitive:

fpc -Mdelphi -v mads.pas
  • -Mdelphi compile in Delphi mode
  • -v show all error and warning messages
  • -O3 enable code optimizations

Compared to the Delphi compiler, the code generated by FPC is longer. But the speed of the MADS compiled with it is much higher, up to several seconds per run. The attached mads.exe file is compiled using FPC.

MADS vs. XASM

Similarities

  • same syntax
  • same exit codes
  • same macro commands

Differences and Additions

  • MADS supports small additions to ORG, e.g. ORG [[expression]]address[,address2].
  • MADS does not accept ORG a:address nor ORG f:address.
  • MADS tolerates white spaces and accepts them for logical expressions, arithmetic, definitions of constants and variables. XASM does not like white spaces.
  • MADS allows expressions to be placed between parentheses () []. XASM only allows them between [].
  • MADS supports definitions of constants and variables with local, global and temporary scope. XASM only supports global scope.
  • MADS supports defining real numbers via the .FL .FL real directive. XASM via the DTA R, DTA R(real) pseudo command.
  • MADS offers more extensive support for the pseudo command INS.
  • MADS does not accept the lda (203),0 syntax.
  • MADS supports writing programs for Sparta DOS X.
  • MADS supports the generation of relocatable code in its own format.
  • MADS distinguishes between single quotes lda #' ' (ATASCII encoding) and double quotes lda #" " (INTERNAL encoding) for characters and strings. XASM treats both forms the same (ATASCII encoding). Of course, for DTA data, quotes are not distinguished by MADS.
  • MADS supports the + addition to increase and the - addition to decrease the index register in indexed addressing modes, e.g.:
  lda $2000,x+    ->    lda $2000,x
                        inx
  • MADS supports the +<offset> addition to increase and the -<offset> addition to decrease the address of the main operand in absolute indexed addressing modes, e.g.:
  lda $2000,x+2   ->    lda $2002,x