PAL-11A Syntax

At its most basic, an assembler needs to interpret instruction mnemonics their operands, determine their addressing modes, and encode them into their raw instruction words or bytes. PAL-11A does that, and includes a few other simple features that are very helpful for programmers, such as symbol handling and the ability to encode raw words, bytes, and even character strings into the assembled binary. It does not support macros, which are common in most assemblers; DEC later released an enhanced assembler called MACRO-11 that was one of the primary programming languages of the PDP-11 series.

A line of PAL-11A assembler code has the format, with a label, instruction mnemonic, its operands, and a comment.

LABEL:  INS     OP1,OP2         ; COMMENT

Each of these is optional, except for the operands, which can only appear if there is also an instruction mnemonmic. By convention, if a label is present, it starts in the first column, if a mnemonic appears, it starts in the ninth column (one tab from the first colummn), if there are operands, they appear in the seventeenth column (two tabs from the first column), adn if there is a comment, it appears in the thirty-third column (four tabs from the first column). Lines longer than 72 columns will be truncated, and the assembler will emit a warning.

PAL-11A is case insensitive; internally, all lower case letters are converted to upper case.

Only the first six characters of the label are significant, and can be letters or numbers. During assembly, the location of the instruction at the label is stored in the symbol table, and can be referenced through the program. For example:

        MOV     #12,%0          ; SET R0 TO TEN
LOOP:   DEC     %0              ; DECREMENT R0
        TST     %0              ; SET STATUS BITS BASED ON R0
        BNE     LOOP            ; IF Z IS 0, BRANCH TO LOOP
        HALT                    ; HALT THE PROCESSOR
        .END                    ; END PROGRAM

Constants can also be directly assigned to symbols. One common use of this is to define the symbols R0, R1, etc., to represent their internal PAL-11A symbols for registers %0, %1, etc.

The beginning of most programs sets up these symbols, sets the stack pointer to a particular location, and tells the assembler where to start assembling.

; MY PROGRAM

; SET UP REGISTER SYMBOLS
R0=     %0
R1=     %1
R2=     %2
R3=     %3
R4=     %4
R5=     %5
SP=     %6
PC=     %7

; ASSEMBLE AT LOCATION 1000
.=      1000

START:  MOV     #1000,SP        ; SET SP TO 1000

                                ; PROGRAM CODE HERE

        HALT                    ; DONE.  HALT THE PROCESSOR
        JMP     START           ; RESTART UPON CONT
        .END

PAL-11A also supports a simple assembly-time expression evaluation system. Expressions can use + and - arithmetic operators, & and ! (OR) logical operators, ASCII character constants 'A, and ., which evaluates to the address of the current assembly location.

PAL-11A also supports a small number of directives, which are instructions for the assembler itself, and are not machine instructions:

  • .EOT: Indicates the End Of Tape. A program can be split across multiple paper tapes, and this directive tells the assemebler that additional source tapes should be read.
  • .EVEN: Increments the assembly location if it is at an odd location. Used to align the next instruction to an even address.
  • .END: Tells the assembler that this is the end of the program. If it has an operand, the Absolute Loader will automatically start the program at the given address.
  • .WORD: Embeds one or more words at the assembly location. This allows a programmer to prepopulate memory with the given values.
  • .BYTE: Embeds one of more bytes at the assembly location. Like .WORD, this allows a programmer to prepopulate memory with the given values.
  • .ASCII: Embeds the ASCII values as bytes to the assembly location. The first character is considered a delimiter, so to encode the bytes for the string VALUE, the programmer can use /VALUE/ or "VALUE", or even XVALUEX. The forward slash is the most commonly used.

References