On 7/13/24 19:46, John Levine wrote:
It appears that Douglas McIlroy
<douglas.mcilroy(a)dartmouth.edu> said:
-=-=-=-=-=-
> the DEC PDP-1 MACRO assembler manual says that a macro call
> is expanded by copying the *sequence of 'storage words' and
> advancing the current location (.) for each word copied*
> I am quite surprised.
I looked at the manual and I think he's misreading it. The "words"
in
question are the tokens in the macro definition.
The example macros look pretty straightforward, instructions and
pseudo-ops that are expanded replacing dummy arguments by actual ones.
There's no conditional assembly so each macro is just a parameterized
chunk of code.
https://bitsavers.org/pdf/dec/pdp1/PDP-1_Macro.pdf
R's,
John
Possibly, but they use 'syllables' for tokens (symbols or integers), and
they say here that they advance the location counter after each word
copied. If they were copying characters into the input stream, they
would not be incrementing the location counter ('.') after each word
transferred.
And as you say, it is simple parameter substitution, so tracking which
macro argument goes into which instruction's address field is easy. The
instruction format is simple. So for each line in the macro definition
body, if the opcode is a memory reference instruction, put the argument
number in the binary instruction address field before storing the
instruction word in a list/block. When expanding the macro, if the
opcode is a memory reference instruction, get the argument number from
the address field and replace it with the symbol table value of the
symbol passed in as the actual argument, and store the word in the
output stream (and incrememnt '.').
I haven't yet gotten the 18-bit-but-incompatible PDP-4 documentation for
comparison. [IIRC the PDP-4 assembler was the one with a single pass
assembler that punched the symbol table at the end of the tape, and the
clever loader that read the tape upside down and backwards to first
rebuild the symbol table and then fix up the instructions and load them
into memory.]
- Aron