]> Shamusworld >> Repos - rmac/commitdiff
More fixups to remove warnings, removal of more cruft.
authorShamus Hammons <jlhamm@acm.org>
Tue, 5 Mar 2013 17:47:22 +0000 (11:47 -0600)
committerShamus Hammons <jlhamm@acm.org>
Tue, 5 Mar 2013 17:47:22 +0000 (11:47 -0600)
24 files changed:
68kgen.c
amode.h
debug.c
direct.c
error.c
error.h
expr.c
expr.h
listing.c
listing.h
mach.c
mach.h
macro.c
mark.c
mark.h
object.c
procln.c
procln.h
rmac.c
rmac.h
sect.c
sect.h
token.c
token.h

index b614454bbb601d7df82c059dc1455cfa5a77c974..23da319429c9c443e8c7aac2c3e9264b03c5e32b 100644 (file)
--- a/68kgen.c
+++ b/68kgen.c
 #include <ctype.h>
 #include <stdlib.h>
 
+
 #define        EOS     '\0'
 
 int kwnum = 1;                 /* current op# for kwgen output */
-
-FILE * kfp;                    /* keyword file */
-
+FILE * kfp;                            /* keyword file */
 int lineno = 0;
 
+// Function prototypes
 void error(char *, char *);
 void procln(int, char **);
 
+
 int main(int argc, char ** argv)
 {
        char * namv[256];
diff --git a/amode.h b/amode.h
index cde089522e03108859c7a0ca25f981b174ee1e63..5632fe9a26139380c4c8c5d095a7194932d9297a 100644 (file)
--- a/amode.h
+++ b/amode.h
 #include "rmac.h"
 
 // 68000 and 68020 addressing modes
-#define DREG         000                                    // Dn
-#define AREG         010                                    // An
-#define AIND         020                                    // (An)
-#define APOSTINC     030                                    // (An)+
-#define APREDEC      040                                    // -(An)
-#define ADISP        050                                    // (d16,An) d16(An)
-#define AINDEXED     060                                    // (d8,An,Xn) d8(An,Xn)
-#define ABSW         070                                    // xxx.W
-#define ABSL         071                                    // xxx or xxx.L
-#define PCDISP       072                                    // (d16,PC) d16(PC)
-#define PCINDEXED    073                                    // (d16,PC,Xn) d16(PC,Xn)
-#define IMMED        074                                    // #data
-#define ABASE        0100                                   // (bd,An,Xn)
-#define MEMPOST      0101                                   // ([bd,An],Xn,od)
-#define MEMPRE       0102                                   // ([bc,An,Xn],od)
-#define PCBASE       0103                                   // (bd,PC,Xn)
-#define PCMPOST      0104                                   // ([bd,PC],Xn,od)
-#define PCMPRE       0105                                   // ([bc,PC,Xn],od)
+#define DREG         000                               // Dn
+#define AREG         010                               // An
+#define AIND         020                               // (An)
+#define APOSTINC     030                               // (An)+
+#define APREDEC      040                               // -(An)
+#define ADISP        050                               // (d16,An) d16(An)
+#define AINDEXED     060                               // (d8,An,Xn) d8(An,Xn)
+#define ABSW         070                               // xxx.W
+#define ABSL         071                               // xxx or xxx.L
+#define PCDISP       072                               // (d16,PC) d16(PC)
+#define PCINDEXED    073                               // (d16,PC,Xn) d16(PC,Xn)
+#define IMMED        074                               // #data
+#define ABASE        0100                              // (bd,An,Xn)
+#define MEMPOST      0101                              // ([bd,An],Xn,od)
+#define MEMPRE       0102                              // ([bc,An,Xn],od)
+#define PCBASE       0103                              // (bd,PC,Xn)
+#define PCMPOST      0104                              // ([bd,PC],Xn,od)
+#define PCMPRE       0105                              // ([bc,PC,Xn],od)
 #define AM_USP       0106
 #define AM_SR        0107
 #define AM_CCR       0110
-#define AM_NONE      0111                                   // Nothing
+#define AM_NONE      0111                              // Nothing
 
 // Addressing-mode masks
-#define M_DREG       0x00000001L                            // Dn
-#define M_AREG       0x00000002L                            // An
-#define M_AIND       0x00000004L                            // (An)
-#define M_APOSTINC   0x00000008L                            // (An)+ 
-#define M_APREDEC    0x00000010L                            // -(An)
-#define M_ADISP      0x00000020L                            // (d16,An) d16(An)
-#define M_AINDEXED   0x00000040L                            // (d8,An,Xn) d8(An,Xn)
-#define M_ABSW       0x00000080L                            // xxx.W
-#define M_ABSL       0x00000100L                            // xxx or xxx.L
-#define M_PCDISP     0x00000200L                            // (d16,PC) d16(PC)
-#define M_PCINDEXED  0x00000400L                            // (d16,PC,Xn) d16(PC,Xn)
-#define M_IMMED      0x00000800L                            // #data
-#define M_ABASE      0x00001000L                            // (bd,An,Xn)
-#define M_MEMPOST    0x00002000L                            // ([bd,An],Xn,od)
-#define M_MEMPRE     0x00004000L                            // ([bc,An,Xn],od)
-#define M_PCBASE     0x00008000L                            // (bd,PC,Xn)
-#define M_PCMPOST    0x00010000L                            // ([bd,PC],Xn,od)
-#define M_PCMPRE     0x00020000L                            // ([bc,PC,Xn],od)
-#define M_AM_USP     0x00040000L                            // USP
-#define M_AM_SR      0x00080000L                            // SR
-#define M_AM_CCR     0x00100000L                            // CCR
-#define M_AM_NONE    0x00200000L                            // (nothing)
+#define M_DREG       0x00000001L               // Dn
+#define M_AREG       0x00000002L               // An
+#define M_AIND       0x00000004L               // (An)
+#define M_APOSTINC   0x00000008L               // (An)+ 
+#define M_APREDEC    0x00000010L               // -(An)
+#define M_ADISP      0x00000020L               // (d16,An) d16(An)
+#define M_AINDEXED   0x00000040L               // (d8,An,Xn) d8(An,Xn)
+#define M_ABSW       0x00000080L               // xxx.W
+#define M_ABSL       0x00000100L               // xxx or xxx.L
+#define M_PCDISP     0x00000200L               // (d16,PC) d16(PC)
+#define M_PCINDEXED  0x00000400L               // (d16,PC,Xn) d16(PC,Xn)
+#define M_IMMED      0x00000800L               // #data
+#define M_ABASE      0x00001000L               // (bd,An,Xn)
+#define M_MEMPOST    0x00002000L               // ([bd,An],Xn,od)
+#define M_MEMPRE     0x00004000L               // ([bc,An,Xn],od)
+#define M_PCBASE     0x00008000L               // (bd,PC,Xn)
+#define M_PCMPOST    0x00010000L               // ([bd,PC],Xn,od)
+#define M_PCMPRE     0x00020000L               // ([bc,PC,Xn],od)
+#define M_AM_USP     0x00040000L               // USP
+#define M_AM_SR      0x00080000L               // SR
+#define M_AM_CCR     0x00100000L               // CCR
+#define M_AM_NONE    0x00200000L               // (nothing)
 
 // Addr mode categories
-#define C_ALL        0x00000fffL
-#define C_DATA       0x00000ffdL
-#define C_MEM        0x00000ffcL
-#define C_CTRL       0x000007e4L
-#define C_ALT        0x000001ffL
+#define C_ALL        0x00000FFFL
+#define C_DATA       0x00000FFDL
+#define C_MEM        0x00000FFCL
+#define C_CTRL       0x000007E4L
+#define C_ALT        0x000001FFL
 
 #define C_ALTDATA    (C_DATA&C_ALT)
 #define C_ALTMEM     (C_MEM&C_ALT)
 #define C_NONE       M_AM_NONE
 
 // Scales
-#define TIMES1       00000                                  // (empty or *1)
-#define TIMES2       01000                                  // *2
-#define TIMES4       02000                                  // *4
-#define TIMES8       03000                                  // *8
+#define TIMES1       00000                             // (empty or *1)
+#define TIMES2       01000                             // *2
+#define TIMES4       02000                             // *4
+#define TIMES8       03000                             // *8
 
-#define EXPRSIZE     128                                    // Maximum #tokens in an expression
+#define EXPRSIZE     128                               // Maximum #tokens in an expression
 
 // Addressing mode variables, output of amode()
 extern int nmodes;
@@ -97,18 +97,19 @@ extern SYM * a0esym, * a1esym;
 // Mnemonic table structure
 #define MNTAB  struct _mntab
 MNTAB {
-   WORD mnattr;                                             // Attributes (CGSPECIAL, SIZN, ...)
-   LONG mn0, mn1;                                           // Addressing modes
-   WORD mninst;                                             // Instruction mask
-   WORD mncont;                                             // Continuation (or -1)
-   int (*mnfunc)(WORD, WORD);                                         // Mnemonic builder
+   WORD mnattr;                                                        // Attributes (CGSPECIAL, SIZN, ...)
+   LONG mn0, mn1;                                              // Addressing modes
+   WORD mninst;                                                        // Instruction mask
+   WORD mncont;                                                        // Continuation (or -1)
+   int (*mnfunc)(WORD, WORD);                  // Mnemonic builder
 };
 
 // mnattr:
-#define CGSPECIAL    0x8000                                 // Special (don't parse addr modes)
+#define CGSPECIAL    0x8000                            // Special (don't parse addr modes)
 
 // Prototypes
 int amode(int);
 int reglist(WORD *);
 
 #endif // __AMODE_H__
+
diff --git a/debug.c b/debug.c
index 7d498c77eaa36d6fce4650d995222d449bd482ce..1930ec8c8fd4b4d51295d1f0b3c892230ce2e3f3 100644 (file)
--- a/debug.c
+++ b/debug.c
@@ -359,7 +359,7 @@ int dump_everything(void)
 
        printf("\nMarks:\n");
        mudump();                                                               // Dump marks
-       printf("Total memory allocated=$%X\n", amemtot);
+//     printf("Total memory allocated=$%X\n", amemtot);
 
        return 0;
 }
index 1d77c1c7b441e797b3a022ebf41209e7ea9315bc..6f94402c4c0502564942368273a17cac1b0781eb 100644 (file)
--- a/direct.c
+++ b/direct.c
 #define DEF_KW
 #include "kwtab.h"
 
+
 TOKEN exprbuf[128];                    // Expression buffer 
 SYM * symbolPtr[1000000];      // Symbol pointers table
+static long unused;                    // For supressing 'write' warnings
+
 
 // Directive handler table
 int (*dirtab[])() = {
@@ -134,7 +137,7 @@ int d_print(void)
                        printf("%s", prntstr);
 
                        if (list_fd) 
-                               write(list_fd, prntstr, (LONG)strlen(prntstr));
+                               unused = write(list_fd, prntstr, (LONG)strlen(prntstr));
 
                        tok += 2;
                        break;
@@ -184,7 +187,7 @@ int d_print(void)
                                printf("%s", prntstr);
 
                                if (list_fd) 
-                                       write(list_fd, prntstr, (LONG)strlen(prntstr));
+                                       unused = write(list_fd, prntstr, (LONG)strlen(prntstr));
 
                                formatting = 0;
                                wordlong = 0;
diff --git a/error.c b/error.c
index fa4ceb54a7ee8c64346f70ffaa53660eb2090df3..300a07e9daabcb3851381ea568e0fe5fa91701ba 100644 (file)
--- a/error.c
+++ b/error.c
 #include "token.h"
 #include "listing.h"
 
-int errcnt;                                                                    // Error count
-char * err_fname;                                                      // Name of error message file
+int errcnt;                                            // Error count
+char * err_fname;                              // Name of error message file
 
-static char nl[] = "\n";
+static const char nl[] = "\n";
+static long unused;                            // For supressing 'write' warnings
 
 
 //
@@ -21,20 +22,20 @@ static char nl[] = "\n";
 //
 int at_eol(void)
 {
-   if (*tok != EOL)
-      error("syntax error");
+       if (*tok != EOL)
+               error("syntax error");
 
-   return 0;
+       return 0;
 }
 
 
 //
 // Cannot Create a File
 //
-void cantcreat(char * fn)
+void cantcreat(const char * fn)
 {
-   printf("cannot create: '%s'\n", fn);
-   exit(1);
+       printf("cannot create: '%s'\n", fn);
+       exit(1);
 }
 
 
@@ -85,7 +86,7 @@ int error(const char * s)
        length = strlen(buf);
 
        if (err_flag)
-               write(err_fd, buf, length);
+               unused = write(err_fd, buf, length);
        else
                printf("%s", buf);
 
@@ -96,7 +97,7 @@ int error(const char * s)
 }
 
 
-int errors(char * s, char * s1)
+int errors(const char * s, char * s1)
 {
        char buf[EBUFSIZ];
        char buf1[EBUFSIZ];
@@ -110,7 +111,7 @@ int errors(char * s, char * s1)
        sprintf(buf1, "%s %d: Error: %s%s", curfname, curlineno, buf, nl);
 
        if (err_flag)
-               write(err_fd, buf1, (LONG)strlen(buf1));
+               unused = write(err_fd, buf1, (LONG)strlen(buf1));
        else
                printf("%s", buf1);
 
@@ -121,7 +122,7 @@ int errors(char * s, char * s1)
 }
 
 
-int warn(char * s)
+int warn(const char * s)
 {
        char buf[EBUFSIZ];
 
@@ -133,7 +134,7 @@ int warn(char * s)
        sprintf(buf, "%s %d: Warning: %s%s", curfname, curlineno, s, nl);
 
        if (err_flag)
-               write(err_fd, buf, (LONG)strlen(buf));
+               unused = write(err_fd, buf, (LONG)strlen(buf));
        else
                printf("%s", buf);
 
@@ -143,7 +144,7 @@ int warn(char * s)
 }
 
 
-int warns(char * s, char * s1)
+int warns(const char * s, char * s1)
 {
        char buf[EBUFSIZ];
        char buf1[EBUFSIZ];
@@ -157,7 +158,7 @@ int warns(char * s, char * s1)
        sprintf(buf1, "%s %d: Warning: %s%s", curfname, curlineno, buf, nl);
 
        if (err_flag)
-               write(err_fd, buf1, (LONG)strlen(buf1));
+               unused = write(err_fd, buf1, (LONG)strlen(buf1));
        else
                printf("%s", buf1);
 
@@ -167,7 +168,7 @@ int warns(char * s, char * s1)
 }
 
 
-int warni(char * s, unsigned i)
+int warni(const char * s, unsigned i)
 {
        char buf[EBUFSIZ];
        char buf1[EBUFSIZ];
@@ -181,7 +182,7 @@ int warni(char * s, unsigned i)
        sprintf(buf1, "%s %d: Warning: %s%s", curfname, curlineno, buf, nl);
 
        if (err_flag)
-               write(err_fd, buf1, (LONG)strlen(buf1));
+               unused = write(err_fd, buf1, (LONG)strlen(buf1));
        else
                printf("%s", buf1);
 
@@ -191,7 +192,7 @@ int warni(char * s, unsigned i)
 }
 
 
-int fatal(char * s)
+int fatal(const char * s)
 {
        char buf[EBUFSIZ];
 
@@ -203,7 +204,7 @@ int fatal(char * s)
        sprintf(buf, "%s %d: Fatal: %s%s", curfname, curlineno, s, nl);
 
        if (err_flag)
-               write(err_fd, buf, (LONG)strlen(buf));
+               unused = write(err_fd, buf, (LONG)strlen(buf));
        else
                printf("%s", buf);
 
@@ -222,9 +223,10 @@ int interror(int n)
                ship_ln(buf);
 
        if (err_flag)
-               write(err_fd, buf, (LONG)strlen(buf));
+               unused = write(err_fd, buf, (LONG)strlen(buf));
        else
                printf("%s", buf);
 
        exit(1);
 }
+
diff --git a/error.h b/error.h
index f0e9ed6e714a174dc9d7e8799f4baf44b4dd11d5..3a3551c4846acd68c4927e347c7c3af15f052fbc 100644 (file)
--- a/error.h
+++ b/error.h
@@ -19,13 +19,13 @@ extern char * err_fname;
 
 // Prototypes
 int error(const char *);
-int errors(char *, char *);
-int fatal(char *);
-int warn(char *);
-int warns(char *, char *);
-int warni(char *, unsigned);
+int errors(const char *, char *);
+int fatal(const char *);
+int warn(const char *);
+int warns(const char *, char *);
+int warni(const char *, unsigned);
 int interror(int);
-void cantcreat(char *);
+void cantcreat(const char *);
 void err_setup(void);
 
 #endif // __ERROR_H__
diff --git a/expr.c b/expr.c
index 0335fbd12de4f46173e5efb254b85c5302126ad3..31eb89974fb0eab6b6ab40bc0ef99597ad5a53e2 100644 (file)
--- a/expr.c
+++ b/expr.c
@@ -71,7 +71,7 @@ static VALUE str_value(char * p)
 //
 // Initialize Expression Analyzer
 //
-void init_expr(void)
+void InitExpression(void)
 {
        int i;                                                                  // Iterator
        char * p;                                                               // Token pointer
diff --git a/expr.h b/expr.h
index c8c1e85d7ae823bbc268a668c6865811d74568d9..148157f33af4bc1f708ec52071f879c65323169c 100644 (file)
--- a/expr.h
+++ b/expr.h
@@ -31,7 +31,7 @@
 #define OR           12                        // Bitwise or: |
 
 // Prototypes
-void init_expr(void);
+void InitExpression(void);
 int expr1(void);
 int expr2(void);
 int expr(TOKEN *, VALUE *, WORD *, SYM **);
index 82d2520ba56b3a036cf38f68d4760ce37136222b..f930b79d84100d26b903ada41e80306feec92406 100644 (file)
--- a/listing.c
+++ b/listing.c
 #include "sect.h"
 #include "error.h"
 
-char * list_fname;                                          // Listing filename
-char subttl[TITLESIZ];                                      // Current subtitle
-int listing;                                                // Listing level 
-int pagelen = 61;                                           // Lines on a page
-int nlines;                                                 // #lines on page so far
-LONG lsloc;                                                 // `sloc' at start of line 
+char * list_fname;                                     // Listing filename
+char subttl[TITLESIZ];                         // Current subtitle
+int listing;                                           // Listing level 
+int pagelen = 61;                                      // Lines on a page
+int nlines;                                                    // #lines on page so far
+LONG lsloc;                                                    // `sloc' at start of line 
 
 // Private
-static int lcursect;                                        // `cursect' at start of line
-static int llineno;                                         // `curlineno' at start of line 
-static int pageno;                                          // Current page number 
-static int pagewidth;                                       // #columns on a page
-static int subflag;                                         // 0, don't do .eject on subttl (set 1)
-static char lnimage[IMAGESIZ];                              // Image of output line
-static char title[TITLESIZ];                                // Current title
-static char datestr[20];                                    // Current date dd-mon-yyyy 
-static char timestr[20];                                    // Current time hh:mm:ss [am|pm]
-static char buf[IMAGESIZ];                                  // Buffer for numbers
+static int lcursect;                           // `cursect' at start of line
+static int llineno;                                    // `curlineno' at start of line 
+static int pageno;                                     // Current page number 
+static int pagewidth;                          // #columns on a page
+static int subflag;                                    // 0, don't do .eject on subttl (set 1)
+static char lnimage[IMAGESIZ];         // Image of output line
+static char title[TITLESIZ];           // Current title
+static char datestr[20];                       // Current date dd-mon-yyyy 
+static char timestr[20];                       // Current time hh:mm:ss [am|pm]
+static char buf[IMAGESIZ];                     // Buffer for numbers
+static long unused;                                    // For supressing 'write' warnings
 
 static char * month[16] = { "",    "Jan", "Feb", "Mar",
                            "Apr", "May", "Jun", "Jul",
@@ -212,8 +213,8 @@ void println(const char * ln)
                list_setup();
 
        length = strlen(ln);
-       write(list_fd, ln, length);
-       write(list_fd, "\n", 1L);
+       unused = write(list_fd, ln, length);
+       unused = write(list_fd, "\n", 1L);
 }
 
 
@@ -255,7 +256,7 @@ void ship_ln(const char * ln)
 //
 // Initialize Listing Generator
 //
-void init_list(void)
+void InitListing(void)
 {
        extern VALUE dos_date(), dos_time();
 
index f674ea6d763b2ae5b48a61de6bf25f8880b58952..3a1af65ce1472bfa4581531bd74df3ad5dbc405b 100644 (file)
--- a/listing.h
+++ b/listing.h
@@ -30,7 +30,7 @@ extern int nlines;
 extern LONG lsloc;
 
 // Prototypes
-void init_list(void);
+void InitListing(void);
 void ship_ln(const char *);
 void taglist(char);
 void println(const char *);
diff --git a/mach.c b/mach.c
index 2220d0fd79d30f7a149b8afdb62eb232845c67ea..a108f4440ce21cd68616696bfdd5fe0756e4ba26 100644 (file)
--- a/mach.c
+++ b/mach.c
 #define DEF_KW
 #include "kwtab.h"
 
+
+// Fucntion prototypes 
+int m_unimp(WORD, WORD), m_badmode(WORD, WORD), m_bad6mode(WORD, WORD), m_bad6inst(WORD, WORD);
+int m_self(WORD, WORD);
+int m_abcd(WORD, WORD);
+int m_reg(WORD, WORD);
+int m_imm(WORD, WORD);
+int m_imm8(WORD, WORD);
+int m_shi(WORD, WORD);
+int m_shr(WORD, WORD);
+int m_bitop(WORD, WORD);
+int m_exg(WORD, WORD);
+int m_ea(WORD, WORD);
+int m_br(WORD, WORD);
+int m_dbra(WORD, WORD);
+int m_link(WORD, WORD);
+int m_adda(WORD, WORD);
+int m_addq(WORD, WORD);
+//int m_move(WORD, int);
+int m_move(WORD, WORD);
+int m_moveq(WORD, WORD);
+int m_usp(WORD, WORD);
+int m_movep(WORD, WORD);
+int m_trap(WORD, WORD);
+int m_movem(WORD, WORD);
+int m_clra(WORD, WORD);
+
 // Common error messages
 char range_error[] = "expression out of range";
 char abs_error[] = "illegal absolute expression";
@@ -31,7 +58,8 @@ extern int ea1gen(WORD);
 
 // Include code tables
 MNTAB machtab[] = {
-   { (WORD)-1, (unsigned long)-1L, (unsigned long)-1L, 0x0000, 0, m_badmode }, // 0 
+//   { (WORD)-1, (unsigned long)-1L, (unsigned long)-1L, 0x0000, 0, m_badmode }, // 0 
+   { 0xFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0000, 0, m_badmode }, // 0 
    #include "68ktab.h"
    {  0,  0L,  0L, 0x0000, 0, m_unimp   }                   // Last entry
 };
@@ -83,19 +111,20 @@ WORD am_6[] = {
 
 
 // Error messages
-int m_unimp(void)
+int m_unimp(WORD unused1, WORD unused2)
 {
        return (int)error("unimplemented mnemonic");
 }
 
 
-int m_badmode(void)
+//int m_badmode(void)
+int m_badmode(WORD unused1, WORD unused2)
 {
        return (int)error("inappropriate addressing mode");
 }
 
 
-int m_self(WORD inst)
+int m_self(WORD inst, WORD usused)
 {
        D_word(inst);
        return 0;
@@ -121,43 +150,47 @@ int m_self(WORD inst)
 //
 int m_ea(WORD inst, WORD siz)
 {
-       WORD flg;
-
-       flg = inst;                                              // Save flag bits 
-       inst &= ~0x3f;                                           // Clobber flag bits in instr 
+       WORD flg = inst;                                        // Save flag bits 
+       inst &= ~0x3F;                                          // Clobber flag bits in instr 
 
-       if (flg & 4)                                              // Install "standard" instr size bits 
+       // Install "standard" instr size bits 
+       if (flg & 4)
                inst |= siz_6[siz];
 
        if (flg & 16)
-       {                                           // OR-in register number 
+       {
+               // OR-in register number 
                if (flg & 8)
                {
-                       inst |= reg_9[a1reg];                              // ea1reg in bits 9..11 
+                       inst |= reg_9[a1reg];           // ea1reg in bits 9..11 
                }
                else
                {
-                       inst |= reg_9[a0reg];                              // ea0reg in bits 9..11 
+                       inst |= reg_9[a0reg];           // ea0reg in bits 9..11 
                }
        }
 
        if (flg & 1)
-       {                                            // Use am1 
-               inst |= am1 | a1reg;                                  // Get ea1 into instr 
-               D_word(inst);                                         // Deposit instr 
+       {
+               // Use am1 
+               inst |= am1 | a1reg;                    // Get ea1 into instr 
+               D_word(inst);                                   // Deposit instr 
 
-               if (flg & 2)                                           // Generate ea0 if requested 
+               // Generate ea0 if requested 
+               if (flg & 2)
                        ea0gen(siz);
 
-               ea1gen(siz);                                          // Generate ea1 
+               ea1gen(siz);                                    // Generate ea1 
        }
        else
-       {                                                 // Use am0 
-               inst |= am0 | a0reg;                                     // Get ea0 into instr 
-               D_word(inst);                                         // Deposit instr 
-               ea0gen(siz);                                          // Generate ea0 
+       {
+               // Use am0 
+               inst |= am0 | a0reg;                    // Get ea0 into instr 
+               D_word(inst);                                   // Deposit instr 
+               ea0gen(siz);                                    // Generate ea0 
 
-               if (flg & 2)                                           // Generate ea1 if requested 
+               // Generate ea1 if requested 
+               if (flg & 2)
                        ea1gen(siz);
        }
 
@@ -172,8 +205,9 @@ int m_ea(WORD inst, WORD siz)
 int m_abcd(WORD inst, WORD siz)
 {
        if (inst & 1)
-       {                                           // Install size bits 
-               --inst;
+       {
+               // Install size bits 
+               inst--;
                inst |= siz_6[siz];
        }
 
@@ -191,7 +225,7 @@ int m_adda(WORD inst, WORD siz)
 {
        inst |= am0 | a0reg | lwsiz_8[siz] | reg_9[a1reg];
        D_word(inst);
-       ea0gen(siz);                                             // Gen EA 
+       ea0gen(siz);    // Generate EA 
 
        return 0;
 }
@@ -203,14 +237,16 @@ int m_adda(WORD inst, WORD siz)
 // 
 int m_reg(WORD inst, WORD siz)
 {
-       if (inst & 1)                                             // Install size bits 
+       if (inst & 1)
+               // Install size bits 
                inst |= siz_6[siz];
 
-       if (inst & 2)                                             // Install other register (9..11) 
+       if (inst & 2)
+               // Install other register (9..11) 
                inst |= reg_9[a1reg];
 
-       inst &= ~7;                                              // Clear off crufty bits 
-       inst |= a0reg;                                           // Install first register 
+       inst &= ~7;                     // Clear off crufty bits 
+       inst |= a0reg;          // Install first register 
        D_word(inst);
 
        return 0;
@@ -286,11 +322,11 @@ int m_bitop(WORD inst, WORD siz)
 {
        // Enforce instruction sizes
        if (am1 == DREG)
-       {                                        // X,Dn must be .n or .l 
-               if (siz & (SIZB|SIZW))
+       {                               // X,Dn must be .n or .l 
+               if (siz & (SIZB | SIZW))
                        return error(siz_error);
        }
-       else if (siz & (SIZW|SIZL))                                 // X,ea must be .n or .b 
+       else if (siz & (SIZW | SIZL))   // X,ea must be .n or .b 
                return error(siz_error);
 
        // Construct instr and EAs
@@ -299,7 +335,7 @@ int m_bitop(WORD inst, WORD siz)
        if (am0 == IMMED)
        {
                D_word(inst);
-               ea0gen(SIZB);                                         // Immediate bit number 
+               ea0gen(SIZB);                           // Immediate bit number 
        }
        else
        {
@@ -307,7 +343,8 @@ int m_bitop(WORD inst, WORD siz)
                D_word(inst);
        }
 
-       ea1gen(SIZB);                                            // ea to bit-munch 
+       // ea to bit-munch 
+       ea1gen(SIZB);
 
        return 0;
 }
@@ -335,7 +372,7 @@ int m_dbra(WORD inst, WORD siz)
        }
        else
        {
-               fixup(FU_WORD|FU_PCREL|FU_ISBRA, sloc, a1expr);
+               fixup(FU_WORD | FU_PCREL | FU_ISBRA, sloc, a1expr);
                D_word(0);
        }
 
@@ -395,8 +432,12 @@ int m_link(WORD inst, WORD siz)
 // 
 // Optimize MOVE.L #<smalldata>,D0 to a MOVEQ
 //
-int m_move(WORD inst, int siz)
+//int m_move(WORD inst, int siz)
+int m_move(WORD inst, WORD size)
 {
+       // Cast the passed in value to an int
+       int siz = (int)size;
+
        // Try to optimize to MOVEQ
        if (siz == SIZL && am0 == IMMED && am1 == DREG
                && (a0exattr & (TDB|DEFINED)) == DEFINED && a0exval + 0x80 < 0x100)
@@ -428,9 +469,9 @@ int m_usp(WORD inst, WORD siz)
        siz = siz;
 
        if (am0 == AM_USP)
-               inst |= a1reg;                         // USP,An 
+               inst |= a1reg;          // USP, An 
        else
-               inst |= a0reg;                                      // An,USP 
+               inst |= a0reg;          // An, USP 
 
        D_word(inst);
 
@@ -454,7 +495,7 @@ int m_moveq(WORD inst, WORD siz)
        else if (a0exval + 0x100 >= 0x200)
                return error(range_error);
 
-       inst |= reg_9[a1reg] | (a0exval & 0xff);
+       inst |= reg_9[a1reg] | (a0exval & 0xFF);
        D_word(inst);
 
        return 0;
@@ -462,12 +503,10 @@ int m_moveq(WORD inst, WORD siz)
 
 
 //
-// movep Dn,disp(An) -- movep disp(An),Dn
+// movep Dn, disp(An) -- movep disp(An), Dn
 //
 int m_movep(WORD inst, WORD siz)
 {
-       //WORD k;
-
        if (siz == SIZL)
                inst |= 0x0040;
 
@@ -477,9 +516,7 @@ int m_movep(WORD inst, WORD siz)
                D_word(inst);
 
                if (am1 == AIND)
-               {
                        D_word(0);
-               }
                else 
                        ea1gen(siz);
        }
@@ -489,9 +526,7 @@ int m_movep(WORD inst, WORD siz)
                D_word(inst);
 
                if (am0 == AIND)
-               {
                        D_word(0);
-               }
                else 
                        ea0gen(siz);
        }
@@ -518,13 +553,15 @@ int m_br(WORD inst, WORD siz)
                if (siz == SIZN)
                {
                        if (v != 0 && v + 0x80 < 0x100)
-                       {                   // Fits in .B 
-                               inst |= v & 0xff;
+                       {
+                               // Fits in .B 
+                               inst |= v & 0xFF;
                                D_word(inst);
                                return 0;
                        }
                        else
-                       {                                           // Fits in .W 
+                       {
+                               // Fits in .W 
                                if (v + 0x8000 > 0x10000)
                                        return error(range_error);
 
@@ -539,7 +576,7 @@ int m_br(WORD inst, WORD siz)
                        if (v + 0x80 >= 0x100)
                                return error(range_error);
 
-                       inst |= v & 0xff;
+                       inst |= v & 0xFF;
                        D_word(inst);
                }
                else
@@ -557,15 +594,17 @@ int m_br(WORD inst, WORD siz)
                siz = SIZW;
 
        if (siz == SIZB)
-       {                                        // .B 
-               fixup(FU_BBRA|FU_PCREL|FU_SEXT, sloc, a0expr);
+       {
+               // .B 
+               fixup(FU_BBRA | FU_PCREL | FU_SEXT, sloc, a0expr);
                D_word(inst);
                return 0;
        }
        else
-       {                                                 // .W 
+       {
+               // .W 
                D_word(inst);
-               fixup(FU_WORD|FU_PCREL|FU_LBRA|FU_ISBRA, sloc, a0expr);
+               fixup(FU_WORD | FU_PCREL | FU_LBRA | FU_ISBRA, sloc, a0expr);
                D_word(0);
        }
 
@@ -642,8 +681,9 @@ int m_movem(WORD inst, WORD siz)
                inst |= 0x0040;
 
        if (*tok == '#')
-       {                                        // Handle #<expr>,ea 
-               ++tok;
+       {
+               // Handle #<expr>, ea 
+               tok++;
 
                if (abs_expr(&eval) != OK)
                        return 0;
@@ -656,7 +696,8 @@ int m_movem(WORD inst, WORD siz)
        }
 
        if (*tok >= KW_D0 && *tok <= KW_A7)
-       {                     // <rlist>,ea 
+       {
+               // <rlist>, ea 
                if (reglist(&rmask) < 0)
                        return 0;
 
@@ -669,7 +710,7 @@ immed1:
 
                inst |= am0 | a0reg;
 
-               if (!(amsktab[am0] & (C_ALTCTRL|M_APREDEC)))
+               if (!(amsktab[am0] & (C_ALTCTRL | M_APREDEC)))
                        return error("invalid addressing mode");
 
                // If APREDEC, reverse register mask
@@ -683,7 +724,8 @@ immed1:
                }
        }
        else
-       {                                                 // ea,<rlist> 
+       {
+               // ea, <rlist> 
                if (amode(0) < 0)
                        return 0;
 
@@ -696,8 +738,9 @@ immed1:
                        return error("missing register list");
 
                if (*tok == '#')
-               {                                     // ea,#<expr> 
-                       ++tok;
+               {
+                       // ea, #<expr> 
+                       tok++;
 
                        if (abs_expr(&eval) != OK)
                                return 0;
@@ -710,7 +753,7 @@ immed1:
                else if (reglist(&rmask) < 0)
                        return 0;
 
-               if (!(amsktab[am0] & (C_CTRL|M_APOSTINC)))
+               if (!(amsktab[am0] & (C_CTRL | M_APOSTINC)))
                        return error("invalid addressing mode");
        }
 
@@ -732,3 +775,4 @@ int m_clra(WORD inst, WORD siz)
 
        return 0;
 }
+
diff --git a/mach.h b/mach.h
index 224095039ffaf4d8861f5caf72ecf420a2fc9205..9add0a351ef7c0504eec12e5100b48e754a7dc72 100644 (file)
--- a/mach.h
+++ b/mach.h
@@ -20,29 +20,4 @@ extern char range_error[];
 extern char abs_error[];
 extern MNTAB machtab[];
 
-// Prototypes 
-int m_unimp(), m_badmode(), m_bad6mode(), m_bad6inst();
-int m_self(WORD);
-int m_abcd(WORD, WORD);
-int m_reg(WORD, WORD);
-int m_imm(WORD, WORD);
-int m_imm8(WORD, WORD);
-int m_shi(WORD, WORD);
-int m_shr(WORD, WORD);
-int m_bitop(WORD, WORD);
-int m_exg(WORD, WORD);
-int m_ea(WORD, WORD);
-int m_br(WORD, WORD);
-int m_dbra(WORD, WORD);
-int m_link(WORD, WORD);
-int m_adda(WORD, WORD);
-int m_addq(WORD, WORD);
-int m_move(WORD, int);
-int m_moveq(WORD, WORD);
-int m_usp(WORD, WORD);
-int m_movep(WORD, WORD);
-int m_trap(WORD, WORD);
-int m_movem(WORD, WORD);
-int m_clra(WORD, WORD);
-
 #endif // __MACH_H__
diff --git a/macro.c b/macro.c
index 5c590e405e51086f762e0c5c45d397b8409004be..6e9fd864af4eb370c0ba8f03b00ee4b774d7becf 100644 (file)
--- a/macro.c
+++ b/macro.c
@@ -333,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");
@@ -350,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
                        }
                }
 
diff --git a/mark.c b/mark.c
index eacebf50a07c8318211285b78ba113df25082221..c33f4508559cd0eff331e792546d7f23949ecb22 100644 (file)
--- a/mark.c
+++ b/mark.c
@@ -26,7 +26,7 @@ uint16_t curfrom;                     // Current "from" section
 //
 // Initialize Marker
 //
-void init_mark(void)
+void InitMark(void)
 {
        firstmch = curmch = NULL;
        mcalloc = mcused = 0;
diff --git a/mark.h b/mark.h
index d46639aae8ed6a5ca2524f1bf45cfb0a73f4502d..b117bbac88796ca8c877191db3b9e4d4243aa2e1 100644 (file)
--- a/mark.h
+++ b/mark.h
@@ -19,7 +19,7 @@
 extern MCHUNK * firstmch;
 
 // Prototypes
-void init_mark(void);
+void InitMark(void);
 void stopmark(void);
 //int rmark(int, LONG, int, int, SYM *);
 int rmark(uint16_t, uint32_t, uint16_t, uint16_t, SYM *);
index 4f9309af0299f5a4f4417d8ec0164d082b244498..4e9613f5a258a2a02f3c079ef7a8c23cea9809cf 100644 (file)
--- a/object.c
+++ b/object.c
@@ -80,14 +80,15 @@ char * constr_bsdsymtab(char * buf, SYM * sym, int globflag)
 //
 int object(WORD fd)
 {
-       LONG t;                                                                 // Scratch long
-       LONG tds;                                                               // TEXT & DATA segment size
-       int i;                                                                  // Temporary int
-       CHUNK * cp;                                                             // Chunk (for gather)
-       char * buf;                                                             // Scratch area
-       char * p;                                                               // Temporary ptr
-       LONG ssize;                                                             // Size of symbols
-       LONG trsize, drsize;                                    // Size of relocations
+       LONG t;                                 // Scratch long
+       LONG tds;                               // TEXT & DATA segment size
+       int i;                                  // Temporary int
+       CHUNK * cp;                             // Chunk (for gather)
+       char * buf;                             // Scratch area
+       char * p;                               // Temporary ptr
+       LONG ssize;                             // Size of symbols
+       LONG trsize, drsize;    // Size of relocations
+       long unused;                    // For supressing 'write' warnings
 
        // Write requested object file...
        switch (obj_format)
@@ -117,19 +118,14 @@ int object(WORD fd)
 
                // Build object file header
                chptr = buf;                                                            // Base of header
-               t = 0x00000107;
-               D_long(t);                                                                      // Magic number
-               t = sect[TEXT].sloc;                                            // TEXT size 
-               D_long(t);
-               t = sect[DATA].sloc;                                            // DATA size 
-               D_long(t);
-               t = sect[BSS].sloc;                                                     // BSS size 
-               D_long(t);
-               t = 0x00000000;
-               D_long(t);                                                                      // Symbol size
-               D_long(t);                                                                      // First entry (0L)
-               D_long(t);                                                                      // TEXT relocation size
-               D_long(t);                                                                      // BSD relocation size
+               D_long(0x00000107);                                                     // Magic number
+               D_long(sect[TEXT].sloc);                                        // TEXT size 
+               D_long(sect[DATA].sloc);                                        // DATA size 
+               D_long(sect[BSS].sloc);                                         // BSS size 
+               D_long(0x00000000);                                                     // Symbol size
+               D_long(0x00000000);                                                     // First entry (0L)
+               D_long(0x00000000);                                                     // TEXT relocation size
+               D_long(0x00000000);                                                     // BSD relocation size
 
                // Construct TEXT and DATA segments (without relocation changes)
                p = buf + BSDHDRSIZE;
@@ -170,7 +166,7 @@ int object(WORD fd)
                D_long(strindx);                                                        // Write string table size
 
                // Write the BSD object file from the object image buffer
-               write(fd, buf, BSDHDRSIZE + tds + trsize + drsize + symsize + strindx + 4);
+               unused = write(fd, buf, BSDHDRSIZE + tds + trsize + drsize + symsize + strindx + 4);
 
                if (buf)
                        free(buf);                                                              // Free allocated memory
index 61c9029ab095e186e0af0cc0bda75680bef7e66c..743c9b96e13b61da115d038dc8f529578849eee7 100644 (file)
--- a/procln.c
+++ b/procln.c
@@ -39,11 +39,11 @@ VALUE pcloc;                                        // Value of "PC" at beginning of line
 IFENT * ifent;                                 // Current ifent
 SYM * lab_sym;                                 // Label on line (or NULL)
 
-char extra_stuff[] = "extra (unexpected) text found after addressing mode";
-char * comma_error = "missing comma";
-char * syntax_error = "syntax error";
-char * locgl_error = "cannot GLOBL local symbol";
-char * lab_ignored = "label ignored";
+const char extra_stuff[] = "extra (unexpected) text found after addressing mode";
+const char comma_error[] = "missing comma";
+const char syntax_error[] = "syntax error";
+const char locgl_error[] = "cannot GLOBL local symbol";
+const char lab_ignored[] = "label ignored";
 
 // Table to convert an addressing-mode number to a bitmask.
 LONG amsktab[0112] = {
@@ -92,7 +92,7 @@ LONG amsktab[0112] = {
 //
 // Initialize Line Processor
 //
-void init_procln(void)
+void InitLineProcessor(void)
 {
        disabled = 0;
        ifent = &ifent0;
@@ -127,13 +127,12 @@ void Assemble(void)
        WORD rmask;                                     // Register list, for REG
        int registerbank;                       // RISC register bank
        int riscreg;                            // RISC register
-
        listflag = 0;                           // Initialise listing flag
 
 loop:                                                  // Line processing loop label
 
        // Get another line of tokens
-       if (tokln() == TKEOF)
+       if (TokenizeLine() == TKEOF)
        {
 if (verb_flag) printf("Assemble: Found TKEOF flag...\n");
                if (list_flag && listflag)                      // Flush last line of source
@@ -426,12 +425,20 @@ checking to see if it's already been equated, issue a warning.
                                sy->sattre  = EQUATEDREG | RISCSYM;     // Mark as equated register
                                riscreg = (*tok - KW_R0);
 //is there any reason to do this, since we're putting this in svalue?
-                               sy->sattre |= (riscreg << 8);           // Store register number
-
+//i'm thinking, no. Let's test that out! :-D
+//                             sy->sattre |= (riscreg << 8);           // Store register number
+//everything seems to build fine without it... We'll leave it here Just In Case(tm)
+
+#define DEBODGE_REGBANK
+#ifdef DEBODGE_REGBANK
+                               // Default is current state of "regbank"
+                               registerbank = regbank;
+#else
                                // Default is no register bank specified
                                registerbank = BANK_N;
+#endif
 
-                               // Check for ",<bank #>" notation
+                               // Check for ",<bank #>" override notation
                                if ((tok[1] == ',') && (tok[2] == CONST))
                                {
                                        // Advance token pointer to the constant
@@ -444,6 +451,9 @@ checking to see if it's already been equated, issue a warning.
                                                registerbank = BANK_1;
                                }
 
+#ifdef DEBODGE_REGBANK
+                               sy->sattre |= registerbank;     // Store register bank
+#else
 // What needs to happen here is to prime registerbank with regbank, then use
 // registerbank down below for the bank marking.
 #warning "!!! regbank <-> registerbank confusion here !!!"
@@ -452,6 +462,7 @@ checking to see if it's already been equated, issue a warning.
 // not in what ends up in symbol->svalue?
 // ".regbankN" is not an original Madmac directive, so it's suspect
                                sy->sattre |= regbank;          // Store register bank
+#endif
                                eattr = ABS | DEFINED | GLOBAL;
 // & what does this $80000080 constant mean???
 //                             eval = 0x80000080 + (riscreg) + (registerbank << 8);
@@ -526,7 +537,8 @@ checking to see if it's already been equated, issue a warning.
                                sy->stype = sy2->stype;
                                sy->sattr = sy2->sattr;
                                sy->sattre = sy2->sattre;
-                               sy->svalue = (sy2->svalue & 0xFFFFF0FF);
+//ICK                          sy->svalue = (sy2->svalue & 0xFFFFF0FF);
+                               sy->svalue = sy2->svalue;
                                goto loop;
                        }
                        else if (expr(exprbuf, &eval, &eattr, &esym) != OK)
@@ -556,15 +568,7 @@ checking to see if it's already been equated, issue a warning.
        {
 do_label:
                // Check for dot in front of label; means this is a local label if present
-#if 0
-               j = 0;
-
-               if (*label == '.')
-                       j = curenv;
-#else
                j = (*label == '.' ? curenv : 0);
-#endif
-
                sy = lookup(label, LABEL, j);
 
                if (sy == NULL)
index 7409b18034add656e825540a5e3eda4fd0097297..518e1455a99457ba4b976067b93b2390265c0a1e 100644 (file)
--- a/procln.h
+++ b/procln.h
 
 // Globals, externals etc
 extern IFENT * ifent;
-extern char * comma_error;
-extern char * locgl_error;
-extern char * syntax_error;
+extern const char comma_error[];
+extern const char locgl_error[];
+extern const char syntax_error[];
+extern const char extra_stuff[];
 extern int just_bss;
 extern VALUE pcloc;
-extern IFENT * ifent;
+//extern IFENT * ifent;
 extern SYM * lab_sym;
-extern char extra_stuff[];
 extern LONG amsktab[];
 
 // Prototypes
-void init_procln(void);
+void InitLineProcessor(void);
 void Assemble(void);
 int eject(void);
 int d_if(void);
diff --git a/rmac.c b/rmac.c
index 6dd9475d7db3b7a7aa848820977d45f2e78bdf75..ffa3165553e2e7df78f0ba4f165ccb10e69b5545 100644 (file)
--- a/rmac.c
+++ b/rmac.c
@@ -44,303 +44,6 @@ char * cmdlnexec;                                   // Executable name, pointer to ARGV[0]
 char * searchpath;                                     // Search path for include files 
 char defname[] = "noname.o";           // Default output filename
 
-// Under Windows and UNIX malloc() is an expensive call, so for small amounts
-// of memory we allocate from a previously allocated buffer.
-
-#define A_AMOUNT        4096                                // Amount to malloc() at a time
-#define A_THRESH        64                                  // Use malloc() for amounts >= A_THRESH
-
-static LONG a_amount;                                       // Amount left at a_ptr 
-static char * a_ptr;                                        // Next free chunk
-LONG amemtot;                                               // amem() total of requests
-
-// Qsort; The THRESHold below is the insertion sort threshold, and has been adjusted
-// for records of size 48 bytes.The MTHREShold is where we stop finding a better median.
-#define THRESH          4                                   // Threshold for insertion
-#define MTHRESH         6                                   // Threshold for median
-
-static int (*qcmp)();                                       // The comparison routine
-static int qsz;                                             // Size of each record
-static int thresh;                                          // THRESHold in chars 
-static int mthresh;                                         // MTHRESHold in chars
-
-// This is unused BOLLOCKS
-#if 0
-//
-// qst: Do a quicksort. First, find the median element, and put that one in the
-// first place as the discriminator. (This "median" is just the median of the
-// first, last and middle elements). (Using this median instead of the first
-// element is a big win). Then, the usual partitioning/swapping, followed by
-// moving the discriminator into the right place. Then, figure out the sizes of
-// the two partions, do the smaller one recursively and the larger one via a
-// repeat of this code.  Stopping when there are less than THRESH elements in a
-// partition and cleaning up with an insertion sort (in our caller) is a huge
-// win. All data swaps are done in-line, which is space-losing but time-saving.
-// (And there are only three places where this is done).
-//
-static int qst(char * base, char * max)
-{
-   char c, * i, * j, * jj;
-   int ii;
-   char * mid, * tmp;
-   long lo, hi;
-
-   /*
-        * At the top here, lo is the number of characters of elements in the
-        * current partition. (Which should be max - base).
-        * Find the median of the first, last, and middle element and make
-        * that the middle element. Set j to largest of first and middle.
-        * If max is larger than that guy, then it's that guy, else compare
-        * max with loser of first and take larger. Things are set up to
-        * prefer the middle, then the first in case of ties.
-        */
-       lo = max - base;                /* number of elements as chars */
-
-       do
-       {
-               mid = i = base + qsz * ((lo / qsz) >> 1);
-
-               if (lo >= mthresh)
-               {
-                       j = (qcmp((jj = base), i) > 0 ? jj : i);
-
-                       if (qcmp(j, (tmp = max - qsz)) > 0)
-                       {
-                               /* switch to first loser */
-                               j = (j == jj ? i : jj);
-
-                               if (qcmp(j, tmp) < 0)
-                                       j = tmp;
-                       }
-
-                       if (j != i)
-                       {
-                               ii = qsz;
-
-                               do
-                               {
-                                       c = *i;
-                                       *i++ = *j;
-                                       *j++ = c;
-                               }
-                               while (--ii);
-                       }
-               }
-
-               /*
-                * Semi-standard quicksort partitioning/swapping
-                */
-               for(i=base, j=max-qsz; ;)
-               {
-                       while (i < mid && qcmp(i, mid) <= 0)
-                               i += qsz;
-
-                       while (j > mid)
-                       {
-                               if (qcmp(mid, j) <= 0)
-                               {
-                                       j -= qsz;
-                                       continue;
-                               }
-
-                               tmp = i + qsz;  /* value of i after swap */
-
-                               if (i == mid)
-                               {
-                                       /* j <-> mid, new mid is j */
-                                       mid = jj = j;
-                               }
-                               else
-                               {
-                                       /* i <-> j */
-                                       jj = j;
-                                       j -= qsz;
-                               }
-
-                               goto swap;
-                       }
-
-                       if (i == mid)
-                       {
-                               break;
-                       }
-                       else
-                       {
-                               /* i <-> mid, new mid is i */
-                               jj = mid;
-                               tmp = mid = i;  /* value of i after swap */
-                               j -= qsz;
-                       }
-swap:
-                       ii = qsz;
-
-                       do
-                       {
-                               c = *i;
-                               *i++ = *jj;
-                               *jj++ = c;
-                       }
-                       while (--ii);
-
-                       i = tmp;
-               }
-
-               /*
-                * Look at sizes of the two partitions, do the smaller
-                * one first by recursion, then do the larger one by
-                * making sure lo is its size, base and max are update
-                * correctly, and branching back.  But only repeat
-                * (recursively or by branching) if the partition is
-                * of at least size THRESH.
-                */
-               i = (j = mid) + qsz;
-
-               if ((lo = j - base) <= (hi = max - i))
-               {
-                       if (lo >= thresh)
-                               qst(base, j);
-
-                       base = i;
-                       lo = hi;
-               }
-               else
-               {
-                       if (hi >= thresh)
-                               qst(i, max);
-
-                       max = j;
-               }
-       }
-       while (lo >= thresh);
-
-       return 0;
-}
-
-
-/*
- * qsort:
- * First, set up some global parameters for qst to share.  Then, quicksort
- * with qst(), and then a cleanup insertion sort ourselves.  Sound simple?
- * It's not...
- */
-int rmac_qsort(char * base, int n, int size, int (*compar)())
-{
-       register char c, * i, * j, * lo, * hi;
-       char * min, * max;
-
-       if (n <= 1)
-               return 0;
-
-       qsz = size;
-       qcmp = compar;
-       thresh = qsz * THRESH;
-       mthresh = qsz * MTHRESH;
-       max = base + n * qsz;
-
-       if (n >= THRESH)
-       {
-               qst(base, max);
-               hi = base + thresh;
-       }
-       else
-       {
-               hi = max;
-       }
-
-       /*
-        * First put smallest element, which must be in the first THRESH, in
-        * the first position as a sentinel.  This is done just by searching
-        * the first THRESH elements (or the first n if n < THRESH), finding
-        * the min, and swapping it into the first position.
-        */
-       for(j=lo=base; (lo+=qsz)<hi;)
-       {
-               if (qcmp(j, lo) > 0)
-                       j = lo;
-       }
-
-       if (j != base)
-       {
-               /* swap j into place */
-               for(i=base, hi=base+qsz; i<hi;)
-               {
-                       c = *j;
-                       *j++ = *i;
-                       *i++ = c;
-               }
-       }
-
-       /*
-        * With our sentinel in place, we now run the following hyper-fast
-        * insertion sort.  For each remaining element, min, from [1] to [n-1],
-        * set hi to the index of the element AFTER which this one goes.
-        * Then, do the standard insertion sort shift on a character at a time
-        * basis for each element in the frob.
-        */
-       for(min=base; (hi=min+=qsz)<max;)
-       {
-               while (qcmp(hi -= qsz, min) > 0)
-                       /* void */;
-
-               if ((hi += qsz) != min)
-               {
-                       for(lo=min+qsz; --lo>=min;)
-                       {
-                               c = *lo;
-
-                               for(i=j=lo; (j-=qsz)>=hi; i=j)
-                                       *i = *j;
-
-                               *i = c;
-                       }
-               }
-       }
-
-       return 0;
-}
-#endif
-
-#if 0
-//
-// Allocate memory; Panic and Quit if we Run Out
-//
-char * amem(LONG amount)
-{
-       char * p;
-
-//     if (amount & 1)                                                         // Keep word alignment
-//             amount++;
-       amount = (amount + 1) & ~(0x01);                        // Keep word alignment
-
-       // Honor *small* request (< 64 bytes)
-       if (amount < A_THRESH)
-       {
-               if (a_amount < amount)
-               {
-                       a_ptr = amem(A_AMOUNT);                         // Allocate 4K bytes
-                       a_amount = A_AMOUNT;
-               }
-
-               p = a_ptr;
-               a_ptr += amount;
-               a_amount -= amount;
-       }
-       else
-       {
-               amemtot += amount;                                              // Bump total alloc
-               p = (char *)malloc(amount);                             // Get memory from malloc
-
-               if (p == NULL)
-                       fatal("Memory exhausted!");
-
-               memset(p, 0, amount);
-       }
-
-       return p;
-}
-#endif
-
 
 //
 // Copy stuff around, return pointer to dest+count+1 (doesn't handle overlap)
@@ -489,29 +192,29 @@ int nthpath(char * env_var, int itemno, char * buf)
 //
 void display_help(void)
 {
-       printf("Usage:\n");
-       printf("    %s [options] srcfile\n", cmdlnexec);
-       printf("\n");
-       printf("Options:\n");
-       printf("   -? or -h              display usage information\n");
-       printf("   -dsymbol[=value]      define symbol\n");
-       printf("   -e[errorfile]         send error messages to file, not stdout\n");
-       printf("   -f[format]            output object file format\n");
-       printf("                         b: BSD (use this for Jaguar)\n");
-       printf("   -i[path]              directory to search for include files\n");
-       printf("   -l[filename]          create an output listing file\n");
-       printf("   -o file               output file name\n");
-       printf("   -r[size]              pad segments to boundary size specified\n");
-       printf("                         w: word (2 bytes, default alignment)\n");
-       printf("                         l: long (4 bytes)\n");
-       printf("                         p: phrase (8 bytes)\n");
-       printf("                         d: double phrase (16 bytes)\n");
-       printf("                         q: quad phrase (32 bytes)\n");
-       printf("   -s                    warn about possible short branches\n");
-       printf("   -u                    force referenced and undefined symbols global\n");
-       printf("   -v                    set verbose mode\n");
-       printf("   -y[pagelen]           set page line length (default: 61)\n");
-       printf("\n");
+       printf("Usage:\n"
+               "    %s [options] srcfile\n"
+               "\n"
+               "Options:\n"
+               "  -? or -h          Display usage information\n"
+               "  -dsymbol[=value]  Define symbol\n"
+               "  -e[errorfile]     Send error messages to file, not stdout\n"
+               "  -f[format]        Output object file format\n"
+               "                    b: BSD (use this for Jaguar)\n"
+               "  -i[path]          Directory to search for include files\n"
+               "  -l[filename]      Create an output listing file\n"
+               "  -o file           Output file name\n"
+               "  -r[size]          Pad segments to boundary size specified\n"
+               "                    w: word (2 bytes, default alignment)\n"
+               "                    l: long (4 bytes)\n"
+               "                    p: phrase (8 bytes)\n"
+               "                    d: double phrase (16 bytes)\n"
+               "                    q: quad phrase (32 bytes)\n"
+               "  -s                Warn about possible short branches\n"
+               "  -u                Force referenced and undefined symbols global\n"
+               "  -v                Set verbose mode\n"
+               "  -y[pagelen]       Set page line length (default: 61)\n"
+               "\n", cmdlnexec);
 }
 
 
@@ -520,9 +223,9 @@ void display_help(void)
 //
 void display_version(void)
 {
-       printf("\nReboot's Macro Assembler for Atari Jaguar\n"); 
-       printf("Copyright (C) 199x Landon Dyer, 2011 Reboot\n"); 
-       printf("V%01i.%01i.%01i %s (%s)\n\n", MAJOR, MINOR, PATCH, __DATE__, PLATFORM);
+       printf("\nReboot's Macro Assembler for Atari Jaguar\n"
+               "Copyright (C) 199x Landon Dyer, 2011 Reboot\n"
+               "V%01i.%01i.%01i %s (%s)\n\n", MAJOR, MINOR, PATCH, __DATE__, PLATFORM);
 }
 
 
@@ -560,18 +263,17 @@ int process(int argc, char ** argv)
        regbank = BANK_N;                               // No RISC register bank specified
        orgactive = 0;                                  // Not in RISC org section
        orgwarning = 0;                                 // No ORG warning issued
-       a_amount = 0;
        segpadsize = 2;                                 // Initialise segment padding size
 
        // Initialise modules
        InitSymbolTable();                              // Symbol table
-       init_token();                                   // Tokenizer
-       init_procln();                                  // Line processor
-       init_expr();                                    // Expression analyzer
-       init_sect();                                    // Section manager / code generator
-       init_mark();                                    // Mark tape-recorder
+       InitTokenizer();                                // Tokenizer
+       InitLineProcessor();                    // Line processor
+       InitExpression();                               // Expression analyzer
+       InitSection();                                  // Section manager / code generator
+       InitMark();                                             // Mark tape-recorder
        InitMacro();                                    // Macro processor
-       init_list();                                    // Listing generator
+       InitListing();                                  // Listing generator
 
        // Process command line arguments and assemble source files
        for(argno=0; argno<argc; ++argno)
@@ -594,7 +296,7 @@ int process(int argc, char ** argv)
                                if (argv[argno][2] == EOS)
                                {
                                        printf("-d: empty symbol\n");
-                                       ++errcnt;
+                                       errcnt++;
                                        return errcnt;
                                }
 
@@ -607,12 +309,14 @@ int process(int argc, char ** argv)
                                }
 
                                sy->sattr = DEFINED | EQUATED | ABS;
-
+#if 0
                                if (*s)
                                        sy->svalue = (VALUE)atoi(s);
                                else
                                        sy->svalue = 0;
-
+#else
+                               sy->svalue = (*s ? (VALUE)atoi(s) : 0);
+#endif
                                break;
                        case 'e':                                       // Redirect error message output
                        case 'E':
diff --git a/rmac.h b/rmac.h
index 1c777747731a78ffa878ef36ddde98e5d9d9502a..27bfe69c0f49a3acb1972925bbad7216e534011e 100644 (file)
--- a/rmac.h
+++ b/rmac.h
@@ -188,12 +188,10 @@ extern LONG amemtot;
 void init_sym(void);
 SYM * newsym(char *, int, int);
 char * fext(char *, char *, int);
-void cantcreat(char *);
 int kmatch(char *, int *, int *, int *, int *);
 void autoeven(int);
 int nthpath(char *, int, char *);
 void clear(char *, LONG);
 char * copy(char *, char *, LONG);
-//int rmac_qsort(char *, int, int, int (*)());
 
 #endif // __RMAC_H__
diff --git a/sect.c b/sect.c
index f9c8a588531a4d655b2981189b845ad859294b51..fe630b15d3a2f8aaf1b4f8a36ac0d33f34b65f78 100644 (file)
--- a/sect.c
+++ b/sect.c
 #include "token.h"
 
 
+// Function prototypes
+void mksect(int, WORD);
+void switchsect(int);
+
 // Section descriptors
 SECT sect[NSECTS];                             // All sections... 
 int cursect;                                   // Current section number
@@ -38,10 +42,6 @@ LONG fchalloc;                                       // # bytes alloc'd to fixup chunk
 LONG fchsize;                                  // # bytes used in fixup chunk
 PTR fchptr;                                            // Deposit point in fixup chunk buffer
 
-// BOLLOCKS
-//unsigned fwdjump[MAXFWDJUMPS];       // forward jump check table
-//unsigned fwindex = 0;                        // forward jump index
-
 // Return a size (SIZB, SIZW, SIZL) or 0, depending on what kind of fixup is
 // associated with a location.
 static char fusiztab[] = {
@@ -68,6 +68,28 @@ static char fusizoffs[] = {
 };
 
 
+//
+// Initialize Sections; Setup initial ABS, TEXT, DATA and BSS sections
+//
+void InitSection(void)
+{
+       int i;
+
+       // Cleanup all sections
+       for(i=0; i<NSECTS; i++)
+               mksect(i, 0);
+
+       // Construct default sections, make TEXT the current section
+       mksect(ABS,   SUSED | SABS | SBSS);             // ABS
+       mksect(TEXT,  SUSED | TEXT       );             // TEXT
+       mksect(DATA,  SUSED | DATA       );             // DATA
+       mksect(BSS,   SUSED | BSS | SBSS );             // BSS
+//     mksect(M6502, SUSED | TEXT       );             // 6502 code section
+
+       switchsect(TEXT);                                               // Switch to TEXT for starters
+}
+
+
 //
 // Make a New (Clean) Section
 //
@@ -136,28 +158,6 @@ void savsect(void)
 }
 
 
-//
-// Initialize Sections; Setup initial ABS, TEXT, DATA and BSS sections
-//
-void init_sect(void)
-{
-       int i;
-
-       // Cleanup all sections
-       for(i=0; i<NSECTS; i++)
-               mksect(i, 0);
-
-       // Construct default sections, make TEXT the current section
-       mksect(ABS,   SUSED | SABS | SBSS);             // ABS
-       mksect(TEXT,  SUSED | TEXT       );             // TEXT
-       mksect(DATA,  SUSED | DATA       );             // DATA
-       mksect(BSS,   SUSED | BSS | SBSS );             // BSS
-//     mksect(M6502, SUSED | TEXT       );             // 6502 code section
-
-       switchsect(TEXT);                                               // Switch to TEXT for starters
-}
-
-
 //
 // Test to see if a location has a fixup sic'd on it.  This is used by the
 // listing generator to print 'xx's instead of '00's for forward references
diff --git a/sect.h b/sect.h
index e5711911c96408f72cb226c3875081c0a77fcb95..d86056d33372df357fa664a770f9b8e22d0cc174 100644 (file)
--- a/sect.h
+++ b/sect.h
 // Macros to deposit code in the current section
 // D_rword deposits a "6502" format (low, high) word (01).
 // D_rlong deposits a MWC "canonical byte order" longword (2301).
-#define D_byte(b)    {*chptr++=(char)b; ++sloc; ++ch_size; if(orgactive) ++orgaddr;}
-#define D_word(w)         {chcheck(2);*chptr++=(char)(w>>8); *chptr++=(char)w; \
-                      sloc+=2; ch_size+=2; if(orgactive) orgaddr += 2;}
-#define D_long(lw)   {*chptr++=(char)(lw>>24); *chptr++=(char)(lw>>16);\
-                          *chptr++=(char)(lw>>8); *chptr++=(char)lw; \
-                      sloc+=4; ch_size += 4; if(orgactive) orgaddr += 4;}
-#define D_rword(w)   {*chptr++=(char)w; *chptr++=(char)(w>>8); \
-                      sloc+=2; ch_size+=2;if(orgactive) orgaddr += 2;}
-#define D_rlong(lw)  {*chptr++=(char)(lw>>16);*chptr++=(char)(lw>>24);\
-                      *chptr++=(char)lw;*chptr++=(char)(lw>>8); \
-                      sloc+=4; ch_size += 4;if(orgactive) orgaddr += 4;}
+#define D_byte(b)      {*chptr++=(char)b; ++sloc; ++ch_size; if(orgactive) ++orgaddr;}
+#define D_word(w)      {chcheck(2);*chptr++=(char)(w>>8); *chptr++=(char)w; \
+                                               sloc+=2; ch_size+=2; if(orgactive) orgaddr += 2;}
+#define D_long(lw)     {*chptr++=(char)(lw>>24); *chptr++=(char)(lw>>16);\
+                                               *chptr++=(char)(lw>>8); *chptr++=(char)lw; \
+                                               sloc+=4; ch_size += 4; if(orgactive) orgaddr += 4;}
+//#define D_rword(w)   {*chptr++=(char)w; *chptr++=(char)(w>>8); \
+//                                             sloc+=2; ch_size+=2;if(orgactive) orgaddr += 2;}
+//#define D_rlong(lw)  {*chptr++=(char)(lw>>16);*chptr++=(char)(lw>>24);\
+//                                             *chptr++=(char)lw;*chptr++=(char)(lw>>8); \
+//                                             sloc+=4; ch_size += 4;if(orgactive) orgaddr += 4;}
 
 #define NSECTS       16                                // Max. number of sections
 
@@ -135,13 +135,12 @@ extern LONG challoc;
 extern CHUNK * scode;
 
 // Prototypes
-void init_sect(void);
+void InitSection(void);
 void switchsect(int);
 void savsect(void);
 int fixtest(int, LONG);
 int chcheck(LONG);
 int fixup(WORD, LONG, TOKEN *);
 int ResolveAllFixups(void);
-//int ResolveFixups(int);
 
 #endif // __SECT_H__
diff --git a/token.c b/token.c
index 53f76a98c2e283e4e9042c4987aac4d081201e54..78de051d7e7df3ae3281023a99f7eb65f96fe415 100644 (file)
--- a/token.c
+++ b/token.c
@@ -117,6 +117,57 @@ static char * riscregname[] = {
 };
 
 
+//
+// Initialize Tokenizer
+//
+void InitTokenizer(void)
+{
+       int i;                                                                  // Iterator
+       char * htab = "0123456789abcdefABCDEF"; // Hex character table
+
+       lnsave = 0;                                                             // Don't save lines
+       curfname = "";                                                  // No file, empty filename
+       filecount = (WORD)-1;
+       cfileno = (WORD)-1;                                             // cfileno gets bumped to 0
+       curlineno = 0;
+       totlines = 0;
+       etok = tokbuf;
+       f_inobj = NULL;
+       f_ifile = NULL;
+       f_imacro = NULL;
+       cur_inobj = NULL;
+       filerec = NULL;
+       last_fr = NULL;
+       lntag = SPACE;
+
+       // Initialize hex, "dot" and tolower tables
+       for(i=0; i<128; i++)
+       {
+               hextab[i] = -1;
+               dotxtab[i] = 0;
+               tolowertab[i] = (char)i;
+       }
+
+       for(i=0; htab[i]!=EOS; i++)
+               hextab[htab[i]] = (char)((i < 16) ? i : i - 6);
+
+       for(i='A'; i<='Z'; i++)
+               tolowertab[i] |= 0x20;
+
+       // These characters are legal immediately after a period
+       dotxtab['b'] = DOTB;                                    // .b .B .s .S 
+       dotxtab['B'] = DOTB;
+       dotxtab['s'] = DOTB;
+       dotxtab['S'] = DOTB;
+       dotxtab['w'] = DOTW;                                    // .w .W 
+       dotxtab['W'] = DOTW;
+       dotxtab['l'] = DOTL;                                    // .l .L 
+       dotxtab['L'] = DOTL;
+       dotxtab['i'] = DOTI;                                    // .i .I (???) 
+       dotxtab['I'] = DOTI;
+}
+
+
 void SetFilenameForErrorReporting(void)
 {
        WORD fnum = cfileno;
@@ -563,7 +614,7 @@ overflow:
 //
 // Get Next Line of Text from a Macro
 //
-char * getmln(void)
+char * GetNextMacroLine(void)
 {
        unsigned source_addr;
 
@@ -579,33 +630,6 @@ char * getmln(void)
 //     ExpandMacro((char *)(strp + 1), imacro->im_lnbuf, LNSIZ);
        ExpandMacro(strp->line, imacro->im_lnbuf, LNSIZ);
 
-// bollocks
-#if 0
-       if (!strcmp(imacro->im_macro->sname, "mjump") && !mjump_align)
-       {
-               // if we need to adjust the alignment of the jump source address to
-               // meet the rules of gpu main execution we need to skip the first nop
-               // of the macro. This is simpler than trying to insert nop's mid macro.
-               source_addr = (orgactive ? orgaddr : sloc);
-               source_addr += 8;
-
-               if (source_addr % 4)
-               {
-                       strp = imacro->im_nextln;
-
-                       if (strp == NULL)
-                               return NULL;
-
-//                     imacro->im_nextln = (LONG *)*strp;
-//                     ExpandMacro((char *)(strp + 1), imacro->im_lnbuf, LNSIZ);
-                       imacro->im_nextln = strp->next;
-                       ExpandMacro(strp->line, imacro->im_lnbuf, LNSIZ);
-               }
-
-               mjump_align = 1;
-       }
-#endif
-
        return imacro->im_lnbuf;
 }
 
@@ -613,7 +637,7 @@ char * getmln(void)
 //
 // Get Next Line of Text from a Repeat Block
 //
-char * getrln(void)
+char * GetNextRepeatLine(void)
 {
 
        IREPT * irept = cur_inobj->inobj.irept;
@@ -688,57 +712,6 @@ int include(int handle, char * fname)
 }
 
 
-//
-// Initialize Tokenizer
-//
-void init_token(void)
-{
-       int i;                                                                  // Iterator
-       char * htab = "0123456789abcdefABCDEF"; // Hex character table
-
-       lnsave = 0;                                                             // Don't save lines
-       curfname = "";                                                  // No file, empty filename
-       filecount = (WORD)-1;
-       cfileno = (WORD)-1;                                             // cfileno gets bumped to 0
-       curlineno = 0;
-       totlines = 0;
-       etok = tokbuf;
-       f_inobj = NULL;
-       f_ifile = NULL;
-       f_imacro = NULL;
-       cur_inobj = NULL;
-       filerec = NULL;
-       last_fr = NULL;
-       lntag = SPACE;
-
-       // Initialize hex, "dot" and tolower tables
-       for(i=0; i<128; i++)
-       {
-               hextab[i] = -1;
-               dotxtab[i] = 0;
-               tolowertab[i] = (char)i;
-       }
-
-       for(i=0; htab[i]!=EOS; i++)
-               hextab[htab[i]] = (char)((i < 16) ? i : i - 6);
-
-       for(i='A'; i<='Z'; i++)
-               tolowertab[i] |= 0x20;
-
-       // These characters are legal immediately after a period
-       dotxtab['b'] = DOTB;                                    // .b .B .s .S 
-       dotxtab['B'] = DOTB;
-       dotxtab['s'] = DOTB;
-       dotxtab['S'] = DOTB;
-       dotxtab['w'] = DOTW;                                    // .w .W 
-       dotxtab['W'] = DOTW;
-       dotxtab['l'] = DOTL;                                    // .l .L 
-       dotxtab['L'] = DOTL;
-       dotxtab['I'] = DOTI;                                    // .l .L 
-       dotxtab['I'] = DOTI;
-}
-
-
 //
 // Pop the Current Input Level
 //
@@ -809,7 +782,7 @@ if (verb_flag) printf("[fpop: (post) cfileno=%d ifile->ifno=%d]\n", (int)cfileno
 // Get line from file into buf, return NULL on EOF or ptr to the start of a
 // null-term line
 //
-char * getln(void)
+char * GetNextLine(void)
 {
        int i, j;
        char * p, * d;
@@ -894,7 +867,7 @@ char * getln(void)
 //
 // Tokenize a Line
 //
-int tokln(void)
+int TokenizeLine(void)
 {
        char * ln = NULL;                               // Ptr to current position in line
        char * p;                                               // Random character ptr
@@ -908,7 +881,7 @@ int tokln(void)
        char c1;
        int stringNum = 0;                              // Pointer to string locations in tokenized line
 
-       retry:
+retry:
 
        if (cur_inobj == NULL)                                  // Return EOF if input stack is empty
                return TKEOF;
@@ -923,9 +896,9 @@ int tokln(void)
        // o  tag the listing-line with a space;
        // o  kludge lines generated by Alcyon C.
        case SRC_IFILE:
-               if ((ln = getln()) == NULL)
+               if ((ln = GetNextLine()) == NULL)
                {
-if (verb_flag) printf("tokln: Calling fpop() from SRC_IFILE...\n");
+if (verb_flag) printf("TokenizeLine: Calling fpop() from SRC_IFILE...\n");
                        fpop();                                                 // Pop input level
                        goto retry;                                             // Try for more lines 
                }
@@ -958,7 +931,7 @@ if (verb_flag) printf("tokln: Calling fpop() from SRC_IFILE...\n");
        // o  Handle end-of-macro;
        // o  tag the listing-line with an at (@) sign.
        case SRC_IMACRO:
-               if ((ln = getmln()) == NULL)
+               if ((ln = GetNextMacroLine()) == NULL)
                {
                        ExitMacro();                                    // Exit macro (pop args, do fpop(), etc)
                        goto retry;                                             // Try for more lines...
@@ -970,9 +943,9 @@ if (verb_flag) printf("tokln: Calling fpop() from SRC_IFILE...\n");
        // o  Handle end-of-repeat-block;
        // o  tag the listing-line with a pound (#) sign.
        case SRC_IREPT:
-               if ((ln = getrln()) == NULL)
+               if ((ln = GetNextRepeatLine()) == NULL)
                {
-if (verb_flag) printf("tokln: Calling fpop() from SRC_IREPT...\n");
+if (verb_flag) printf("TokenizeLine: Calling fpop() from SRC_IREPT...\n");
                        fpop();
                        goto retry;
                }
@@ -1200,7 +1173,7 @@ if (verb_flag) printf("tokln: Calling fpop() from SRC_IREPT...\n");
                                                        break;
                                                default:
                                                        warn("bad backslash code in string");
-                                                       --ln;
+                                                       ln--;
                                                        break;
                                                }
                                        }
@@ -1223,19 +1196,19 @@ if (verb_flag) printf("tokln: Calling fpop() from SRC_IREPT...\n");
 
                                        if (*ln == '.')
                                        {
-                                               if ((*(ln+1) == 'b') || (*(ln+1) == 'B'))
+                                               if ((*(ln + 1) == 'b') || (*(ln + 1) == 'B'))
                                                {
                                                        v &= 0x000000FF;
                                                        ln += 2;
                                                }
 
-                                               if ((*(ln+1) == 'w') || (*(ln+1) == 'W'))
+                                               if ((*(ln + 1) == 'w') || (*(ln + 1) == 'W'))
                                                {
                                                        v &= 0x0000FFFF;
                                                        ln += 2;
                                                }
 
-                                               if ((*(ln+1) == 'l') || (*(ln+1) == 'L'))
+                                               if ((*(ln + 1) == 'l') || (*(ln + 1) == 'L'))
                                                {
                                                        ln += 2;
                                                }
@@ -1292,11 +1265,11 @@ if (verb_flag) printf("tokln: Calling fpop() from SRC_IREPT...\n");
                                {
                                case '>':
                                        *tk++ = SHR;
-                                       ++ln;
+                                       ln++;
                                        continue;
                                case '=':
                                        *tk++ = GE;
-                                       ++ln;
+                                       ln++;
                                        continue;
                                default:
                                        *tk++ = '>';
@@ -1530,6 +1503,7 @@ int d_goto(WORD unused)
                {
                        // Compare names (sleazo string compare)
                        // This string compare is not right. Doesn't check for lengths.
+                       // (actually it does, but in a crappy, unclear way.)
 #warning "!!! Bad string comparison !!!"
                        s1 = sym;
 //                     s2 = (char *)(defln + 1) + 1;
diff --git a/token.h b/token.h
index 0109489f588cf0e409974b57f8faab6539672382..c7dc4b194cceffc74eecbb50a4bdf02f5f727e84 100644 (file)
--- a/token.h
+++ b/token.h
@@ -154,9 +154,9 @@ extern char * string[];
 
 // Prototypes
 int include(int, char *);
-void init_token(void);
+void InitTokenizer(void);
 void SetFilenameForErrorReporting(void);
-int tokln(void);
+int TokenizeLine(void);
 int fpop(void);
 int d_goto(WORD);
 //int d_goto(void);