]> Shamusworld >> Repos - rmac/blobdiff - macro.c
Fix for "*" getting bad section attributes, reported by A. Seed.
[rmac] / macro.c
diff --git a/macro.c b/macro.c
index 3f3e81b82fe185d51606ee620711a57e224ab0ae..5aaa842a52d78d75c4808d676b384a54d5e1d914 100644 (file)
--- a/macro.c
+++ b/macro.c
@@ -3,7 +3,7 @@
 // MACRO.C - Macro Definition and Invocation
 // Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
 // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
-// Source Utilised with the Kind Permission of Landon Dyer
+// Source utilised with the kind permission of Landon Dyer
 //
 
 #include "macro.h"
@@ -17,8 +17,6 @@
 #include "token.h"
 
 
-//static void SetupDefaultMacros(void);
-
 LONG curuniq;                                                          // Current macro's unique number
 //TOKEN ** argp;                                                               // Free spot in argptrs[]
 int macnum;                                                                    // Unique number for macro definition
@@ -36,7 +34,7 @@ static int rptlevel;                                          // .rept nesting level
 
 
 //
-// Initialize Macro Processor
+// Initialize macro processor
 //
 void InitMacro(void)
 {
@@ -44,12 +42,11 @@ void InitMacro(void)
        macnum = 1;
 //     argp = NULL;
        argp = 0;
-//     SetupDefaultMacros();
 }
 
 
 //
-// Exit from a Macro;
+// Exit from a macro;
 // -- pop any intervening include files and repeat blocks;
 // -- restore argument stack;
 // -- pop the macro.
@@ -84,13 +81,12 @@ of another (nested macros). Need to fix that somehow.
        DEBUG printf("%d (nargs = %d)\n", argp, imacro->im_nargs);
 
        fpop();
-//     mjump_align = 0;
        return 0;
 }
 
 
 //
-// Add a Formal Argument to a Macro Definition
+// Add a formal argument to a macro definition
 //
 int defmac2(char * argname)
 {
@@ -337,7 +333,7 @@ int lncatch(int (* lnfunc)(), char * dirlist)
 
        for(;;)
        {
-               if (tokln() == TKEOF)
+               if (TokenizeLine() == TKEOF)
                {
                        errors("encountered end-of-file looking for '%s'", dirlist);
                        fatal("cannot continue");
@@ -354,19 +350,11 @@ int lncatch(int (* lnfunc)(), char * dirlist)
                        if ((tok[2] == ':' || tok[2] == DCOLON))
                        {
                                if (tok[3] == SYMBOL)                   // label: symbol
-#if 0
-                                       p = (char *)tok[4];
-#else
                                        p = string[tok[4]];
-#endif
                        }
                        else
                        {
-#if 0
-                               p = (char *)tok[1];                             // symbol 
-#else
                                p = string[tok[1]];                             // Symbol
-#endif
                        }
                }
 
@@ -451,14 +439,6 @@ int InvokeMacro(SYM * mac, WORD siz)
 //     argp = 0;
        DEBUG printf("InvokeMacro: argp: %d -> ", argp);
 
-#if 0
-       if ((!strcmp(mac->sname, "mjump") || !strcmp(mac->sname, "mpad")) && !in_main)
-       {
-               error("macro cannot be used outside of .gpumain");
-               return ERROR;
-       }
-#endif
-
        INOBJ * inobj = a_inobj(SRC_IMACRO);            // Alloc and init IMACRO 
        IMACRO * imacro = inobj->inobj.imacro;
        imacro->im_siz = siz;
@@ -572,12 +552,13 @@ int InvokeMacro(SYM * mac, WORD siz)
 Shamus:
 This construct is meant to deal with nested macros, so the simple minded way
 we deal with them now won't work. :-/ Have to think about how to fix.
-What we could do is simply move the argp with each call, and move it back by the
-number of arguments in the macro that's ending. That would solve the problem nicely.
+What we could do is simply move the argp with each call, and move it back by
+the number of arguments in the macro that's ending. That would solve the
+problem nicely.
 [Which we do now. But that uncovered another problem: the token strings are all
-stale by the time a nested macro gets to the end. But they're supposed to be symbols,
-which means if we put symbol references into the argument token streams, we can
-alleviate this problem.]
+stale by the time a nested macro gets to the end. But they're supposed to be
+symbols, which means if we put symbol references into the argument token
+streams, we can alleviate this problem.]
 */
 #if 0
                        argptr = (TOKEN **)malloc((nargs + 1) * sizeof(LONG));
@@ -625,49 +606,3 @@ alleviate this problem.]
        return OK;
 }
 
-
-#if 0
-//
-// Setup inbuilt macros (SubQMod)
-//
-static void SetupDefaultMacros(void)
-{
-       curmac = NewSymbol("mjump", MACRO, 0);
-       curmac->svalue = 0;
-       curmac->sattr = (WORD)(macnum++);
-       argno = 0;
-       defmac2("cc");
-       defmac2("addr");
-       defmac2("jreg");
-//     curmln = NULL;
-       curmac->lineList = NULL;
-       defmac1("  nop", -1);
-       defmac1("  movei #\\addr,\\jreg", -1);
-       defmac1("  jump  \\cc,(\\jreg)", -1);
-       defmac1("  nop", -1);
-       defmac1("  nop", -1);
-
-       curmac = NewSymbol("mjr", MACRO, 0);
-       curmac->svalue = 0;
-       curmac->sattr = (WORD)(macnum++);
-       argno = 0;
-       defmac2("cc");
-       defmac2("addr");
-//     curmln = NULL;
-       curmac->lineList = NULL;
-       defmac1("  jr    \\cc,\\addr", -1);
-       defmac1("  nop", -1);
-       defmac1("  nop", -1);
-
-       curmac = NewSymbol("mpad", MACRO, 0);
-       curmac->svalue = 0;
-       curmac->sattr = (WORD)(macnum++);
-       argno = 0;
-       defmac2("size");
-//     curmln = NULL;
-       curmac->lineList = NULL;
-       defmac1("  .rept (\\size/2)", -1);
-       defmac1("     nop", -1);
-       defmac1("  .endr", -1);
-}
-#endif