!pr0
!lm12
!rm77
Macro Can Build Macros............................Mike Laumer

The S-C Macro Assembler can do a lot of things even its designer never dreamed of.  The macro capability may be limited compared to mainframe systems, but it still has a lot of power.

A few days ago I got a bright idea that maybe you could even define macros inside macros, or write a macro that builds new macros.  Lo and behold, it works!  Here is what I tried:

!lm+5
1000        .MA BLD
1010        ]1
1020        ]2
1030        ]3
1040        ]4
1050        .EM
!lm-5

Notice that every line from the opcode field on is defined by a macro parameter. I called it with lines like this:

!lm+5
1060        >BLD ".MA ATOB","LDA A","STA B",".EM"
1070        >BLD ".MA BTOA","LDA B","STA A",".EM"
!lm-5

Here is how it all looks when you type ASM:

               1010        .MA BLD
               1020        ]1
               1030        ]2
               1040        ]3
               1050        ]4
               1060        .EM
0800-          1070        >BLD ".MA ATOB","LDA A","STA B",".EM"
               0000>        .MA ATOB
               0000>        LDA A
               0000>        STA B
               0000>        .EM
0800-          1080        >BLD ".MA BTOA","LDA B","STA A",".EM"
               0000>        .MA BTOA
               0000>        LDA B
               0000>        STA A
               0000>        .EM
               1090 *--------------------------------
0800-          1100 A      .BS 1
0801-          1110 B      .BS 1
               1120 *--------------------------------
0802-          1130        >ATOB
0802- AD 00 08 0000>        LDA A
0805- 8D 01 08 0000>        STA B
0808-          1140        >BTOA
0808- AD 01 08 0000>        LDA B
080B- 8D 00 08 0000>        STA A


I don't know whether this is really useful or not....  If you think of a way to use it that is significant, I'd like to hear from you!
