MACRO-11

MACRO-11 is an assembly language with macro facilities for PDP-11 minicomputers from Digital Equipment Corporation (DEC). It is the successor to PAL-11 (Program Assembler Loader), an earlier version of the PDP-11 assembly language without macro facilities.

The MACRO-11 assembly language was designed for the PDP-11 minicomputer family. It was supported on all DEC PDP-11 operating systems. PDP-11 Unix systems also include an assembler (called "as"), structurally similar to MACRO-11 but with different syntax and fewer features.

Programming example

A complete "Hello, world!" program in PDP-11 macro assembler, to run under RT-11:

        .TITLE  HELLO WORLD
        .MCALL  .TTYOUT,.EXIT
HELLO:: MOV     #MSG,R1  ;STARTING ADDRESS OF STRING
1$:     MOVB    (R1)+,R0 ;FETCH NEXT CHARACTER
        BEQ     DONE     ;IF ZERO, EXIT LOOP
        .TTYOUT          ;OTHERWISE PRINT IT
        BR      1$       ;REPEAT LOOP
DONE:   .EXIT

MSG:    .ASCIZ /Hello, world!/
        .END    HELLO

The .MCALL pseudo-op warns the assembler that the code will be using the .TTYOUT and .EXIT macros. The .TTYOUT and .EXIT macros are defined in the standard system macro library to expand to the EMT instructions to call the RT-11 monitor to perform the requested functions.

If this file is HELLO.MAC, the RT-11 commands to assemble, link and run (with console output shown) are as follows:

.MACRO HELLO
ERRORS DETECTED:  0

.LINK HELLO

.R HELLO
Hello, world!
.

(The RT-11 command prompt is ".")

For a more complicated example of MACRO-11 code, two examples chosen at random are Kevin Murrell's KPUN.MAC, or Farba Research's JULIAN routine. More extensive libraries of PDP-11 code can be found in the Metalab freeware and Trailing Edge archives.[1][2]

gollark: Thanks!
gollark: I think this is technically possible to implement, so bee⁻¹ you.
gollark: This is underspecified because bee² you, yes.
gollark: All numbers are two's complement because bee you.
gollark: The rest of the instruction consists of variable-width (for fun) target specifiers. The first N target specifiers in an operation are used as destinations and the remaining ones as sources. N varies per opcode. They can be of the form `000DDD` (pop/push from/to stack index DDD), `001EEE` (peek stack index EEE if source, if destination then push onto EEE if it is empty), `010FFFFFFFF` (8-bit immediate value FFFFFFFF; writes are discarded), `011GGGGGGGGGGGGGGGG` (16-bit immediate value GGGGGGGGGGGGGGGG; writes are also discarded), `100[H 31 times]` (31-bit immediate because bee you), `101IIIIIIIIIIIIIIII` (16 bits of memory location relative to the base memory address register of the stack the operation is conditional on), `110JJJJJJJJJJJJJJJJ` (16 bit memory location relative to the top value on that stack instead), `1111LLLMMM` (memory address equal to base memory address of stack LLL plus top of stack MMM), or `1110NNN` (base memory address register of stack MMM).Opcodes (numbered from 0 in order): MOV (1 source, as many destinations as can be parsed validly; the value is copied to all of them), ADD (1 destination, multiple sources), JMP (1 source), NOT (same as MOV), WR (write to output port; multiple sources, first is port number), RE (read from input port; one source for port number, multiple destinations), SUB, AND, OR, XOR, SHR, SHL (bitwise operations), MUL, ROR, ROL, NOP, MUL2 (multiplication with two outputs).

References

This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.