[Home] [Services] [Philosophy] [Experience] [Software] [Publications] [Tips] [Contact]


PAPP - Portable Assembly Pre-Processor
xml-format - XML Beautifier
Diskimage Tools
Matlab Installer

The papp command preprocesses assembly language code, much like cpp does for C and C++.

Papp parses assembly language programs line-by-line, processing macro definitions, macro references, and includes. Output is sent to the standard output.

Papp can be used with any assembler, but was specifically designed to enhance the programming experience with the SPIM MIPS simulator, and follows a syntax taken from MIPS assembly language documentation.

Macro definitions take the following general form:

    .macro name($arg1[,$arg2...])
    Macro text

Argument names must begin with a $, and should use standard variable naming conventions that do not conflict with any tokens in the assembly language being preprocessed. References to arguments within the macro text are replaced by the text from the macro invocation.

MIPS assembly language (MAL) example:

    .macro push($x)
    sw      $x, ($sp)
    addi    $sp, $sp, -4

    .macro swap($r1,$r2,$temp)
    move    $temp, $r1
    move    $r1, $r2
    move    $r2, $temp

Macros are invoked using parentheses surrounding the argument:

    lw      $t0, x
    swap($a0, $a1, $t1)

Files can be included using the .include directive. This is especially useful for storing commonly used predefined constants and macros in a separate file for inclusion in other programs. For example, if the macro examples above are stored in a file called mymacros.mal, then the following could be used to import them to another program (in the same directory):