On Sat, Jul 13, 2024 at 5:20 PM Aron Insinga <aki@insinga.com> wrote:
On 7/13/24 13:36, Paul Winalski wrote:
Neither the VAX assembler nor the VAX MACRO compiler treats macros as high-level entities.  I know of no assembler that would do such a thing.

-Paul W.


This morning I would have agreed with you but I think I found a counter-example.  At MIT, there were 2 assemblers written for the TX-0 and later ported and retargeted to the PDP-1: MACRO (which DEC adopted) and then Midas (which MIT stayed with for the PDP-6 and PDP-10).

The MIDAS assembler manual says that it copies characters from the macro body into the source program (as we would expect to happen today for a macro, as opposed to an inline procedure):
http://www.bitsavers.org/pdf/mit/rle_pdp1/memos/PDP-1_MIDAS.pdf
p 10 in the document says:
When a macro instruction is called, MIDAS reads out the characters which form the macro-instruction definition, substitutes the characters of the arguments for the dummy arguments, and inserts the resulting characters into the source program as if typed there originally.
However, 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* (although it does replace labels with memory addresses):
https://bitsavers.org/pdf/dec/pdp1/PDP-1_Macro.pdf
p 19 in the document says:

Those two quotes from the documentation are saying the same thing.  The MACRO quote says the process is this:

1. Evaluate the expressions in the argument list of the macro.

2. Substitute these values for the dummy symbols in the macro.

3. Process the resulting text exactly the same way as non-macro input to the assembler.

4.  Place the resulting binary machine words into the object file.

Steps (1) and (2) match what the Midas text says.  Steps (3) and (4) are conventional processing of assembler input.

There is nothing unusual here.  MACRO is decidedly NOT treating the macro calls as higher-level entities.  It is doing simple text substitution and then treating it as it would any other input.

-Paul W.