* as/hc08/Makefile.bcc, as/hc08/Makefile.in, as/hc08/as_hc08.dsp,
authorborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 29 Dec 2007 21:44:17 +0000 (21:44 +0000)
committerborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 29 Dec 2007 21:44:17 +0000 (21:44 +0000)
  as/mcs51/Makefile.bcc, as/mcs51/Makefile.in, as/mcs51/asx8051.dsp,
  as/z80/Makefile.bcc, as/z80/Makefile.in, as/z80/as_gbz80.dsp,
  as/z80/as_z80.dsp: added dbuf.[ch] and dbuf_string[ch] to project
* as/asxxsrc/aslex.c: use dbuf_getline()
* as/hc08/asdata.c, as/hc08/asexpr.c, as/hc08/asm.h, as/hc08/m08adr.c,
  as/mcs51/asdata.c, as/mcs51/asexpr.c, as/mcs51/asm.h,
  as/mcs51/i51adr.c, as/z80/asdata.c, as/z80/asexpr.c, as/z80/aslist.c,
  as/z80/asm.h, as/z80/z80adr.c:
  changed type of ib and ip to const char *

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4988 4a8a32a2-be11-0410-ad9d-d568d2c75423

26 files changed:
ChangeLog
as/asxxsrc/aslex.c
as/hc08/Makefile.bcc
as/hc08/Makefile.in
as/hc08/as_hc08.dsp
as/hc08/asdata.c
as/hc08/asexpr.c
as/hc08/asm.h
as/hc08/m08adr.c
as/mcs51/Makefile.bcc
as/mcs51/Makefile.in
as/mcs51/asdata.c
as/mcs51/asexpr.c
as/mcs51/asm.h
as/mcs51/asx8051.dsp
as/mcs51/i51adr.c
as/z80/Makefile.bcc
as/z80/Makefile.in
as/z80/as_gbz80.dsp
as/z80/as_z80.dsp
as/z80/asdata.c
as/z80/asexpr.c
as/z80/aslist.c
as/z80/asm.h
as/z80/z80adr.c
src/SDCCasm.c

index 492ad2fbfd8ceefe12ecb9793ca5de4dce0bd989..8ee437efa8fa173dee6c1a5b26bf7724fe1133c7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,16 @@
        * src/ds390/gen.c, src/hc08/gen.c, src/mcs51/gen.c, src/pic16/gen.c,
          src/pic/gen.c, src/z80/gen.c, src/xa51/gen.c, src/pic16/ralloc.c,
          src/pic16/pcode.[ch]: added const qualifier
+       * as/hc08/Makefile.bcc, as/hc08/Makefile.in, as/hc08/as_hc08.dsp,
+         as/mcs51/Makefile.bcc, as/mcs51/Makefile.in, as/mcs51/asx8051.dsp,
+         as/z80/Makefile.bcc, as/z80/Makefile.in, as/z80/as_gbz80.dsp,
+         as/z80/as_z80.dsp: added dbuf.[ch] and dbuf_string[ch] to project
+       * as/asxxsrc/aslex.c: use dbuf_getline()
+       * as/hc08/asdata.c, as/hc08/asexpr.c, as/hc08/asm.h, as/hc08/m08adr.c,
+         as/mcs51/asdata.c, as/mcs51/asexpr.c, as/mcs51/asm.h,
+         as/mcs51/i51adr.c, as/z80/asdata.c, as/z80/asexpr.c, as/z80/aslist.c,
+         as/z80/asm.h, as/z80/z80adr.c:
+         changed type of ib and ip to const char *
 
 2007-12-28 Borut Razem <borut.razem AT siol.net>
 
index 22fa8f410c195b64d31b86d7e85531fea9ec9902..ae3161560d970df7f59bbbff4b235617f213e238 100644 (file)
@@ -19,6 +19,7 @@
 #include <stdio.h>
 #include <setjmp.h>
 #include <string.h>
+#include "dbuf_string.h"
 #include "asm.h"
 
 /*)Module       aslex.c
@@ -356,75 +357,6 @@ getmap(d)
         return (c);
 }
 
-/*)Function     char *  readlin()
- *
- *              char *  str             poinetr to beginning of the buffer
- *              size_t  n               size of the buffer
- *              FILE *  infp            input file pointer
- *
- *      The function readlin() reads a line from a file to the buffer s.
- *      The buffer length is n. If the line is truncterd to n -1 caharecters
- *      if it is longer the n - 1 characters.
- *      Trailing LF or CR/LF are removed from str, if present.
- *
- *      local variables:
- *              int c                   character read from the file
- *              char *s                 buffer pointer
- *              satic char eof_f        EOF flag
- *
- *      global variables:
- *              none
- *
- *      called functions:
- *              int     getc            c-library
- */
-
-char *
-readlin(char *str, size_t n, FILE *infp)
-{
-  int c = ' ';  /* initialize it to something for the caharacter eating step */
-  char *s;
-  static char eof_f = 0;
-
-  if (eof_f)
-    {
-      eof_f = 0;
-      return NULL;
-    }
-
-  if (n > 0)
-    {
-    s = str;
-    if (n > 1)
-      {
-        while (--n && (c = getc(infp)) != '\n' && c != EOF)
-          *s++ = c;
-      }
-
-    /* chop CR */
-    if (s > str && *(s - 1) == '\r')
-      --s;
-
-    /* terminate the line */
-    *s = '\0';
-
-    /* eat characters until the end of line */
-    while (c != '\n' && c != EOF)
-      c = getc(infp);
-
-    /* if the EOF is not at the beginning of the line, return the line;
-       return NULL at the next call of redlin */
-    if (c == EOF)
-      {
-        if (s == str)
-          return NULL;
-        eof_f = 1;
-      }
-    }
-
-  return str;
-}
-
 /*)Function     int     as_getline()
  *
  *      The function as_getline() reads a line of assembler-source text
@@ -442,7 +374,7 @@ readlin(char *str, size_t n, FILE *infp)
  *              int     i               string length
  *
  *      global variables:
- *              char    ib[]            string buffer containing
+ *              const char ib[]         string buffer containing
  *                                      assembler-source text line
  *              char    ifp[]           array of file handles for
  *                                      include files
@@ -459,6 +391,10 @@ readlin(char *str, size_t n, FILE *infp)
  *              int     inpfil          maximum input file index
  *
  *      called functions:
+ *              int     dbuf_init()
+ *              int     dbuf_set_length()
+ *              int     dbuf_getline()
+ *              const char * dbuf_c_str()
  *              int     fclose()        c-library
  *              char *  fgets()         c-library
  *              int     strlen()        c-library
@@ -472,29 +408,64 @@ readlin(char *str, size_t n, FILE *infp)
  */
 
 int
-as_getline()
+as_getline(void)
 {
-loop:   if (incfil >= 0) {
-                if (readlin(ib, sizeof ib, ifp[incfil]) == NULL) {
-                        fclose(ifp[incfil]);
-                        ifp[incfil--] = NULL;
-                        lop = NLPP;
-                        goto loop;
-                } else {
-                        ++incline[incfil];
-                }
-        } else {
-                if (readlin(ib, sizeof ib, sfp[cfile]) == NULL) {
-                        if (++cfile <= inpfil) {
-                                srcline[cfile] = 0;
-                                goto loop;
-                        }
-                        return (0);
-                } else {
-                        ++srcline[cfile];
-                }
+  static struct dbuf_s dbuf;
+  static char dbufInitialized = 0;
+  size_t len;
+
+  if (!dbufInitialized)
+    {
+      dbuf_init (&dbuf, 1024);
+      dbufInitialized = 1;
+    }
+  else
+    dbuf_set_length (&dbuf, 0);
+
+loop:
+  if (incfil >= 0)
+    {
+      if ((len = dbuf_getline (&dbuf, ifp[incfil])) == 0)
+        {
+          fclose (ifp[incfil]);
+          ifp[incfil--] = NULL;
+          lop = NLPP;
+          goto loop;
+        }
+      else
+        {
+          ++incline[incfil];
         }
-        return (1);
+    }
+  else
+    {
+      if ((len = dbuf_getline (&dbuf, sfp[cfile])) == 0)
+        {
+          if (++cfile <= inpfil)
+            {
+              srcline[cfile] = 0;
+              goto loop;
+            }
+          return 0;
+        }
+      else
+        {
+          ++srcline[cfile];
+        }
+    }
+  ib = dbuf_c_str (&dbuf);
+
+  /* remove the trailing NL */
+  if (len > 0 && '\n' == ib[len - 1])
+    {
+      --len;
+      if (len > 0 && '\r' == ib[len - 1])
+        --len;
+      dbuf_set_length (&dbuf, len);
+      ib = dbuf_c_str (&dbuf);
+    }
+
+  return 1;
 }
 
 /*)Function     int     more()
index 068d802b3792d451d938147f349939d1678e4317..384c518e459134add3f90abb94d3ee84625fc259 100644 (file)
@@ -7,7 +7,8 @@ PRJDIR          = ../..
 ASOBJECTS       = asmain.obj aslex.obj assubr.obj asnoice.obj \
                   asexpr.obj asdata.obj aslist.obj asout.obj \
                   h08ext.obj h08pst.obj h08mch.obj h08adr.obj \
-                  ../asxxsrc/strcmpi.obj ../asxxsrc/assym.obj
+                  ../asxxsrc/strcmpi.obj ../asxxsrc/assym.obj \
+                  ../../support/Util/dbuf.obj ../../support/Util/dbuf_string.obj
 
 ASX8051         = $(PRJDIR)/bin/asx8051.exe
 
index 65ab660f849df243e231a3460ee738d133ccfdf1..4a4e3ce5345cde57d83280a36ffe235034a8bd54 100644 (file)
@@ -40,19 +40,22 @@ LDFLAGS         = @LDFLAGS@
 
 OBJDIR = obj
 
-ASXXLIB = $(srcdir)/../asxxsrc
+UTILLIB = $(srcdir)/../../support/Util
+UTILSRC = dbuf.c dbuf_string.c
+UTILLIBOBJS = $(UTILSRC:%.c=$(OBJDIR)/%.o)
 
+ASXXLIB = $(srcdir)/../asxxsrc
 ASXXLIBSRC = strcmpi.c assym.c aslex.c
+ASXXLIBOBJS = $(ASXXLIBSRC:%.c=$(OBJDIR)/%.o)
 
 SRC = asmain.c assubr.c asnoice.c \
       asexpr.c asdata.c aslist.c asout.c \
       m08ext.c m08pst.c m08mch.c m08adr.c
-
-ASSOURCES = %(SRC) $(ASXXLIBSRC:%.c=$(ASXXLIB)/%.c)
-                  
 OBJS = $(SRC:%.c=$(OBJDIR)/%.o)
-ASXXLIBOBJS = $(ASXXLIBSRC:%.c=$(OBJDIR)/%.o)
-ASOBJECTS = $(OBJS) $(ASXXLIBOBJS)
+
+ASSOURCES = %(SRC) $(ASXXLIBSRC:%.c=$(ASXXLIB)/%.c) $(UTILSRC:%.c=$(UTILLIB)/%.c)
+
+AASOBJECTS = $(OBJS) $(ASXXLIBOBJS) $(UTILLIBOBJS)
 
 ASHC08 = $(top_builddir)/bin/as-hc08$(EXEEXT)
 
index 8cd7b59c02ed82e997460df5c2ed9fdb34025287..2b2c675e215606d94db1b24328769d8d596aec64 100644 (file)
@@ -42,7 +42,7 @@ RSC=rc.exe
 # PROP Ignore_Export_Lib 0\r
 # PROP Target_Dir ""\r
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c\r
-# ADD CPP /nologo /W3 /GX /O2 /I "." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c\r
+# ADD CPP /nologo /W3 /GX /O2 /I "." /I "../../support/Util" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c\r
 # ADD BASE RSC /l 0x409 /d "NDEBUG"\r
 # ADD RSC /l 0x409 /d "NDEBUG"\r
 BSC32=bscmake.exe\r
@@ -66,7 +66,7 @@ LINK32=link.exe
 # PROP Ignore_Export_Lib 0\r
 # PROP Target_Dir ""\r
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c\r
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /U "." /YX /FD /GZ /c\r
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "." /I "../../support/Util" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c\r
 # ADD BASE RSC /l 0x409 /d "_DEBUG"\r
 # ADD RSC /l 0x409 /d "_DEBUG"\r
 BSC32=bscmake.exe\r
@@ -123,6 +123,14 @@ SOURCE=..\asxxsrc\assym.c
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=..\..\support\Util\dbuf.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\support\Util\dbuf_string.c\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\m08adr.c\r
 # End Source File\r
 # Begin Source File\r
@@ -151,6 +159,14 @@ SOURCE=.\asm.h
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=..\..\support\Util\dbuf.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\support\Util\dbuf_string.h\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\m6808.h\r
 # End Source File\r
 # End Group\r
index 166575209bfe2b97104b008c2d826a673f961f98..2069661df9a507abf0ffbd5855590d7968cf0904 100644 (file)
@@ -8,8 +8,8 @@
  * 721 Berkeley St.
  * Kent, Ohio  44240
  *
- * 28-Oct-97 JLH: 
- *          - change s_id from [NCPS] to pointer (comment)
+ * 28-Oct-97 JLH:
+ *           - change s_id from [NCPS] to pointer (comment)
  *  2-Nov-97 JLH:
  *           - add jflag for debug control
  */
 #include <string.h>
 #include "asm.h"
 
-/*)Module      asdata.c
+/*)Module       asdata.c
  *
- *     The module asdata.c contains the global constants,
- *     structures, and variables used in the assembler.
+ *      The module asdata.c contains the global constants,
+ *      structures, and variables used in the assembler.
  */
 
-int    aserr;          /*      ASxxxx error counter
-                        */
-jmp_buf        jump_env;       /*      compiler dependent structure
-                        *      used by setjmp() and longjmp()
-                        */
-int    inpfil;         /*      count of assembler
-                        *      input files specified
-                        */
-int    incfil;         /*      current file handle index
-                        *      for include files
-                        */
-int    cfile;          /*      current file handle index
-                        *      of input assembly files
-                        */
-int    flevel;         /*      IF-ELSE-ENDIF flag will be non
-                        *      zero for false conditional case
-                        */
-int    tlevel;         /*      current conditional level
-                        */
-int    ifcnd[MAXIF+1]; /*      array of IF statement condition
-                        *      values (0 = FALSE) indexed by tlevel
-                        */
-int    iflvl[MAXIF+1]; /*      array of IF-ELSE-ENDIF flevel
-                        *      values indexed by tlevel
-                        */
+int     aserr;          /*      ASxxxx error counter
+                         */
+jmp_buf jump_env;       /*      compiler dependent structure
+                         *      used by setjmp() and longjmp()
+                         */
+int     inpfil;         /*      count of assembler
+                         *      input files specified
+                         */
+int     incfil;         /*      current file handle index
+                         *      for include files
+                         */
+int     cfile;          /*      current file handle index
+                         *      of input assembly files
+                         */
+int     flevel;         /*      IF-ELSE-ENDIF flag will be non
+                         *      zero for false conditional case
+                         */
+int     tlevel;         /*      current conditional level
+                         */
+int     ifcnd[MAXIF+1]; /*      array of IF statement condition
+                         *      values (0 = FALSE) indexed by tlevel
+                         */
+int     iflvl[MAXIF+1]; /*      array of IF-ELSE-ENDIF flevel
+                         *      values indexed by tlevel
+                         */
 
-char   afn[PATH_MAX];          /*      afile temporary file name
-                                */
-char   srcfn[MAXFIL][PATH_MAX];        /*      array of source file names
-                                */
-int    srcline[MAXFIL];        /*      source line number
-                                */
-char   incfn[MAXINC][PATH_MAX];        /*      array of include file names
-                                */
-int    incline[MAXINC];        /*      include line number
-                                */
+char    afn[PATH_MAX];          /*      afile temporary file name
+                                 */
+char    srcfn[MAXFIL][PATH_MAX];        /*      array of source file names
+                                 */
+int     srcline[MAXFIL];        /*      source line number
+                                 */
+char    incfn[MAXINC][PATH_MAX];        /*      array of include file names
+                                 */
+int     incline[MAXINC];        /*      include line number
+                                 */
 
-int    radix;          /*      current number conversion radix:
-                        *      2 (binary), 8 (octal), 10 (decimal),
-                        *      16 (hexadecimal)
-                        */
-int    line;           /*      current assembler source
-                        *      line number
-                        */
-int    page;           /*      current page number
-                        */
-int    lop;            /*      current line number on page
-                        */
-int    pass;           /*      assembler pass number
-                        */
-int    lflag;          /*      -l, generate listing flag
-                        */
-int    cflag;          /*      -lc, generate sdcdb debug info
-                        */
-int    gflag;          /*      -g, make undefined symbols global flag
-                        */
-int    aflag;          /*      -a, make all symbols global flag
-                        */
-int    jflag;          /*      -j, generate debug information flag
-                        */
-int    oflag;          /*      -o, generate relocatable output flag
-                        */
-int    sflag;          /*      -s, generate symbol table flag
-                        */
-int    pflag;          /*      -p, enable listing pagination
-                        */
-int    xflag;          /*      -x, listing radix flag
-                        */
-int    fflag;          /*      -f(f), relocations flagged flag
-                        */
-Addr_T laddr;          /*      address of current assembler line
-                        *      or value of .if argument
-                        */
-Addr_T fuzz;           /*      tracks pass to pass changes in the
-                        *      address of symbols caused by
-                        *      variable length instruction formats
-                        */
-int    lmode;          /*      listing mode
-                        */
-char   *ep;            /*      pointer into error list
-                        *      array eb[NERR]
-                        */
-char   eb[NERR];       /*      array of generated error codes
-                        */
-char   *ip;            /*      pointer into the assembler-source
-                        *      text line in ib[]
-                        */
-char   ib[NINPUT];     /*      assembler-source text line
-                        */
-char   *cp;            /*      pointer to assembler output
-                        *      array cb[]
-                        */
-char   cb[NCODE];      /*      array of assembler output values
-                        */
-int    *cpt;           /*      pointer to assembler relocation type
-                        *      output array cbt[]
-                        */
-int    cbt[NCODE];     /*      array of assembler relocation types
-                        *      describing the data in cb[]
-                        */
-char   tb[NTITL];      /*      Title string buffer
-                        */
-char   stb[NSBTL];     /*      Subtitle string buffer
-                        */
-char   optsdcc[NINPUT];        /*      sdcc compile options 
-                        */
-int    flat24Mode;     /*      non-zero if we are using DS390 24 bit 
-                        *      flat mode (via .flat24 directive). 
-                        */
+int     radix;          /*      current number conversion radix:
+                         *      2 (binary), 8 (octal), 10 (decimal),
+                         *      16 (hexadecimal)
+                         */
+int     line;           /*      current assembler source
+                         *      line number
+                         */
+int     page;           /*      current page number
+                         */
+int     lop;            /*      current line number on page
+                         */
+int     pass;           /*      assembler pass number
+                         */
+int     lflag;          /*      -l, generate listing flag
+                         */
+int     cflag;          /*      -lc, generate sdcdb debug info
+                         */
+int     gflag;          /*      -g, make undefined symbols global flag
+                         */
+int     aflag;          /*      -a, make all symbols global flag
+                         */
+int     jflag;          /*      -j, generate debug information flag
+                         */
+int     oflag;          /*      -o, generate relocatable output flag
+                         */
+int     sflag;          /*      -s, generate symbol table flag
+                         */
+int     pflag;          /*      -p, enable listing pagination
+                         */
+int     xflag;          /*      -x, listing radix flag
+                         */
+int     fflag;          /*      -f(f), relocations flagged flag
+                         */
+Addr_T  laddr;          /*      address of current assembler line
+                         *      or value of .if argument
+                         */
+Addr_T  fuzz;           /*      tracks pass to pass changes in the
+                         *      address of symbols caused by
+                         *      variable length instruction formats
+                         */
+int     lmode;          /*      listing mode
+                         */
+char    *ep;            /*      pointer into error list
+                         *      array eb[NERR]
+                         */
+char    eb[NERR];       /*      array of generated error codes
+                         */
+const char *ip;         /*      pointer into the assembler-source
+                         *      text line in ib[]
+                         */
+const char *ib;         /*      assembler-source text line
+                         */
+char    *cp;            /*      pointer to assembler output
+                         *      array cb[]
+                         */
+char    cb[NCODE];      /*      array of assembler output values
+                         */
+int     *cpt;           /*      pointer to assembler relocation type
+                         *      output array cbt[]
+                         */
+int     cbt[NCODE];     /*      array of assembler relocation types
+                         *      describing the data in cb[]
+                         */
+char    tb[NTITL];      /*      Title string buffer
+                         */
+char    stb[NSBTL];     /*      Subtitle string buffer
+                         */
+char    optsdcc[NINPUT];        /*      sdcc compile options
+                         */
+int     flat24Mode;     /*      non-zero if we are using DS390 24 bit
+                         *      flat mode (via .flat24 directive).
+                         */
 
-char   symtbl[] = { "Symbol Table" };
-char   aretbl[] = { "Area Table" };
+char    symtbl[] = { "Symbol Table" };
+char    aretbl[] = { "Area Table" };
 
-char   module[NCPS];   /*      module name string
-                        */
+char    module[NCPS];   /*      module name string
+                         */
 
 /*
- *     The mne structure is a linked list of the assembler
- *     mnemonics and directives.  The list of mnemonics and
- *     directives contained in the device dependent file
- *     xxxpst.c are hashed and linked into NHASH lists in
- *     module assym.c by syminit().  The structure contains
- *     the mnemonic/directive name, a subtype which directs
- *     the evaluation of this mnemonic/directive, a flag which
- *     is used to detect the end of the mnemonic/directive
- *     list in xxxpst.c, and a value which is normally
- *     associated with the assembler mnemonic base instruction
- *     value.
+ *      The mne structure is a linked list of the assembler
+ *      mnemonics and directives.  The list of mnemonics and
+ *      directives contained in the device dependent file
+ *      xxxpst.c are hashed and linked into NHASH lists in
+ *      module assym.c by syminit().  The structure contains
+ *      the mnemonic/directive name, a subtype which directs
+ *      the evaluation of this mnemonic/directive, a flag which
+ *      is used to detect the end of the mnemonic/directive
+ *      list in xxxpst.c, and a value which is normally
+ *      associated with the assembler mnemonic base instruction
+ *      value.
  *
- *     struct  mne
- *     {
- *             struct  mne *m_mp;      Hash link
- *             char    m_id[NCPS];     Mnemonic
- *             char    m_type;         Mnemonic subtype
- *             char    m_flag;         Mnemonic flags
- *             Addr_T  m_valu;         Value
- *     };
+ *      struct  mne
+ *      {
+ *              struct  mne *m_mp;      Hash link
+ *              char    m_id[NCPS];     Mnemonic
+ *              char    m_type;         Mnemonic subtype
+ *              char    m_flag;         Mnemonic flags
+ *              Addr_T  m_valu;         Value
+ *      };
  */
-struct mne     *mnehash[NHASH];
+struct  mne     *mnehash[NHASH];
 
 /*
- *     The sym structure is a linked list of symbols defined
- *     in the assembler source files.  The first symbol is "."
- *     defined here.  The entry 'struct tsym *s_tsym'
- *     links any temporary symbols following this symbol and
- *     preceeding the next normal symbol.  The structure also
- *     contains the symbol's name, type (USER or NEW), flag
- *     (global, assigned, and multiply defined), a pointer
- *     to the area structure defining where the symbol is
- *     located, a reference number assigned by outgsd() in
- *     asout.c, and the symbols address relative to the base
- *     address of the area where the symbol is located.
+ *      The sym structure is a linked list of symbols defined
+ *      in the assembler source files.  The first symbol is "."
+ *      defined here.  The entry 'struct tsym *s_tsym'
+ *      links any temporary symbols following this symbol and
+ *      preceeding the next normal symbol.  The structure also
+ *      contains the symbol's name, type (USER or NEW), flag
+ *      (global, assigned, and multiply defined), a pointer
+ *      to the area structure defining where the symbol is
+ *      located, a reference number assigned by outgsd() in
+ *      asout.c, and the symbols address relative to the base
+ *      address of the area where the symbol is located.
  *
- *     struct  sym
- *     {
- *             struct  sym  *s_sp;     Hash link
- *             struct  tsym *s_tsym;   Temporary symbol link
- *             char    *s_id;          Symbol (JLH)
- *             char    s_type;         Symbol subtype
- *             char    s_flag;         Symbol flags
- *             struct  area *s_area;   Area line, 0 if absolute
- *             int     s_ref;          Ref. number
- *             Addr_T  s_addr;         Address
- *     };
+ *      struct  sym
+ *      {
+ *              struct  sym  *s_sp;     Hash link
+ *              struct  tsym *s_tsym;   Temporary symbol link
+ *              char    *s_id;          Symbol (JLH)
+ *              char    s_type;         Symbol subtype
+ *              char    s_flag;         Symbol flags
+ *              struct  area *s_area;   Area line, 0 if absolute
+ *              int     s_ref;          Ref. number
+ *              Addr_T  s_addr;         Address
+ *      };
  */
-struct sym     sym[] = {
-    {NULL,     NULL,   ".",    S_USER, S_END,  NULL,   0,      0}
+struct  sym     sym[] = {
+    {NULL,      NULL,   ".",    S_USER, S_END,  NULL,   0,      0}
 };
 
-struct sym     *symp;          /*      pointer to a symbol structure
-                                */
-struct sym *symhash[NHASH];    /*      array of pointers to NHASH
-                                *      linked symbol lists
-                                */
+struct  sym     *symp;          /*      pointer to a symbol structure
+                                 */
+struct  sym *symhash[NHASH];    /*      array of pointers to NHASH
+                                 *      linked symbol lists
+                                 */
 
 /*
- *     The area structure contains the parameter values for a
- *     specific program or data section.  The area structure
- *     is a linked list of areas.  The initial default area
- *     is "_CODE" defined here, the next area structure
- *     will be linked to this structure through the structure
- *     element 'struct area *a_ep'.  The structure contains the
- *     area name, area reference number ("_CODE" is 0) determined
- *     by the order of .area directives, area size determined
- *     from the total code and/or data in an area, area fuzz is
- *     an variable used to track pass to pass changes in the
- *     area size caused by variable length instruction formats,
- *     and area flags which specify the area's relocation type.
+ *      The area structure contains the parameter values for a
+ *      specific program or data section.  The area structure
+ *      is a linked list of areas.  The initial default area
+ *      is "_CODE" defined here, the next area structure
+ *      will be linked to this structure through the structure
+ *      element 'struct area *a_ep'.  The structure contains the
+ *      area name, area reference number ("_CODE" is 0) determined
+ *      by the order of .area directives, area size determined
+ *      from the total code and/or data in an area, area fuzz is
+ *      an variable used to track pass to pass changes in the
+ *      area size caused by variable length instruction formats,
+ *      and area flags which specify the area's relocation type.
  *
- *     struct  area
- *     {
- *             struct  area *a_ap;     Area link
- *             char    a_id[NCPS];     Area Name
- *             int     a_ref;          Reference number
- *             Addr_T  a_size;         Area size
- *             Addr_T  a_fuzz;         Area fuzz
- *             int     a_flag;         Area flags
- *     };
+ *      struct  area
+ *      {
+ *              struct  area *a_ap;     Area link
+ *              char    a_id[NCPS];     Area Name
+ *              int     a_ref;          Reference number
+ *              Addr_T  a_size;         Area size
+ *              Addr_T  a_fuzz;         Area fuzz
+ *              int     a_flag;         Area flags
+ *      };
  */
-struct area    area[] = {
-    {NULL,     "_CODE",        0,      0,      0,      A_CON|A_REL}
+struct  area    area[] = {
+    {NULL,      "_CODE",        0,      0,      0,      A_CON|A_REL}
 };
 
-struct area    *areap; /*      pointer to an area structure
-                        */
+struct  area    *areap; /*      pointer to an area structure
+                         */
 
-FILE   *lfp;           /*      list output file handle
-                        */
-FILE   *ofp;           /*      relocation output file handle
-                        */
-FILE   *tfp;           /*      symbol table output file handle
-                        */
-FILE   *sfp[MAXFIL];   /*      array of assembler-source file handles
-                        */
-FILE   *ifp[MAXINC];   /*      array of include-file file handles
-                        */
+FILE    *lfp;           /*      list output file handle
+                         */
+FILE    *ofp;           /*      relocation output file handle
+                         */
+FILE    *tfp;           /*      symbol table output file handle
+                         */
+FILE    *sfp[MAXFIL];   /*      array of assembler-source file handles
+                         */
+FILE    *ifp[MAXINC];   /*      array of include-file file handles
+                         */
 
 /*
- *     array of character types, one per
- *     ASCII character
+ *      array of character types, one per
+ *      ASCII character
  */
-unsigned char  ctype[128] = {
-/*NUL*/        ILL,    ILL,    ILL,    ILL,    ILL,    ILL,    ILL,    ILL,
-/*BS*/ ILL,    SPACE,  ILL,    ILL,    SPACE,  ILL,    ILL,    ILL,
-/*DLE*/        ILL,    ILL,    ILL,    ILL,    ILL,    ILL,    ILL,    ILL,
-/*CAN*/        ILL,    ILL,    ILL,    ILL,    ILL,    ILL,    ILL,    ILL,
-/*SPC*/        SPACE,  ETC,    ETC,    ETC,    LETTER, BINOP,  BINOP,  ETC,
-/*(*/  ETC,    ETC,    BINOP,  BINOP,  ETC,    BINOP,  LETTER, BINOP,
-/*0*/  DGT2,   DGT2,   DGT8,   DGT8,   DGT8,   DGT8,   DGT8,   DGT8,
-/*8*/  DGT10,  DGT10,  ETC,    ETC,    BINOP,  ETC,    BINOP,  ETC,
-/*@*/  ETC,    LTR16,  LTR16,  LTR16,  LTR16,  LTR16,  LTR16,  LETTER,
-/*H*/  LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
-/*P*/  LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
-/*X*/  LETTER, LETTER, LETTER, ETC,    ETC,    ETC,    BINOP,  LETTER,
-/*`*/  ETC,    LTR16,  LTR16,  LTR16,  LTR16,  LTR16,  LTR16,  LETTER,
-/*h*/  LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
-/*p*/  LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
-/*x*/  LETTER, LETTER, LETTER, ETC,    BINOP,  ETC,    ETC,    ETC
+unsigned char   ctype[128] = {
+/*NUL*/ ILL,    ILL,    ILL,    ILL,    ILL,    ILL,    ILL,    ILL,
+/*BS*/  ILL,    SPACE,  ILL,    ILL,    SPACE,  ILL,    ILL,    ILL,
+/*DLE*/ ILL,    ILL,    ILL,    ILL,    ILL,    ILL,    ILL,    ILL,
+/*CAN*/ ILL,    ILL,    ILL,    ILL,    ILL,    ILL,    ILL,    ILL,
+/*SPC*/ SPACE,  ETC,    ETC,    ETC,    LETTER, BINOP,  BINOP,  ETC,
+/*(*/   ETC,    ETC,    BINOP,  BINOP,  ETC,    BINOP,  LETTER, BINOP,
+/*0*/   DGT2,   DGT2,   DGT8,   DGT8,   DGT8,   DGT8,   DGT8,   DGT8,
+/*8*/   DGT10,  DGT10,  ETC,    ETC,    BINOP,  ETC,    BINOP,  ETC,
+/*@*/   ETC,    LTR16,  LTR16,  LTR16,  LTR16,  LTR16,  LTR16,  LETTER,
+/*H*/   LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
+/*P*/   LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
+/*X*/   LETTER, LETTER, LETTER, ETC,    ETC,    ETC,    BINOP,  LETTER,
+/*`*/   ETC,    LTR16,  LTR16,  LTR16,  LTR16,  LTR16,  LTR16,  LETTER,
+/*h*/   LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
+/*p*/   LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
+/*x*/   LETTER, LETTER, LETTER, ETC,    BINOP,  ETC,    ETC,    ETC
 };
 
 /*
- *     an array of characters which
- *     perform the case translation function
+ *      an array of characters which
+ *      perform the case translation function
  */
-char   ccase[128] = {
-/*NUL*/        '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
-/*BS*/ '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
-/*DLE*/        '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
-/*CAN*/        '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
-/*SPC*/        '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
-/*(*/  '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
-/*0*/  '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
-/*8*/  '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
-/*@*/  '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
-/*H*/  '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
-/*P*/  '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
-/*X*/  '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
-/*`*/  '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
-/*h*/  '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
-/*p*/  '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
-/*x*/  '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177'
-};     
+char    ccase[128] = {
+/*NUL*/ '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
+/*BS*/  '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
+/*DLE*/ '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
+/*CAN*/ '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
+/*SPC*/ '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
+/*(*/   '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
+/*0*/   '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
+/*8*/   '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
+/*@*/   '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
+/*H*/   '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
+/*P*/   '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
+/*X*/   '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
+/*`*/   '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
+/*h*/   '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
+/*p*/   '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
+/*x*/   '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177'
+};
index a21e9b0feff473674417f5297f5d691d5de53d6a..6f433940f20955517f80d04791b219caac193256 100644 (file)
@@ -1,4 +1,4 @@
-       /* asexpr.c */
+        /* asexpr.c */
 
 /*
  * (C) Copyright 1989-1995
 #include <string.h>
 #include "asm.h"
 
-/*)Module      asexpr.c
- *
- *     The module asexpr.c contains the routines to evaluate
- *     arithmetic/numerical expressions.  The functions in
- *     asexpr.c perform a recursive evaluation of the arithmetic
- *     expression read from the assembler-source text line.
- *     The expression may include binary/unary operators, brackets,
- *     symbols, labels, and constants in hexadecimal, decimal, octal
- *     and binary.  Arithmetic operations are prioritized and
- *     evaluated by normal arithmetic conventions.
- *
- *     asexpr.c contains the following functions:
- *             VOID    abscheck()
- *             Addr_T  absexpr()
- *             VOID    clrexpr()
- *             int     digit()
- *             VOID    expr()
- *             int     oprio()
- *             VOID    term()
- *
- *     asexpr.c contains no local/static variables
+/*)Module       asexpr.c
+ *
+ *      The module asexpr.c contains the routines to evaluate
+ *      arithmetic/numerical expressions.  The functions in
+ *      asexpr.c perform a recursive evaluation of the arithmetic
+ *      expression read from the assembler-source text line.
+ *      The expression may include binary/unary operators, brackets,
+ *      symbols, labels, and constants in hexadecimal, decimal, octal
+ *      and binary.  Arithmetic operations are prioritized and
+ *      evaluated by normal arithmetic conventions.
+ *
+ *      asexpr.c contains the following functions:
+ *              VOID    abscheck()
+ *              Addr_T  absexpr()
+ *              VOID    clrexpr()
+ *              int     digit()
+ *              VOID    expr()
+ *              int     oprio()
+ *              VOID    term()
+ *
+ *      asexpr.c contains no local/static variables
  */
 
-/*)Function    VOID    expr(esp, n)
- *
- *             expr *  esp             pointer to an expr structure
- *             int     n               a firewall priority; all top
- *                                     level calls (from the user)
- *                                     should be made with n set to 0.
- *
- *     The function expr() evaluates an expression and
- *     stores its value and relocation information into
- *     the expr structure supplied by the user.
- *
- *     local variables:
- *             int     c               current assembler-source
- *                                     text character
- *             int     p               current operator priority
- *             area *  ap              pointer to an area structure
- *             exp     re              internal expr structure
- *
- *     global variables:
- *             char    ctype[]         array of character types, one per
- *                                     ASCII character
- *
- *     functions called:
- *             VOID    abscheck()      asexpr.c
- *             VOID    clrexpr()       asexpr.c
- *             VOID    expr()          asexpr.c
- *             int     getnb()         aslex.c
- *             int     oprio()         asexpr.c
- *             VOID    qerr()          assubr.c
- *             VOID    rerr()          assubr.c
- *             VOID    term()          asexpr.c
- *             VOID    unget()         aslex.c
- *
- *
- *     side effects:
- *             An expression is evaluated modifying the user supplied
- *             expr structure, a sym structure maybe created for an
- *             undefined symbol, and the parse of the expression may
- *             terminate if a 'q' error occurs.
+/*)Function     VOID    expr(esp, n)
+ *
+ *              expr *  esp             pointer to an expr structure
+ *              int     n               a firewall priority; all top
+ *                                      level calls (from the user)
+ *                                      should be made with n set to 0.
+ *
+ *      The function expr() evaluates an expression and
+ *      stores its value and relocation information into
+ *      the expr structure supplied by the user.
+ *
+ *      local variables:
+ *              int     c               current assembler-source
+ *                                      text character
+ *              int     p               current operator priority
+ *              area *  ap              pointer to an area structure
+ *              exp     re              internal expr structure
+ *
+ *      global variables:
+ *              char    ctype[]         array of character types, one per
+ *                                      ASCII character
+ *
+ *      functions called:
+ *              VOID    abscheck()      asexpr.c
+ *              VOID    clrexpr()       asexpr.c
+ *              VOID    expr()          asexpr.c
+ *              int     getnb()         aslex.c
+ *              int     oprio()         asexpr.c
+ *              VOID    qerr()          assubr.c
+ *              VOID    rerr()          assubr.c
+ *              VOID    term()          asexpr.c
+ *              VOID    unget()         aslex.c
+ *
+ *
+ *      side effects:
+ *              An expression is evaluated modifying the user supplied
+ *              expr structure, a sym structure maybe created for an
+ *              undefined symbol, and the parse of the expression may
+ *              terminate if a 'q' error occurs.
  */
 
 VOID
@@ -89,31 +89,31 @@ int n;
 
         term(esp);
         while (ctype[c = getnb()] & BINOP) {
-               /*
-                * Handle binary operators + - * / & | % ^ << >>
-                */
+                /*
+                 * Handle binary operators + - * / & | % ^ << >>
+                 */
                 if ((p = oprio(c)) <= n)
                         break;
                 if ((c == '>' || c == '<') && c != get())
                         qerr();
-               clrexpr(&re);
+                clrexpr(&re);
                 expr(&re, p);
-               esp->e_rlcf |= re.e_rlcf;
+                esp->e_rlcf |= re.e_rlcf;
                 if (c == '+') {
-                       /*
-                        * esp + re, at least one must be absolute
-                        */
+                        /*
+                         * esp + re, at least one must be absolute
+                         */
                         if (esp->e_base.e_ap == NULL) {
-                               /*
-                                * esp is absolute (constant),
-                                * use area from re
-                                */
+                                /*
+                                 * esp is absolute (constant),
+                                 * use area from re
+                                 */
                                 esp->e_base.e_ap = re.e_base.e_ap;
                         } else
                         if (re.e_base.e_ap) {
-                               /*
-                                * re should be absolute (constant)
-                                */
+                                /*
+                                 * re should be absolute (constant)
+                                 */
                                 rerr();
                         }
                         if (esp->e_flag && re.e_flag)
@@ -123,9 +123,9 @@ int n;
                         esp->e_addr += re.e_addr;
                 } else
                 if (c == '-') {
-                       /*
-                        * esp - re
-                        */
+                        /*
+                         * esp - re
+                         */
                         if ((ap = re.e_base.e_ap) != NULL) {
                                 if (esp->e_base.e_ap == ap) {
                                         esp->e_base.e_ap = NULL;
@@ -137,118 +137,118 @@ int n;
                                 rerr();
                         esp->e_addr -= re.e_addr;
                 } else {
-                       /*
-                        * Both operands (esp and re) must be constants
-                        */
-                   /* SD :- moved the abscheck to each case
-                      case and change the right shift operator.. if
-                      right shift by 8 bits of a relocatable address then
-                      the user wants the higher order byte. set the R_MSB
-                      for the expression */
+                        /*
+                         * Both operands (esp and re) must be constants
+                         */
+                    /* SD :- moved the abscheck to each case
+                       case and change the right shift operator.. if
+                       right shift by 8 bits of a relocatable address then
+                       the user wants the higher order byte. set the R_MSB
+                       for the expression */
                        switch (c) {
 
                         case '*':
-                           abscheck(esp);
-                           abscheck(&re);
-                           esp->e_addr *= re.e_addr;
-                           break;
+                            abscheck(esp);
+                            abscheck(&re);
+                            esp->e_addr *= re.e_addr;
+                            break;
 
                         case '/':
-                           abscheck(esp);
-                           abscheck(&re);                          
-                           esp->e_addr /= re.e_addr;
-                           break;
+                            abscheck(esp);
+                            abscheck(&re);
+                            esp->e_addr /= re.e_addr;
+                            break;
 
                         case '&':
-                           abscheck(esp);
-                           abscheck(&re);                          
-                           esp->e_addr &= re.e_addr;
-                           break;
+                            abscheck(esp);
+                            abscheck(&re);
+                            esp->e_addr &= re.e_addr;
+                            break;
 
                         case '|':
-                           abscheck(esp);
-                           abscheck(&re);                          
-                           esp->e_addr |= re.e_addr;
-                           break;
+                            abscheck(esp);
+                            abscheck(&re);
+                            esp->e_addr |= re.e_addr;
+                            break;
 
                         case '%':
-                           abscheck(esp);
-                           abscheck(&re);                          
-                           esp->e_addr %= re.e_addr;
-                           break;
+                            abscheck(esp);
+                            abscheck(&re);
+                            esp->e_addr %= re.e_addr;
+                            break;
 
                         case '^':
-                           abscheck(esp);
-                           abscheck(&re);                          
-                           esp->e_addr ^= re.e_addr;
-                           break;
+                            abscheck(esp);
+                            abscheck(&re);
+                            esp->e_addr ^= re.e_addr;
+                            break;
 
                         case '<':
-                           abscheck(esp);
-                           abscheck(&re);                          
-                           esp->e_addr <<= re.e_addr;
-                           break;
+                            abscheck(esp);
+                            abscheck(&re);
+                            esp->e_addr <<= re.e_addr;
+                            break;
 
                         case '>':
-                           /* SD change here */                           
-                           abscheck(&re);      
-                           /* if the left is a relative address &
-                              the right side is == 8 then */
-                           if (esp->e_base.e_ap && re.e_addr == 8) {
-                               esp->e_rlcf |= R_MSB ;
-                               break;
-                           }
-                           else if (esp->e_base.e_ap && re.e_addr == 16)
-                           {
-                               if (flat24Mode)
-                               {
-                                   esp->e_rlcf |= R_HIB;
-                               }
-                               else
-                               {
-                                   warnBanner();
-                                   fprintf(stderr, 
-                                           "(expr >> 16) is only meaningful in "
-                                           ".flat24 mode.\n");
-                                   qerr();
-                               }
-                                   
-                              break;
-                           }
-                           /* else continue with the normal processing */
-                           abscheck(esp);
-                           esp->e_addr >>= re.e_addr;
-                           break;
-                           
-                      default:
-                          qerr();
-                          break;
-                      }
+                            /* SD change here */
+                            abscheck(&re);
+                            /* if the left is a relative address &
+                               the right side is == 8 then */
+                            if (esp->e_base.e_ap && re.e_addr == 8) {
+                                esp->e_rlcf |= R_MSB ;
+                                break;
+                            }
+                            else if (esp->e_base.e_ap && re.e_addr == 16)
+                            {
+                                if (flat24Mode)
+                                {
+                                    esp->e_rlcf |= R_HIB;
+                                }
+                                else
+                                {
+                                    warnBanner();
+                                    fprintf(stderr,
+                                            "(expr >> 16) is only meaningful in "
+                                            ".flat24 mode.\n");
+                                    qerr();
+                                }
+
+                               break;
+                            }
+                            /* else continue with the normal processing */
+                            abscheck(esp);
+                            esp->e_addr >>= re.e_addr;
+                            break;
+
+                       default:
+                           qerr();
+                           break;
+                       }
                 }
         }
         unget(c);
 }
 
-/*)Function    Addr_T  absexpr()
+/*)Function     Addr_T  absexpr()
  *
- *     The function absexpr() evaluates an expression, verifies it
- *     is absolute (i.e. not position dependent or relocatable), and
- *     returns its value.
+ *      The function absexpr() evaluates an expression, verifies it
+ *      is absolute (i.e. not position dependent or relocatable), and
+ *      returns its value.
  *
- *     local variables:
- *             expr    e               expr structure
+ *      local variables:
+ *              expr    e               expr structure
  *
- *     global variables:
- *             none
+ *      global variables:
+ *              none
  *
- *     functions called:
- *             VOID    abscheck()      asexpr.c
- *             VOID    clrexpr()       asexpr.c
- *             VOID    expr()          asexpr.c
+ *      functions called:
+ *              VOID    abscheck()      asexpr.c
+ *              VOID    clrexpr()       asexpr.c
+ *              VOID    expr()          asexpr.c
  *
- *     side effects:
- *             If the expression is not absolute then
- *             a 'r' error is reported.
+ *      side effects:
+ *              If the expression is not absolute then
+ *              a 'r' error is reported.
  */
 
 Addr_T
@@ -256,55 +256,55 @@ absexpr()
 {
         struct expr e;
 
-       clrexpr(&e);
-       expr(&e, 0);
-       abscheck(&e);
-       return (e.e_addr);
+        clrexpr(&e);
+        expr(&e, 0);
+        abscheck(&e);
+        return (e.e_addr);
 }
 
-/*)Function    VOID    term(esp)
- *
- *             expr *  esp             pointer to an expr structure
- *
- *     The function term() evaluates a single constant
- *     or symbol value prefaced by any unary operator
- *     ( +, -, ~, ', ", >, or < ).  This routine is also
- *     responsible for setting the relocation type to symbol
- *     based (e.flag != 0) on global references.
- *
- *     local variables:
- *             int     c               current character
- *             char    id[]            symbol name
- *             char *  jp              pointer to assembler-source text
- *             int     n               constant evaluation running sum
- *             int     r               current evaluation radix
- *             sym *   sp              pointer to a sym structure
- *             tsym *  tp              pointer to a tsym structure
- *             int     v               current digit evaluation
- *
- *     global variables:
- *             char    ctype[]         array of character types, one per
- *                                     ASCII character
- *             sym *   symp            pointer to a symbol structure
- *
- *     functions called:
- *             VOID    abscheck()      asexpr.c
- *             int     digit()         asexpr.c
- *             VOID    err()           assubr.c
- *             VOID    expr()          asexpr.c
- *             int     is_abs()        asexpr.c
- *             int     get()           aslex.c
- *             VOID    getid()         aslex.c
- *             int     getmap()        aslex.c
- *             int     getnb()         aslex.c
- *             sym *   lookup()        assym.c
- *             VOID    qerr()          assubr.c
- *             VOID    unget()         aslex.c
- *
- *     side effects:
- *             An arithmetic term is evaluated, a symbol structure
- *             may be created, term evaluation may be terminated
- *             by a 'q' error.
+/*)Function     VOID    term(esp)
+ *
+ *              expr *  esp             pointer to an expr structure
+ *
+ *      The function term() evaluates a single constant
+ *      or symbol value prefaced by any unary operator
+ *      ( +, -, ~, ', ", >, or < ).  This routine is also
+ *      responsible for setting the relocation type to symbol
+ *      based (e.flag != 0) on global references.
+ *
+ *      local variables:
+ *              int     c               current character
+ *              char    id[]            symbol name
+ *              char *  jp              pointer to assembler-source text
+ *              int     n               constant evaluation running sum
+ *              int     r               current evaluation radix
+ *              sym *   sp              pointer to a sym structure
+ *              tsym *  tp              pointer to a tsym structure
+ *              int     v               current digit evaluation
+ *
+ *      global variables:
+ *              char    ctype[]         array of character types, one per
+ *                                      ASCII character
+ *              sym *   symp            pointer to a symbol structure
+ *
+ *      functions called:
+ *              VOID    abscheck()      asexpr.c
+ *              int     digit()         asexpr.c
+ *              VOID    err()           assubr.c
+ *              VOID    expr()          asexpr.c
+ *              int     is_abs()        asexpr.c
+ *              int     get()           aslex.c
+ *              VOID    getid()         aslex.c
+ *              int     getmap()        aslex.c
+ *              int     getnb()         aslex.c
+ *              sym *   lookup()        assym.c
+ *              VOID    qerr()          assubr.c
+ *              VOID    unget()         aslex.c
+ *
+ *      side effects:
+ *              An arithmetic term is evaluated, a symbol structure
+ *              may be created, term evaluation may be terminated
+ *              by a 'q' error.
  */
 
 VOID
@@ -312,23 +312,23 @@ term(esp)
 register struct expr *esp;
 {
         register int c, n;
-        register char *jp;
+        register const char *jp;
         char id[NCPS];
         struct sym  *sp;
         struct tsym *tp;
         int r=0, v;
 
         c = getnb();
-       /*
-        * Discard the unary '+' at this point and
-        * also any reference to numerical arguments
-        * associated with the '#' prefix.
-        */
+        /*
+         * Discard the unary '+' at this point and
+         * also any reference to numerical arguments
+         * associated with the '#' prefix.
+         */
         while (c == '+' || c == '#') { c = getnb(); }
-       /*
-        * Evaluate all binary operators
-        * by recursively calling expr().
-        */
+        /*
+         * Evaluate all binary operators
+         * by recursively calling expr().
+         */
         if (c == LFTERM) {
                 expr(esp, 0);
                 if (getnb() != RTTERM)
@@ -365,28 +365,28 @@ register struct expr *esp;
         }
         if (c == '>' || c == '<') {
                 expr(esp, 100);
-               if (is_abs (esp)) {
-                       /*
-                        * evaluate msb/lsb directly
-                        */
-                       if (c == '>')
-                               esp->e_addr >>= 8;
-                       esp->e_addr &= 0377;
-                       return;
-               } else {
-                       /*
-                        * let linker perform msb/lsb, lsb is default
-                        */
-                       esp->e_rlcf |= R_BYT2;
-                       if (c == '>')
-                               esp->e_rlcf |= R_MSB;
-                       return;
-               }
+                if (is_abs (esp)) {
+                        /*
+                         * evaluate msb/lsb directly
+                         */
+                        if (c == '>')
+                                esp->e_addr >>= 8;
+                        esp->e_addr &= 0377;
+                        return;
+                } else {
+                        /*
+                         * let linker perform msb/lsb, lsb is default
+                         */
+                        esp->e_rlcf |= R_BYT2;
+                        if (c == '>')
+                                esp->e_rlcf |= R_MSB;
+                        return;
+                }
         }
-       /*
-        * Evaluate digit sequences as local symbols
-        * if followed by a '$' or as constants.
-        */
+        /*
+         * Evaluate digit sequences as local symbols
+         * if followed by a '$' or as constants.
+         */
         if (ctype[c] & DIGIT) {
                 esp->e_mode = S_USER;
                 jp = ip;
@@ -452,58 +452,58 @@ register struct expr *esp;
                 esp->e_addr = n;
                 return;
         }
-       /*
-        * Evaluate '$' sequences as a temporary radix
-        * if followed by a '%', '&', '#', or '$'.
-        */
+        /*
+         * Evaluate '$' sequences as a temporary radix
+         * if followed by a '%', '&', '#', or '$'.
+         */
         if (c == '$') {
                 c = get();
                 if (c == '%' || c == '&' || c == '#' || c == '$') {
-                       switch (c) {
-                               case '%':
-                                       r = 2;
-                                       break;
-                               case '&':
-                                       r = 8;
-                                       break;
-                               case '#':
-                                       r = 10;
-                                       break;
-                               case '$':
-                                       r = 16;                         
-                                       break;
-                               default:
-                                       break;
-                       }
-                       c = get();
-                       n = 0;
-                       while ((v = digit(c, r)) >= 0) {
-                               n = r*n + v;
-                               c = get();
-                       }
-                       unget(c);
-                       esp->e_mode = S_USER;
-                       esp->e_addr = n;
-                       return;
-               }
-               unget(c);
-               c = '$';
+                        switch (c) {
+                                case '%':
+                                        r = 2;
+                                        break;
+                                case '&':
+                                        r = 8;
+                                        break;
+                                case '#':
+                                        r = 10;
+                                        break;
+                                case '$':
+                                        r = 16;
+                                        break;
+                                default:
+                                        break;
+                        }
+                        c = get();
+                        n = 0;
+                        while ((v = digit(c, r)) >= 0) {
+                                n = r*n + v;
+                                c = get();
+                        }
+                        unget(c);
+                        esp->e_mode = S_USER;
+                        esp->e_addr = n;
+                        return;
+                }
+                unget(c);
+                c = '$';
         }
-       /*
-        * Evaluate symbols and labels
-        */
+        /*
+         * Evaluate symbols and labels
+         */
         if (ctype[c] & LETTER) {
                 esp->e_mode = S_USER;
                 getid(id, c);
                 sp = lookup(id);
                 if (sp->s_type == S_NEW) {
                         esp->e_addr = 0;
-                       if (sp->s_flag&S_GBL) {
-                               esp->e_flag = 1;
-                               esp->e_base.e_sp = sp;
-                               return;
-                       }
-                       /* err('u'); */
+                        if (sp->s_flag&S_GBL) {
+                                esp->e_flag = 1;
+                                esp->e_base.e_sp = sp;
+                                return;
+                        }
+                        /* err('u'); */
                 } else {
                         esp->e_mode = sp->s_type;
                         esp->e_addr = sp->s_addr;
@@ -511,33 +511,33 @@ register struct expr *esp;
                 }
                 return;
         }
-       /*
-        * Else not a term.
-        */
+        /*
+         * Else not a term.
+         */
         qerr();
 }
 
-/*)Function    int     digit(c, r)
+/*)Function     int     digit(c, r)
  *
- *             int     c               digit character
- *             int     r               current radix
+ *              int     c               digit character
+ *              int     r               current radix
  *
- *     The function digit() returns the value of c
- *     in the current radix r.  If the c value is not
- *     a number of the current radix then a -1 is returned.
+ *      The function digit() returns the value of c
+ *      in the current radix r.  If the c value is not
+ *      a number of the current radix then a -1 is returned.
  *
- *     local variables:
- *             none
+ *      local variables:
+ *              none
  *
- *     global variables:
- *             char    ctype[]         array of character types, one per
- *                                     ASCII character
+ *      global variables:
+ *              char    ctype[]         array of character types, one per
+ *                                      ASCII character
  *
- *     functions called:
- *             none
+ *      functions called:
+ *              none
  *
- *     side effects:
- *             none
+ *      side effects:
+ *              none
  */
 
 int
@@ -568,31 +568,31 @@ register int c, r;
         return (-1);
 }
 
-/*)Function    VOID    abscheck(esp)
+/*)Function     VOID    abscheck(esp)
  *
- *             expr *  esp             pointer to an expr structure
+ *              expr *  esp             pointer to an expr structure
  *
- *     The function abscheck() tests the evaluation of an
- *     expression to verify it is absolute.  If the evaluation
- *     is relocatable then an 'r' error is noted and the expression
- *     made absolute.
+ *      The function abscheck() tests the evaluation of an
+ *      expression to verify it is absolute.  If the evaluation
+ *      is relocatable then an 'r' error is noted and the expression
+ *      made absolute.
  *
- *     Note:   The area type (i.e. ABS) is not checked because
- *             the linker can be told to explicitly relocate an
- *             absolute area.
+ *      Note:   The area type (i.e. ABS) is not checked because
+ *              the linker can be told to explicitly relocate an
+ *              absolute area.
  *
- *     local variables:
- *             none
+ *      local variables:
+ *              none
  *
- *     global variables:
- *             none
+ *      global variables:
+ *              none
  *
- *     functions called:
- *             VOID    rerr()          assubr.c
+ *      functions called:
+ *              VOID    rerr()          assubr.c
  *
- *     side effects:
- *             The expression may be changed to absolute and the
- *             'r' error invoked.
+ *      side effects:
+ *              The expression may be changed to absolute and the
+ *              'r' error invoked.
  */
 
 VOID
@@ -606,29 +606,29 @@ register struct expr *esp;
         }
 }
 
-/*)Function    int     is_abs(esp)
+/*)Function     int     is_abs(esp)
  *
- *             expr *  esp             pointer to an expr structure
+ *              expr *  esp             pointer to an expr structure
  *
- *     The function is_abs() tests the evaluation of an
- *     expression to verify it is absolute.  If the evaluation
- *     is absolute then 1 is returned, else 0 is returned.
+ *      The function is_abs() tests the evaluation of an
+ *      expression to verify it is absolute.  If the evaluation
+ *      is absolute then 1 is returned, else 0 is returned.
  *
- *     Note:   The area type (i.e. ABS) is not checked because
- *             the linker can be told to explicitly relocate an
- *             absolute area.
+ *      Note:   The area type (i.e. ABS) is not checked because
+ *              the linker can be told to explicitly relocate an
+ *              absolute area.
  *
- *     local variables:
- *             none
+ *      local variables:
+ *              none
  *
- *     global variables:
- *             none
+ *      global variables:
+ *              none
  *
- *     functions called:
- *             none
+ *      functions called:
+ *              none
  *
- *     side effects:
- *             none
+ *      side effects:
+ *              none
  */
 
 int
@@ -636,31 +636,31 @@ is_abs (esp)
 register struct expr *esp;
 {
         if (esp->e_flag || esp->e_base.e_ap) {
-               return(0);
+                return(0);
         }
-       return(1);
+        return(1);
 }
 
-/*)Function    int     oprio(c)
+/*)Function     int     oprio(c)
  *
- *             int     c               operator character
+ *              int     c               operator character
  *
- *     The function oprio() returns a relative priority
- *     for all valid unary and binary operators.
+ *      The function oprio() returns a relative priority
+ *      for all valid unary and binary operators.
  *
- *     local variables:
- *             none
+ *      local variables:
+ *              none
  *
- *     global variables:
- *             none
+ *      global variables:
+ *              none
  *
- *     functions called:
- *             none
+ *      functions called:
+ *              none
  *
- *     side effects:
- *             none
+ *      side effects:
+ *              none
  */
+
 int
 oprio(c)
 register int c;
@@ -680,32 +680,32 @@ register int c;
         return (0);
 }
 
-/*)Function    VOID    clrexpr(esp)
+/*)Function     VOID    clrexpr(esp)
  *
- *             expr *  esp             pointer to expression structure
+ *              expr *  esp             pointer to expression structure
  *
- *     The function clrexpr() clears the expression structure.
+ *      The function clrexpr() clears the expression structure.
  *
- *     local variables:
- *             none
+ *      local variables:
+ *              none
  *
- *     global variables:
- *             none
+ *      global variables:
+ *              none
  *
- *     functions called:
- *             none
+ *      functions called:
+ *              none
  *
- *     side effects:
- *             expression structure cleared.
+ *      side effects:
+ *              expression structure cleared.
  */
+
 VOID
 clrexpr(esp)
 register struct expr *esp;
 {
-       esp->e_mode = 0;
-       esp->e_flag = 0;
-       esp->e_addr = 0;
-       esp->e_base.e_ap = NULL;
-       esp->e_rlcf = 0;
+        esp->e_mode = 0;
+        esp->e_flag = 0;
+        esp->e_addr = 0;
+        esp->e_base.e_ap = NULL;
+        esp->e_rlcf = 0;
 }
index 17e31dc63249dbc7695bb45bfb200e5da1f5558d..f6f44dbab0073611eb105dbb83481306c0fb8f7a 100644 (file)
@@ -465,10 +465,10 @@ extern  char    *ep;            /*      pointer into error list
                                  */
 extern  char    eb[NERR];       /*      array of generated error codes
                                  */
-extern  char    *ip;            /*      pointer into the assembler-source
+extern  const char *ip;         /*      pointer into the assembler-source
                                  *      text line in ib[]
                                  */
-extern  char    ib[NINPUT];     /*      assembler-source text line
+extern  const char *ib;         /*      assembler-source text line
                                  */
 extern  char    *cp;            /*      pointer to assembler output
                                  *      array cb[]
index 61e10b4c152f7f4e5c4991b6fd2bf6fe928e4575..aa904650f70cf8b1b74119862c800f7c93c8e1e7 100644 (file)
@@ -18,114 +18,114 @@ int
 addr(esp)
 register struct expr *esp;
 {
-       register int c;
-       register struct area *espa;
-       register Addr_T espv;
-       char *tcp;
-
-       if ((c = getnb()) == '#') {
-               expr(esp, 0);
-               esp->e_mode = S_IMMED;
-       } else if (c == ',') {
-               switch(admode(axs)) {
-               default:
-                       aerr();
-
-               case S_X:
-                       c = S_IX;
-                       break;
-
-               case S_S:
-                       c = S_IS;
-                       break;
-
-               case S_XP:
-                       c = S_IXP;
-                       break;
-               }
-               esp->e_mode = c;
-       } else if (c == '*') {
-               expr(esp, 0);
-               esp->e_mode = S_DIR;
-               if (esp->e_addr & ~0xFF)
-                       err('d');
-               if (more()) {
-                       comma();
-                       tcp = ip;
-                       switch(admode(axs)) {
-                       case S_X:
-                               esp->e_mode = S_IX1;
-                               break;
-
-                       case S_S:
-                               esp->e_mode = S_SP1;
-                               break;
-
-                       case S_XP:
-                               esp->e_mode = S_IX1P;
-                               break;
-
-                       default:
-                               ip = --tcp;
-                       }
-               }
-       } else {
-               unget(c);
-               if ((esp->e_mode = admode(axs)) != 0) {
-                       ;
-               } else {
-                       expr(esp, 0);
-                       espa = esp->e_base.e_ap;
-                       espv = esp->e_addr;
-                       if (more()) {
-                               comma();
-                               c = admode(axs);
-                               if (esp->e_flag == 0 &&
-                                   espa == NULL &&
-                                   (espv & ~0xFF) == 0) {
-                                       switch(c) {
-                                       default:
-                                               aerr();
-
-                                       case S_X:
-                                               c = S_IX1;
-                                               break;
-
-                                       case S_S:
-                                               c = S_SP1;
-                                               break;
-
-                                       case S_XP:
-                                               c = S_IX1P;
-                                               break;
-                                       }
-                               } else {
-                                       switch(c) {
-                                       default:
-                                               aerr();
-
-                                       case S_X:
-                                               c = S_IX2;
-                                               break;
-
-                                       case S_S:
-                                               c = S_SP2;
-                                               break;
-
-                                       case S_XP:
-                                               c = S_IX2P;
-                                               break;
-                                       }
-                               }
-                               esp->e_mode = c;
-                       } else {
-                               esp->e_mode = S_EXT;
-                       }
-               }
-       }
-       return (esp->e_mode);
+        register int c;
+        register struct area *espa;
+        register Addr_T espv;
+        const char *tcp;
+
+        if ((c = getnb()) == '#') {
+                expr(esp, 0);
+                esp->e_mode = S_IMMED;
+        } else if (c == ',') {
+                switch(admode(axs)) {
+                default:
+                        aerr();
+
+                case S_X:
+                        c = S_IX;
+                        break;
+
+                case S_S:
+                        c = S_IS;
+                        break;
+
+                case S_XP:
+                        c = S_IXP;
+                        break;
+                }
+                esp->e_mode = c;
+        } else if (c == '*') {
+                expr(esp, 0);
+                esp->e_mode = S_DIR;
+                if (esp->e_addr & ~0xFF)
+                        err('d');
+                if (more()) {
+                        comma();
+                        tcp = ip;
+                        switch(admode(axs)) {
+                        case S_X:
+                                esp->e_mode = S_IX1;
+                                break;
+
+                        case S_S:
+                                esp->e_mode = S_SP1;
+                                break;
+
+                        case S_XP:
+                                esp->e_mode = S_IX1P;
+                                break;
+
+                        default:
+                                ip = --tcp;
+                        }
+                }
+        } else {
+                unget(c);
+                if ((esp->e_mode = admode(axs)) != 0) {
+                        ;
+                } else {
+                        expr(esp, 0);
+                        espa = esp->e_base.e_ap;
+                        espv = esp->e_addr;
+                        if (more()) {
+                                comma();
+                                c = admode(axs);
+                                if (esp->e_flag == 0 &&
+                                    espa == NULL &&
+                                    (espv & ~0xFF) == 0) {
+                                        switch(c) {
+                                        default:
+                                                aerr();
+
+                                        case S_X:
+                                                c = S_IX1;
+                                                break;
+
+                                        case S_S:
+                                                c = S_SP1;
+                                                break;
+
+                                        case S_XP:
+                                                c = S_IX1P;
+                                                break;
+                                        }
+                                } else {
+                                        switch(c) {
+                                        default:
+                                                aerr();
+
+                                        case S_X:
+                                                c = S_IX2;
+                                                break;
+
+                                        case S_S:
+                                                c = S_SP2;
+                                                break;
+
+                                        case S_XP:
+                                                c = S_IX2P;
+                                                break;
+                                        }
+                                }
+                                esp->e_mode = c;
+                        } else {
+                                esp->e_mode = S_EXT;
+                        }
+                }
+        }
+        return (esp->e_mode);
 }
-       
+
 /*
  * Enter admode() to search a specific addressing mode table
  * for a match. Return the addressing value on a match or
@@ -135,22 +135,22 @@ int
 admode(sp)
 register struct adsym *sp;
 {
-       register char *ptr;
-       register int i;
-       register char *ips;
-
-       ips = ip;
-       unget(getnb());
-
-       i = 0;
-       while ( *(ptr = &sp[i].a_str[0]) ) {
-               if (srch(ptr)) {
-                       return(sp[i].a_val);
-               }
-               i++;
-       }
-       ip = ips;
-       return(0);
+        register char *ptr;
+        register int i;
+        register const char *ips;
+
+        ips = ip;
+        unget(getnb());
+
+        i = 0;
+        while ( *(ptr = &sp[i].a_str[0]) ) {
+                if (srch(ptr)) {
+                        return(sp[i].a_val);
+                }
+                i++;
+        }
+        ip = ips;
+        return(0);
 }
 
 /*
@@ -160,26 +160,26 @@ int
 srch(str)
 register char *str;
 {
-       register char *ptr;
-       ptr = ip;
-
-       while (*ptr && *str) {
-               if(ccase[*ptr & 0x007F] != ccase[*str & 0x007F])
-                       break;
-               ptr++;
-               str++;
-       }
-       if (ccase[*ptr & 0x007F] == ccase[*str & 0x007F]) {
-               ip = ptr;
-               return(1);
-       }
-
-       if (!*str)
-               if (any(*ptr," \t\n,];")) {
-                       ip = ptr;
-                       return(1);
-               }
-       return(0);
+        register const char *ptr;
+        ptr = ip;
+
+        while (*ptr && *str) {
+                if(ccase[*ptr & 0x007F] != ccase[*str & 0x007F])
+                        break;
+                ptr++;
+                str++;
+        }
+        if (ccase[*ptr & 0x007F] == ccase[*str & 0x007F]) {
+                ip = ptr;
+                return(1);
+        }
+
+        if (!*str)
+                if (any(*ptr," \t\n,];")) {
+                        ip = ptr;
+                        return(1);
+                }
+        return(0);
 }
 
 /*
@@ -190,16 +190,16 @@ any(c,str)
 int c;
 char*str;
 {
-       while (*str)
-               if(*str++ == c)
-                       return(1);
-       return(0);
+        while (*str)
+                if(*str++ == c)
+                        return(1);
+        return(0);
 }
 
-struct adsym   axs[] = {       /* a, x, or s registers */
-    {  "a",    S_A     },
-    {  "x",    S_X     },
-    {  "s",    S_S     },
-    {  "x+",   S_XP    },
-    {  "",     0x00    }
+struct adsym    axs[] = {       /* a, x, or s registers */
+    {   "a",    S_A     },
+    {   "x",    S_X     },
+    {   "s",    S_S     },
+    {   "x+",   S_XP    },
+    {   "",     0x00    }
 };
index 825a7a3bfcadd6130748f2f52d2a52283931ff32..a2a2f1c61eb880f68fe5856d69faabb2d196ed4e 100644 (file)
@@ -7,7 +7,8 @@ PRJDIR          = ../..
 ASOBJECTS       = asmain.obj aslex.obj assubr.obj asnoice.obj \
                   asexpr.obj asdata.obj aslist.obj asout.obj \
                   i51ext.obj i51pst.obj i51mch.obj i51adr.obj \
-                  ../asxxsrc/strcmpi.obj ../asxxsrc/assym.obj
+                  ../asxxsrc/strcmpi.obj ../asxxsrc/assym.obj \
+                  ../../support/Util/dbuf.obj ../../support/Util/dbuf_string.obj
 
 ASX8051         = $(PRJDIR)/bin/asx8051.exe
 
index 279c5deb630021f70a3f8d351bea435c3b3af6b4..393d25f99f3474a67cabf18e94842ee319feb4ce 100644 (file)
@@ -40,19 +40,22 @@ LDFLAGS         = @LDFLAGS@
 
 OBJDIR = obj
 
-ASXXLIB = $(srcdir)/../asxxsrc
+UTILLIB = $(srcdir)/../../support/Util
+UTILSRC = dbuf.c dbuf_string.c
+UTILLIBOBJS = $(UTILSRC:%.c=$(OBJDIR)/%.o)
 
+ASXXLIB = $(srcdir)/../asxxsrc
 ASXXLIBSRC = strcmpi.c assym.c aslex.c
+ASXXLIBOBJS = $(ASXXLIBSRC:%.c=$(OBJDIR)/%.o)
 
 SRC = asmain.c assubr.c asnoice.c \
       asexpr.c asdata.c aslist.c asout.c \
       i51ext.c i51pst.c i51mch.c i51adr.c
-
-ASSOURCES = %(SRC) $(ASXXLIBSRC:%.c=$(ASXXLIB)/%.c)
-                  
 OBJS = $(SRC:%.c=$(OBJDIR)/%.o)
-ASXXLIBOBJS = $(ASXXLIBSRC:%.c=$(OBJDIR)/%.o)
-ASOBJECTS = $(OBJS) $(ASXXLIBOBJS)
+
+ASSOURCES = %(SRC) $(ASXXLIBSRC:%.c=$(ASXXLIB)/%.c) $(UTILSRC:%.c=$(UTILLIB)/%.c)
+
+AASOBJECTS = $(OBJS) $(ASXXLIBOBJS) $(UTILLIBOBJS)
 
 ASX8051 = $(top_builddir)/bin/asx8051$(EXEEXT)
 
index be5dd3d60aa4f5f7cdba78ab419b291a72e76ce5..4a9dfdc01ba71381eca3e734cbed5cb29b953787 100644 (file)
@@ -109,10 +109,10 @@ char    *ep;                    /*      pointer into error list
                                  */
 char    eb[NERR];               /*      array of generated error codes
                                  */
-char    *ip;                    /*      pointer into the assembler-source
+const char *ip;                 /*      pointer into the assembler-source
                                  *      text line in ib[]
                                  */
-char    ib[NINPUT];             /*      assembler-source text line
+const char *ib;                 /*      assembler-source text line
                                  */
 char    *cp;                    /*      pointer to assembler output
                                  *      array cb[]
index 4bef55948427a1de54690abb81d8efd427ac4094..a424d144b45eb38dbb8e30f90090cd297dbb09ec 100644 (file)
@@ -324,7 +324,7 @@ VOID
 term(register struct expr *esp)
 {
         register int c, n;
-        register char *jp;
+        register const char *jp;
         char id[NCPS];
         struct sym  *sp;
         struct tsym *tp;
index 6ef17d3a282c648e25abebe0ba8c883bef52d725..ac98e3addb43a44aad4aa8048cd5bc28718a1cc7 100644 (file)
@@ -480,10 +480,10 @@ extern  char    *ep;                    /*      pointer into error list
                                          */
 extern  char    eb[NERR];               /*      array of generated error codes
                                          */
-extern  char    *ip;                    /*      pointer into the assembler-source
+extern  const char *ip;                 /*      pointer into the assembler-source
                                          *      text line in ib[]
                                          */
-extern  char    ib[NINPUT];             /*      assembler-source text line
+extern  const char *ib;                 /*      assembler-source text line
                                          */
 extern  char    *cp;                    /*      pointer to assembler output
                                          *      array cb[]
index 5b40ddb9960696b45aa9369cfc179eb54019395c..fdd57547ba9365a7f4339cd13b803722ae005a49 100644 (file)
@@ -42,7 +42,7 @@ RSC=rc.exe
 # PROP Ignore_Export_Lib 0\r
 # PROP Target_Dir ""\r
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /FR /FD /GZ /c\r
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /FR /FD /GZ /c\r
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "." /I "../../support/Util" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /FR /FD /GZ /c\r
 # ADD BASE RSC /l 0x409 /d "_DEBUG"\r
 # ADD RSC /l 0x409 /d "_DEBUG"\r
 BSC32=bscmake.exe\r
@@ -67,7 +67,7 @@ LINK32=link.exe
 # PROP Ignore_Export_Lib 0\r
 # PROP Target_Dir ""\r
 # ADD BASE CPP /nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /FD /c\r
-# ADD CPP /nologo /ML /W3 /GX /O2 /I "." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /FD /c\r
+# ADD CPP /nologo /ML /W3 /GX /O2 /I "." /I "../../support/Util" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /FD /c\r
 # ADD BASE RSC /l 0x409 /d "NDEBUG"\r
 # ADD RSC /l 0x409 /d "NDEBUG"\r
 BSC32=bscmake.exe\r
@@ -124,6 +124,14 @@ SOURCE=..\asxxsrc\assym.c
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=..\..\support\Util\dbuf.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\support\Util\dbuf_string.c\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\i51adr.c\r
 # End Source File\r
 # Begin Source File\r
@@ -152,8 +160,20 @@ SOURCE=.\asm.h
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=..\..\support\Util\dbuf.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\support\Util\dbuf_string.h\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\i8051.h\r
 # End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\sdcc_vc.h\r
+# End Source File\r
 # End Group\r
 # End Target\r
 # End Project\r
index 62ef33dc5fbe4a0090ea178a30c3d83f15f2c612..3657d3c4980b689cdb5f6643dca1c6342d28dafc 100644 (file)
 
 extern int admode (struct adsym *);
 
-struct adsym reg51[] = {       /* R0 thru R7 registers */
-{      "R0",   R0},
-{      "R1",   R1},
-{      "R2",   R2},
-{      "R3",   R3},
-{      "R4",   R4},
-{      "R5",   R5},
-{      "R6",   R6},
-{      "R7",   R7},
-{      "A",    A},
-{      "DPTR", DPTR},
-{      "PC",   PC},
-{      "C",    C},
-{      "AB",   AB},
-{      "r0",   R0},
-{      "r1",   R1},
-{      "r2",   R2},
-{      "r3",   R3},
-{      "r4",   R4},
-{      "r5",   R5},
-{      "r6",   R6},
-{      "r7",   R7},
-{      "a",    A},
-{      "dptr", DPTR},
-{      "pc",   PC},
-{      "c",    C},
-{      "ab",   AB},
-{      "",     0x00}
+struct adsym reg51[] = {        /* R0 thru R7 registers */
+{       "R0",   R0},
+{       "R1",   R1},
+{       "R2",   R2},
+{       "R3",   R3},
+{       "R4",   R4},
+{       "R5",   R5},
+{       "R6",   R6},
+{       "R7",   R7},
+{       "A",    A},
+{       "DPTR", DPTR},
+{       "PC",   PC},
+{       "C",    C},
+{       "AB",   AB},
+{       "r0",   R0},
+{       "r1",   R1},
+{       "r2",   R2},
+{       "r3",   R3},
+{       "r4",   R4},
+{       "r5",   R5},
+{       "r6",   R6},
+{       "r7",   R7},
+{       "a",    A},
+{       "dptr", DPTR},
+{       "pc",   PC},
+{       "c",    C},
+{       "ab",   AB},
+{       "",     0x00}
 };
 
 /*  Classify argument as to address mode */
@@ -54,91 +54,91 @@ int
 addr(esp)
 register struct expr *esp;
 {
-       register int c;
+        register int c;
         register unsigned rd;
 
-       if ((c = getnb()) == '#') {
-               /*  Immediate mode */
-               expr(esp, 0);
-               esp->e_mode = S_IMMED;
-       } 
+        if ((c = getnb()) == '#') {
+                /*  Immediate mode */
+                expr(esp, 0);
+                esp->e_mode = S_IMMED;
+        }
         else if (c == '@') {
-               /* choices are @R0, @R1, @DPTR, @A+PC, @A+DPTR */
-               switch (reg()) {
+                /* choices are @R0, @R1, @DPTR, @A+PC, @A+DPTR */
+                switch (reg()) {
                 case R0:
-                       esp->e_mode = S_AT_R;
-                       esp->e_addr = R0;
+                        esp->e_mode = S_AT_R;
+                        esp->e_addr = R0;
                         break;
                 case R1:
-                       esp->e_mode = S_AT_R;
-                       esp->e_addr = R1;
+                        esp->e_mode = S_AT_R;
+                        esp->e_addr = R1;
                         break;
                 case DPTR:
-                       esp->e_mode = S_AT_DP;
-                       esp->e_addr = DPTR;
+                        esp->e_mode = S_AT_DP;
+                        esp->e_addr = DPTR;
                         break;
                 case A:
-                       if (getnb() == '+') {
-                               rd = reg();
+                        if (getnb() == '+') {
+                                rd = reg();
                                 if (rd == PC) {
-                                       esp->e_mode = S_AT_APC;
-                                       esp->e_addr = 0;
-                               } else if (rd == DPTR) {
-                                       esp->e_mode = S_AT_ADP;
-                                       esp->e_addr = 0;
-                               } else {
-                                       aerr();
+                                        esp->e_mode = S_AT_APC;
+                                        esp->e_addr = 0;
+                                } else if (rd == DPTR) {
+                                        esp->e_mode = S_AT_ADP;
+                                        esp->e_addr = 0;
+                                } else {
+                                        aerr();
                                 }
                         } else
-                               aerr();
+                                aerr();
                         break;
                 }
 
-               esp->e_flag = 0;
-               esp->e_base.e_ap = NULL;
-       } 
+                esp->e_flag = 0;
+                esp->e_base.e_ap = NULL;
+        }
         else if (c == '*') {
-               /* Force direct page */
-               expr(esp, 0);
-               esp->e_mode = S_DIR;
-               if (esp->e_addr & ~0xFF)
-                       err('d');
-       } 
+                /* Force direct page */
+                expr(esp, 0);
+                esp->e_mode = S_DIR;
+                if (esp->e_addr & ~0xFF)
+                        err('d');
+        }
         else if (c == '/') {
-               /* Force inverted bit  */
-               expr(esp, 0);
-               esp->e_mode = S_NOT_BIT;
-               if (esp->e_addr & ~0xFF)
-                       err('d');
-       } 
+                /* Force inverted bit  */
+                expr(esp, 0);
+                esp->e_mode = S_NOT_BIT;
+                if (esp->e_addr & ~0xFF)
+                        err('d');
+        }
         else {
-               unget(c);
+                unget(c);
 
-               /* try for register: A, AB, R0-R7, DPTR, PC, Cy */
-               if ((esp->e_addr = admode(reg51)) != -1) {
-                       switch (esp->e_addr) {
+                /* try for register: A, AB, R0-R7, DPTR, PC, Cy */
+                if ((esp->e_addr = admode(reg51)) != -1) {
+                        switch (esp->e_addr) {
                         case A:
-                               esp->e_mode = S_A;
+                                esp->e_mode = S_A;
                                 break;
                         case AB:
-                               esp->e_mode = S_RAB;
+                                esp->e_mode = S_RAB;
                                 break;
                         case DPTR:
-                               esp->e_mode = S_DPTR;
+                                esp->e_mode = S_DPTR;
                                 break;
                         case PC:
-                               esp->e_mode = S_PC;
+                                esp->e_mode = S_PC;
                                 break;
                         case C:
-                               esp->e_mode = S_C;
+                                esp->e_mode = S_C;
                                 break;
-                       default:
-                               /* R0-R7 */
-                               esp->e_mode = S_REG;
+                        default:
+                                /* R0-R7 */
+                                esp->e_mode = S_REG;
                         }
-               } else {
-                       /* Must be an expression */
-                       expr(esp, 0);
+                } else {
+                        /* Must be an expression */
+                        expr(esp, 0);
                         if ((!esp->e_flag)
                                 && (esp->e_base.e_ap==NULL)
                                 && !(esp->e_addr & ~0xFF)) {
@@ -146,9 +146,9 @@ register struct expr *esp;
                         } else {
                                 esp->e_mode = S_EXT;
                         }
-               }
-       }
-       return (esp->e_mode);
+                }
+        }
+        return (esp->e_mode);
 }
 
 
@@ -159,51 +159,51 @@ int
 any(c,str)
 char    c, *str;
 {
-       while (*str)
-               if(*str++ == c)
-                       return(1);
-       return(0);
+        while (*str)
+                if(*str++ == c)
+                        return(1);
+        return(0);
 }
 
 int
 srch(str)
 register char *str;
 {
-       register char *ptr;
-       ptr = ip;
+        register const char *ptr;
+        ptr = ip;
 
-#if    CASE_SENSITIVE
-       while (*ptr && *str) {
-               if(*ptr != *str)
-                       break;
-               ptr++;
-               str++;
-       }
-       if (*ptr == *str) {
-               ip = ptr;
-               return(1);
-       }
+#if     CASE_SENSITIVE
+        while (*ptr && *str) {
+                if(*ptr != *str)
+                        break;
+                ptr++;
+                str++;
+        }
+        if (*ptr == *str) {
+                ip = ptr;
+                return(1);
+        }
 #else
-       while (*ptr && *str) {
-               if(ccase[*ptr] != ccase[*str])
-                       break;
-               ptr++;
-               str++;
-       }
-       if (ccase[*ptr] == ccase[*str]) {
-               ip = ptr;
-               return(1);
-       }
+        while (*ptr && *str) {
+                if(ccase[*ptr] != ccase[*str])
+                        break;
+                ptr++;
+                str++;
+        }
+        if (ccase[*ptr] == ccase[*str]) {
+                ip = ptr;
+                return(1);
+        }
 #endif
 
-       if (!*str)
-               if (any(*ptr," \t\n,];")) {
-                       ip = ptr;
-                       return(1);
-               }
-       return(0);
+        if (!*str)
+                if (any(*ptr," \t\n,];")) {
+                        ip = ptr;
+                        return(1);
+                }
+        return(0);
 }
-       
+
 /*
  * Enter admode() to search a specific addressing mode table
  * for a match. Return the addressing value on a match or
@@ -213,17 +213,17 @@ int
 admode(sp)
 register struct adsym *sp;
 {
-       register char *ptr;
-       register int i;
-       unget(getnb());
-       i = 0;
-       while ( *(ptr = (char *) &sp[i]) ) {
-               if (srch(ptr)) {
-                       return(sp[i].a_val);
-               }
-               i++;
-       }
-       return(-1);
+        register char *ptr;
+        register int i;
+        unget(getnb());
+        i = 0;
+        while ( *(ptr = (char *) &sp[i]) ) {
+                if (srch(ptr)) {
+                        return(sp[i].a_val);
+                }
+                i++;
+        }
+        return(-1);
 }
 
 /*
@@ -236,23 +236,23 @@ register struct adsym *sp;
 int
 reg()
 {
-       register struct mne *mp;
-       char id[NCPS];
+        register struct mne *mp;
+        char id[NCPS];
 
-       getid(id, -1);
-       if ((mp = mlookup(id))==NULL) {
-               aerr();
-               return (-1);
-       }
+        getid(id, -1);
+        if ((mp = mlookup(id))==NULL) {
+                aerr();
+                return (-1);
+        }
         switch (mp->m_type) {
         case S_A:
         case S_AB:
         case S_DPTR:
         case S_PC:
         case S_REG:
-               return (mp->m_valu);
+                return (mp->m_valu);
 
-       default:
-               return (-1);
+        default:
+                return (-1);
         }
 }
index 177563b4900b5aeb5d60f470f9c0c5735e59e610..f5107635cd59c0862cbee9adce1cf033ab232a4c 100644 (file)
@@ -9,7 +9,8 @@ CFLAGS          = $(CFLAGS) -DINDEXLIB -DMLH_MAP -DSDK
 OBJECTS       = asdata.obj asexpr.obj aslex.obj aslist.obj asmain.obj \
                 asout.obj assubr.obj z80adr.obj z80ext.obj \
                 z80mch.obj z80pst.obj \
-                ../asxxsrc/strcmpi.obj ../asxxsrc/assym.obj
+                ../asxxsrc/strcmpi.obj ../asxxsrc/assym.obj ../asxxsrc/aslex.obj \
+                ../../support/Util/dbuf.obj ../../support/Util/dbuf_string.obj
 
 TARGET         = $(PRJDIR)/bin/as-z80.exe
 
index 633601412fb677e28ad8e11544ce8c06271471d3..3e484a9fe59a90caa852cfa51a579951a3ebe12e 100644 (file)
@@ -7,20 +7,22 @@ include $(top_builddir)/Makefile.common
 
 OBJDIR = obj$(EXT)
 
-ASXXLIB = $(srcdir)/../asxxsrc
+UTILLIB = $(srcdir)/../../support/Util
+UTILSRC = dbuf.c dbuf_string.c
+UTILLIBOBJS = $(UTILSRC:%.c=$(OBJDIR)/%.o)
 
+ASXXLIB = $(srcdir)/../asxxsrc
 ASXXLIBSRC = strcmpi.c assym.c aslex.c
-
-SRC = asdata.c asexpr.c aslist.c asmain.c asout.c \
-      assubr.c z80adr.c z80ext.c z80mch.c z80pst.c
-
-ASSOURCES = $(SRC) $(ASXXLIBSRC:%.c=$(ASXXLIB)/%.c)
-
 ASXXLIBOBJS = $(ASXXLIBSRC:%.c=$(OBJDIR)/%.o)
 
+SRC = asmain.c assubr.c \
+      asexpr.c asdata.c aslist.c asout.c \
+      z80ext.c z80pst.c z80mch.c z80adr.c
 OBJS = $(SRC:%.c=$(OBJDIR)/%.o)
 
-ASOBJECTS = $(OBJS) $(ASXXLIBOBJS)
+ASSOURCES = %(SRC) $(ASXXLIBSRC:%.c=$(ASXXLIB)/%.c) $(UTILSRC:%.c=$(UTILLIB)/%.c)
+
+AASOBJECTS = $(OBJS) $(ASXXLIBOBJS) $(UTILLIBOBJS)
 
 BINS = $(BUILDDIR)/as$(EXT)$(EXEEXT)
 
index 4aba0c35b3529bdcf3669c43e99c385e354493a9..f960d441db2162483f8648e47a1a24c5a623856e 100644 (file)
@@ -42,7 +42,7 @@ RSC=rc.exe
 # PROP Ignore_Export_Lib 0\r
 # PROP Target_Dir ""\r
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /FR /FD /GZ /c\r
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /FR /FD /GZ /c\r
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "." /I "../../support/Util" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /FR /FD /GZ /c\r
 # ADD BASE RSC /l 0x409 /d "_DEBUG"\r
 # ADD RSC /l 0x409 /d "_DEBUG"\r
 BSC32=bscmake.exe\r
@@ -67,7 +67,7 @@ LINK32=link.exe
 # PROP Ignore_Export_Lib 0\r
 # PROP Target_Dir ""\r
 # ADD BASE CPP /nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /FD /c\r
-# ADD CPP /nologo /ML /W3 /GX /O2 /I "." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /FD /c\r
+# ADD CPP /nologo /ML /W3 /GX /O2 /I "." /I "../../support/Util" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /FD /c\r
 # ADD BASE RSC /l 0x409 /d "NDEBUG"\r
 # ADD RSC /l 0x409 /d "NDEBUG"\r
 BSC32=bscmake.exe\r
@@ -126,6 +126,14 @@ SOURCE=..\asxxsrc\assym.c
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=..\..\support\Util\dbuf.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\support\Util\dbuf_string.c\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=..\asxxsrc\strcmpi.c\r
 # End Source File\r
 # Begin Source File\r
@@ -162,6 +170,14 @@ SOURCE=.\asm.h
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=..\..\support\Util\dbuf.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\support\Util\dbuf_string.h\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\string.h\r
 # End Source File\r
 # Begin Source File\r
index b4b706fe6b050d7ca6e20ddef7632606e5d29e1e..23aa96ea85f52de15f42922c1207b4032dc5b93c 100644 (file)
@@ -42,7 +42,7 @@ RSC=rc.exe
 # PROP Ignore_Export_Lib 0\r
 # PROP Target_Dir ""\r
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /FR /FD /GZ /c\r
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /FR /FD /GZ /c\r
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "." /I "../../support/Util" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /FR /FD /GZ /c\r
 # ADD BASE RSC /l 0x409 /d "_DEBUG"\r
 # ADD RSC /l 0x409 /d "_DEBUG"\r
 BSC32=bscmake.exe\r
@@ -67,7 +67,7 @@ LINK32=link.exe
 # PROP Ignore_Export_Lib 0\r
 # PROP Target_Dir ""\r
 # ADD BASE CPP /nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /FD /c\r
-# ADD CPP /nologo /ML /W3 /GX /O2 /I "." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /FD /c\r
+# ADD CPP /nologo /ML /W3 /GX /O2 /I "." /I "../../support/Util" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "INDEXLIB" /D "MLH_MAP" /D "SDK" /FD /c\r
 # ADD BASE RSC /l 0x409 /d "NDEBUG"\r
 # ADD RSC /l 0x409 /d "NDEBUG"\r
 BSC32=bscmake.exe\r
@@ -120,6 +120,14 @@ SOURCE=..\asxxsrc\assym.c
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=..\..\support\Util\dbuf.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\support\Util\dbuf_string.c\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=..\asxxsrc\strcmpi.c\r
 # End Source File\r
 # Begin Source File\r
@@ -152,6 +160,14 @@ SOURCE=.\asm.h
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=..\..\support\Util\dbuf.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\support\Util\dbuf_string.h\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\string.h\r
 # End Source File\r
 # Begin Source File\r
index 59ddc13a4048e7d18f29aa7c4f31e06ab14525a7..1f7add6bbcf3a36bb271a9596593572c01fc6b6d 100644 (file)
@@ -101,10 +101,10 @@ char    *ep;            /*      pointer into error list
                          */
 char    eb[NERR];       /*      array of generated error codes
                          */
-char    *ip;            /*      pointer into the assembler-source
+const char *ip;         /*      pointer into the assembler-source
                          *      text line in ib[]
                          */
-char    ib[NINPUT];     /*      assembler-source text line
+const char *ib;         /*      assembler-source text line
                          */
 char    *cp;            /*      pointer to assembler output
                          *      array cb[]
index 2664550db4d31b42763ae8ef2cb8eaabcf85c05b..58fc0776e135567a185fe48a08cf6969d62df5ec 100644 (file)
 
 #include "asm.h"
 
-/*)Module      asexpr.c
- *
- *     The module asexpr.c contains the routines to evaluate
- *     arithmetic/numerical expressions.  The functions in
- *     asexpr.c perform a recursive evaluation of the arithmetic
- *     expression read from the assembler-source text line.
- *     The expression may include binary/unary operators, brackets,
- *     symbols, labels, and constants in hexadecimal, decimal, octal
- *     and binary.  Arithmetic operations are prioritized and
- *     evaluated by normal arithmetic conventions.
- *
- *     asexpr.c contains the following functions:
- *             VOID    abscheck()
- *             Addr_T  absexpr()
- *             VOID    clrexpr()
- *             int     digit()
- *             VOID    expr()
- *             int     oprio()
- *             VOID    term()
- *
- *     asexpr.c contains no local/static variables
+/*)Module       asexpr.c
+ *
+ *      The module asexpr.c contains the routines to evaluate
+ *      arithmetic/numerical expressions.  The functions in
+ *      asexpr.c perform a recursive evaluation of the arithmetic
+ *      expression read from the assembler-source text line.
+ *      The expression may include binary/unary operators, brackets,
+ *      symbols, labels, and constants in hexadecimal, decimal, octal
+ *      and binary.  Arithmetic operations are prioritized and
+ *      evaluated by normal arithmetic conventions.
+ *
+ *      asexpr.c contains the following functions:
+ *              VOID    abscheck()
+ *              Addr_T  absexpr()
+ *              VOID    clrexpr()
+ *              int     digit()
+ *              VOID    expr()
+ *              int     oprio()
+ *              VOID    term()
+ *
+ *      asexpr.c contains no local/static variables
  */
 
-/*)Function    VOID    expr(esp, n)
- *
- *             expr *  esp             pointer to an expr structure
- *             int     n               a firewall priority; all top
- *                                     level calls (from the user)
- *                                     should be made with n set to 0.
- *
- *     The function expr() evaluates an expression and
- *     stores its value and relocation information into
- *     the expr structure supplied by the user.
- *
- *     local variables:
- *             int     c               current assembler-source
- *                                     text character
- *             int     p               current operator priority
- *             area *  ap              pointer to an area structure
- *             exp     re              internal expr structure
- *
- *     global variables:
- *             char    ctype[]         array of character types, one per
- *                                     ASCII character
- *
- *     functions called:
- *             VOID    abscheck()      asexpr.c
- *             VOID    clrexpr()       asexpr.c
- *             VOID    expr()          asexpr.c
- *             int     getnb()         aslex.c
- *             int     oprio()         asexpr.c
- *             VOID    qerr()          assubr.c
- *             VOID    rerr()          assubr.c
- *             VOID    term()          asexpr.c
- *             VOID    unget()         aslex.c
- *
- *
- *     side effects:
- *             An expression is evaluated modifying the user supplied
- *             expr structure, a sym structure maybe created for an
- *             undefined symbol, and the parse of the expression may
- *             terminate if a 'q' error occurs.
+/*)Function     VOID    expr(esp, n)
+ *
+ *              expr *  esp             pointer to an expr structure
+ *              int     n               a firewall priority; all top
+ *                                      level calls (from the user)
+ *                                      should be made with n set to 0.
+ *
+ *      The function expr() evaluates an expression and
+ *      stores its value and relocation information into
+ *      the expr structure supplied by the user.
+ *
+ *      local variables:
+ *              int     c               current assembler-source
+ *                                      text character
+ *              int     p               current operator priority
+ *              area *  ap              pointer to an area structure
+ *              exp     re              internal expr structure
+ *
+ *      global variables:
+ *              char    ctype[]         array of character types, one per
+ *                                      ASCII character
+ *
+ *      functions called:
+ *              VOID    abscheck()      asexpr.c
+ *              VOID    clrexpr()       asexpr.c
+ *              VOID    expr()          asexpr.c
+ *              int     getnb()         aslex.c
+ *              int     oprio()         asexpr.c
+ *              VOID    qerr()          assubr.c
+ *              VOID    rerr()          assubr.c
+ *              VOID    term()          asexpr.c
+ *              VOID    unget()         aslex.c
+ *
+ *
+ *      side effects:
+ *              An expression is evaluated modifying the user supplied
+ *              expr structure, a sym structure maybe created for an
+ *              undefined symbol, and the parse of the expression may
+ *              terminate if a 'q' error occurs.
  */
 
 VOID
@@ -90,31 +90,31 @@ int n;
 
         term(esp);
         while (ctype[c = getnb()] & BINOP) {
-               /*
-                * Handle binary operators + - * / & | % ^ << >>
-                */
+                /*
+                 * Handle binary operators + - * / & | % ^ << >>
+                 */
                 if ((p = oprio(c)) <= n)
                         break;
                 if ((c == '>' || c == '<') && c != get())
                         qerr();
-               clrexpr(&re);
+                clrexpr(&re);
                 expr(&re, p);
-               esp->e_rlcf |= re.e_rlcf;
+                esp->e_rlcf |= re.e_rlcf;
                 if (c == '+') {
-                       /*
-                        * esp + re, at least one must be absolute
-                        */
+                        /*
+                         * esp + re, at least one must be absolute
+                         */
                         if (esp->e_base.e_ap == NULL) {
-                               /*
-                                * esp is absolute (constant),
-                                * use area from re
-                                */
+                                /*
+                                 * esp is absolute (constant),
+                                 * use area from re
+                                 */
                                 esp->e_base.e_ap = re.e_base.e_ap;
                         } else
                         if (re.e_base.e_ap) {
-                               /*
-                                * re should be absolute (constant)
-                                */
+                                /*
+                                 * re should be absolute (constant)
+                                 */
                                 rerr();
                         }
                         if (esp->e_flag && re.e_flag)
@@ -124,9 +124,9 @@ int n;
                         esp->e_addr += re.e_addr;
                 } else
                 if (c == '-') {
-                       /*
-                        * esp - re
-                        */
+                        /*
+                         * esp - re
+                         */
                         if ((ap = re.e_base.e_ap) != NULL) {
                                 if (esp->e_base.e_ap == ap) {
                                         esp->e_base.e_ap = NULL;
@@ -138,9 +138,9 @@ int n;
                                 rerr();
                         esp->e_addr -= re.e_addr;
                 } else {
-                       /*
-                        * Both operands (esp and re) must be constants
-                        */
+                        /*
+                         * Both operands (esp and re) must be constants
+                         */
                         abscheck(esp);
                         abscheck(&re);
                         switch (c) {
@@ -177,35 +177,35 @@ int n;
                                 esp->e_addr >>= re.e_addr;
                                 break;
 
-                       default:
-                               qerr();
-                               break;
+                        default:
+                                qerr();
+                                break;
                         }
                 }
         }
         unget(c);
 }
 
-/*)Function    Addr_T  absexpr()
+/*)Function     Addr_T  absexpr()
  *
- *     The function absexpr() evaluates an expression, verifies it
- *     is absolute (i.e. not position dependent or relocatable), and
- *     returns its value.
+ *      The function absexpr() evaluates an expression, verifies it
+ *      is absolute (i.e. not position dependent or relocatable), and
+ *      returns its value.
  *
- *     local variables:
- *             expr    e               expr structure
+ *      local variables:
+ *              expr    e               expr structure
  *
- *     global variables:
- *             none
+ *      global variables:
+ *              none
  *
- *     functions called:
- *             VOID    abscheck()      asexpr.c
- *             VOID    clrexpr()       asexpr.c
- *             VOID    expr()          asexpr.c
+ *      functions called:
+ *              VOID    abscheck()      asexpr.c
+ *              VOID    clrexpr()       asexpr.c
+ *              VOID    expr()          asexpr.c
  *
- *     side effects:
- *             If the expression is not absolute then
- *             a 'r' error is reported.
+ *      side effects:
+ *              If the expression is not absolute then
+ *              a 'r' error is reported.
  */
 
 Addr_T
@@ -213,55 +213,55 @@ absexpr()
 {
         struct expr e;
 
-       clrexpr(&e);
-       expr(&e, 0);
-       abscheck(&e);
-       return (e.e_addr);
+        clrexpr(&e);
+        expr(&e, 0);
+        abscheck(&e);
+        return (e.e_addr);
 }
 
-/*)Function    VOID    term(esp)
- *
- *             expr *  esp             pointer to an expr structure
- *
- *     The function term() evaluates a single constant
- *     or symbol value prefaced by any unary operator
- *     ( +, -, ~, ', ", >, or < ).  This routine is also
- *     responsible for setting the relocation type to symbol
- *     based (e.flag != 0) on global references.
- *
- *     local variables:
- *             int     c               current character
- *             char    id[]            symbol name
- *             char *  jp              pointer to assembler-source text
- *             int     n               constant evaluation running sum
- *             int     r               current evaluation radix
- *             sym *   sp              pointer to a sym structure
- *             tsym *  tp              pointer to a tsym structure
- *             int     v               current digit evaluation
- *
- *     global variables:
- *             char    ctype[]         array of character types, one per
- *                                     ASCII character
- *             sym *   symp            pointer to a symbol structure
- *
- *     functions called:
- *             VOID    abscheck()      asexpr.c
- *             int     digit()         asexpr.c
- *             VOID    err()           assubr.c
- *             VOID    expr()          asexpr.c
- *             int     is_abs()        asexpr.c
- *             int     get()           aslex.c
- *             VOID    getid()         aslex.c
- *             int     getmap()        aslex.c
- *             int     getnb()         aslex.c
- *             sym *   lookup()        assym.c
- *             VOID    qerr()          assubr.c
- *             VOID    unget()         aslex.c
- *
- *     side effects:
- *             An arithmetic term is evaluated, a symbol structure
- *             may be created, term evaluation may be terminated
- *             by a 'q' error.
+/*)Function     VOID    term(esp)
+ *
+ *              expr *  esp             pointer to an expr structure
+ *
+ *      The function term() evaluates a single constant
+ *      or symbol value prefaced by any unary operator
+ *      ( +, -, ~, ', ", >, or < ).  This routine is also
+ *      responsible for setting the relocation type to symbol
+ *      based (e.flag != 0) on global references.
+ *
+ *      local variables:
+ *              int     c               current character
+ *              char    id[]            symbol name
+ *              char *  jp              pointer to assembler-source text
+ *              int     n               constant evaluation running sum
+ *              int     r               current evaluation radix
+ *              sym *   sp              pointer to a sym structure
+ *              tsym *  tp              pointer to a tsym structure
+ *              int     v               current digit evaluation
+ *
+ *      global variables:
+ *              char    ctype[]         array of character types, one per
+ *                                      ASCII character
+ *              sym *   symp            pointer to a symbol structure
+ *
+ *      functions called:
+ *              VOID    abscheck()      asexpr.c
+ *              int     digit()         asexpr.c
+ *              VOID    err()           assubr.c
+ *              VOID    expr()          asexpr.c
+ *              int     is_abs()        asexpr.c
+ *              int     get()           aslex.c
+ *              VOID    getid()         aslex.c
+ *              int     getmap()        aslex.c
+ *              int     getnb()         aslex.c
+ *              sym *   lookup()        assym.c
+ *              VOID    qerr()          assubr.c
+ *              VOID    unget()         aslex.c
+ *
+ *      side effects:
+ *              An arithmetic term is evaluated, a symbol structure
+ *              may be created, term evaluation may be terminated
+ *              by a 'q' error.
  */
 
 VOID
@@ -269,23 +269,23 @@ term(esp)
 register struct expr *esp;
 {
         register int c, n;
-        register char *jp;
+        register const char *jp;
         char id[NCPS];
         struct sym  *sp;
         struct tsym *tp;
         int r = 0, v;
 
         c = getnb();
-       /*
-        * Discard the unary '+' at this point and
-        * also any reference to numerical arguments
-        * associated with the '#' prefix.
-        */
+        /*
+         * Discard the unary '+' at this point and
+         * also any reference to numerical arguments
+         * associated with the '#' prefix.
+         */
         while (c == '+' || c == '#') { c = getnb(); }
-       /*
-        * Evaluate all binary operators
-        * by recursively calling expr().
-        */
+        /*
+         * Evaluate all binary operators
+         * by recursively calling expr().
+         */
         if (c == LFTERM) {
                 expr(esp, 0);
                 if (getnb() != RTTERM)
@@ -322,28 +322,28 @@ register struct expr *esp;
         }
         if (c == '>' || c == '<') {
                 expr(esp, 100);
-               if (is_abs (esp)) {
-                       /*
-                        * evaluate msb/lsb directly
-                        */
-                       if (c == '>')
-                               esp->e_addr >>= 8;
-                       esp->e_addr &= 0377;
-                       return;
-               } else {
-                       /*
-                        * let linker perform msb/lsb, lsb is default
-                        */
-                       esp->e_rlcf |= R_BYT2;
-                       if (c == '>')
-                               esp->e_rlcf |= R_MSB;
-                       return;
-               }
+                if (is_abs (esp)) {
+                        /*
+                         * evaluate msb/lsb directly
+                         */
+                        if (c == '>')
+                                esp->e_addr >>= 8;
+                        esp->e_addr &= 0377;
+                        return;
+                } else {
+                        /*
+                         * let linker perform msb/lsb, lsb is default
+                         */
+                        esp->e_rlcf |= R_BYT2;
+                        if (c == '>')
+                                esp->e_rlcf |= R_MSB;
+                        return;
+                }
         }
-       /*
-        * Evaluate digit sequences as local symbols
-        * if followed by a '$' or as constants.
-        */
+        /*
+         * Evaluate digit sequences as local symbols
+         * if followed by a '$' or as constants.
+         */
         if (ctype[c] & DIGIT) {
                 esp->e_mode = S_USER;
                 jp = ip;
@@ -409,57 +409,57 @@ register struct expr *esp;
                 esp->e_addr = n;
                 return;
         }
-       /*
-        * Evaluate '$' sequences as a temporary radix
-        * if followed by a '%', '&', '#', or '$'.
-        */
+        /*
+         * Evaluate '$' sequences as a temporary radix
+         * if followed by a '%', '&', '#', or '$'.
+         */
         if (c == '$') {
                 c = get();
                 if (c == '%' || c == '&' || c == '#' || c == '$') {
-                       switch (c) {
-                               case '%':
-                                       r = 2;
-                                       break;
-                               case '&':
-                                       r = 8;
-                                       break;
-                               case '#':
-                                       r = 10;
-                                       break;
-                               case '$':
-                                       r = 16;                         
-                                       break;
-                               default:
-                                       break;
-                       }
-                       c = get();
-                       n = 0;
-                       while ((v = digit(c, r)) >= 0) {
-                               n = r*n + v;
-                               c = get();
-                       }
-                       unget(c);
-                       esp->e_mode = S_USER;
-                       esp->e_addr = n;
-                       return;
-               }
-               unget(c);
-               c = '$';
+                        switch (c) {
+                                case '%':
+                                        r = 2;
+                                        break;
+                                case '&':
+                                        r = 8;
+                                        break;
+                                case '#':
+                                        r = 10;
+                                        break;
+                                case '$':
+                                        r = 16;
+                                        break;
+                                default:
+                                        break;
+                        }
+                        c = get();
+                        n = 0;
+                        while ((v = digit(c, r)) >= 0) {
+                                n = r*n + v;
+                                c = get();
+                        }
+                        unget(c);
+                        esp->e_mode = S_USER;
+                        esp->e_addr = n;
+                        return;
+                }
+                unget(c);
+                c = '$';
         }
-       /*
-        * Evaluate symbols and labels
-        */
+        /*
+         * Evaluate symbols and labels
+         */
         if (ctype[c] & LETTER) {
                 esp->e_mode = S_USER;
                 getid(id, c);
                 sp = lookup(id);
                 if (sp->s_type == S_NEW) {
-                       if (sp->s_flag&S_GBL) {
-                               esp->e_flag = 1;
-                               esp->e_base.e_sp = sp;
-                               return;
-                       }
-                       err('u');
+                        if (sp->s_flag&S_GBL) {
+                                esp->e_flag = 1;
+                                esp->e_base.e_sp = sp;
+                                return;
+                        }
+                        err('u');
                 } else {
                         esp->e_mode = sp->s_type;
                         esp->e_addr = sp->s_addr;
@@ -467,33 +467,33 @@ register struct expr *esp;
                 }
                 return;
         }
-       /*
-        * Else not a term.
-        */
+        /*
+         * Else not a term.
+         */
         qerr();
 }
 
-/*)Function    int     digit(c, r)
+/*)Function     int     digit(c, r)
  *
- *             int     c               digit character
- *             int     r               current radix
+ *              int     c               digit character
+ *              int     r               current radix
  *
- *     The function digit() returns the value of c
- *     in the current radix r.  If the c value is not
- *     a number of the current radix then a -1 is returned.
+ *      The function digit() returns the value of c
+ *      in the current radix r.  If the c value is not
+ *      a number of the current radix then a -1 is returned.
  *
- *     local variables:
- *             none
+ *      local variables:
+ *              none
  *
- *     global variables:
- *             char    ctype[]         array of character types, one per
- *                                     ASCII character
+ *      global variables:
+ *              char    ctype[]         array of character types, one per
+ *                                      ASCII character
  *
- *     functions called:
- *             none
+ *      functions called:
+ *              none
  *
- *     side effects:
- *             none
+ *      side effects:
+ *              none
  */
 
 int
@@ -524,31 +524,31 @@ register int c, r;
         return (-1);
 }
 
-/*)Function    VOID    abscheck(esp)
+/*)Function     VOID    abscheck(esp)
  *
- *             expr *  esp             pointer to an expr structure
+ *              expr *  esp             pointer to an expr structure
  *
- *     The function abscheck() tests the evaluation of an
- *     expression to verify it is absolute.  If the evaluation
- *     is relocatable then an 'r' error is noted and the expression
- *     made absolute.
+ *      The function abscheck() tests the evaluation of an
+ *      expression to verify it is absolute.  If the evaluation
+ *      is relocatable then an 'r' error is noted and the expression
+ *      made absolute.
  *
- *     Note:   The area type (i.e. ABS) is not checked because
- *             the linker can be told to explicitly relocate an
- *             absolute area.
+ *      Note:   The area type (i.e. ABS) is not checked because
+ *              the linker can be told to explicitly relocate an
+ *              absolute area.
  *
- *     local variables:
- *             none
+ *      local variables:
+ *              none
  *
- *     global variables:
- *             none
+ *      global variables:
+ *              none
  *
- *     functions called:
- *             VOID    rerr()          assubr.c
+ *      functions called:
+ *              VOID    rerr()          assubr.c
  *
- *     side effects:
- *             The expression may be changed to absolute and the
- *             'r' error invoked.
+ *      side effects:
+ *              The expression may be changed to absolute and the
+ *              'r' error invoked.
  */
 
 VOID
@@ -562,29 +562,29 @@ register struct expr *esp;
         }
 }
 
-/*)Function    int     is_abs(esp)
+/*)Function     int     is_abs(esp)
  *
- *             expr *  esp             pointer to an expr structure
+ *              expr *  esp             pointer to an expr structure
  *
- *     The function is_abs() tests the evaluation of an
- *     expression to verify it is absolute.  If the evaluation
- *     is absolute then 1 is returned, else 0 is returned.
+ *      The function is_abs() tests the evaluation of an
+ *      expression to verify it is absolute.  If the evaluation
+ *      is absolute then 1 is returned, else 0 is returned.
  *
- *     Note:   The area type (i.e. ABS) is not checked because
- *             the linker can be told to explicitly relocate an
- *             absolute area.
+ *      Note:   The area type (i.e. ABS) is not checked because
+ *              the linker can be told to explicitly relocate an
+ *              absolute area.
  *
- *     local variables:
- *             none
+ *      local variables:
+ *              none
  *
- *     global variables:
- *             none
+ *      global variables:
+ *              none
  *
- *     functions called:
- *             none
+ *      functions called:
+ *              none
  *
- *     side effects:
- *             none
+ *      side effects:
+ *              none
  */
 
 int
@@ -592,31 +592,31 @@ is_abs (esp)
 register struct expr *esp;
 {
         if (esp->e_flag || esp->e_base.e_ap) {
-               return(0);
+                return(0);
         }
-       return(1);
+        return(1);
 }
 
-/*)Function    int     oprio(c)
+/*)Function     int     oprio(c)
  *
- *             int     c               operator character
+ *              int     c               operator character
  *
- *     The function oprio() returns a relative priority
- *     for all valid unary and binary operators.
+ *      The function oprio() returns a relative priority
+ *      for all valid unary and binary operators.
  *
- *     local variables:
- *             none
+ *      local variables:
+ *              none
  *
- *     global variables:
- *             none
+ *      global variables:
+ *              none
  *
- *     functions called:
- *             none
+ *      functions called:
+ *              none
  *
- *     side effects:
- *             none
+ *      side effects:
+ *              none
  */
+
 int
 oprio(c)
 register int c;
@@ -636,32 +636,32 @@ register int c;
         return (0);
 }
 
-/*)Function    VOID    clrexpr(esp)
+/*)Function     VOID    clrexpr(esp)
  *
- *             expr *  esp             pointer to expression structure
+ *              expr *  esp             pointer to expression structure
  *
- *     The function clrexpr() clears the expression structure.
+ *      The function clrexpr() clears the expression structure.
  *
- *     local variables:
- *             none
+ *      local variables:
+ *              none
  *
- *     global variables:
- *             none
+ *      global variables:
+ *              none
  *
- *     functions called:
- *             none
+ *      functions called:
+ *              none
  *
- *     side effects:
- *             expression structure cleared.
+ *      side effects:
+ *              expression structure cleared.
  */
+
 VOID
 clrexpr(esp)
 register struct expr *esp;
 {
-       esp->e_mode = 0;
-       esp->e_flag = 0;
-       esp->e_addr = 0;
-       esp->e_base.e_ap = NULL;
-       esp->e_rlcf = 0;
+        esp->e_mode = 0;
+        esp->e_flag = 0;
+        esp->e_addr = 0;
+        esp->e_base.e_ap = NULL;
+        esp->e_rlcf = 0;
 }
index fa6f3b696249911fc1901963837040a761eebbba..0a8293bb1f0a7f57c6e881f2b269fb959de1882b 100644 (file)
@@ -600,7 +600,6 @@ lstsym(fp)
 FILE *fp;
 {
         register int c, i, j, k;
-        register char *ptr;
         int nmsym, narea;
         struct sym *sp;
         struct sym **p;
index af0c054a1ce8307d62f1aa8d94b7b1e5f8efd6e0..b403e7349fab4cfc93481eecc27a1a6b2268ca6f 100644 (file)
@@ -403,10 +403,10 @@ extern  char    *ep;            /*      pointer into error list
                                  */
 extern  char    eb[NERR];       /*      array of generated error codes
                                  */
-extern  char    *ip;            /*      pointer into the assembler-source
+extern  const char *ip;         /*      pointer into the assembler-source
                                  *      text line in ib[]
                                  */
-extern  char    ib[NINPUT];     /*      assembler-source text line
+extern  const char *ib;         /*      assembler-source text line
                                  */
 extern  char    *cp;            /*      pointer to assembler output
                                  *      array cb[]
index 58594b01d5824f2ec8cf4f5495a501fed7df10c2..f4b12afc53aebefc3e52192f119a73f070e2e572 100644 (file)
  *
  * This addr(esp) routine performs the following addressing decoding:
  *
- *     address         mode            flag            addr            base
- *     #n              S_IMMED         0               n               NULL
- *     label           s_type          ----            s_addr          s_area
- *     [REG]           S_IND+icode     0               0               NULL
- *     [label]         S_INDM          ----            s_addr          s_area
- *     offset[REG]     S_IND+icode     ----            offset          ----
+ *      address         mode            flag            addr            base
+ *      #n              S_IMMED         0               n               NULL
+ *      label           s_type          ----            s_addr          s_area
+ *      [REG]           S_IND+icode     0               0               NULL
+ *      [label]         S_INDM          ----            s_addr          s_area
+ *      offset[REG]     S_IND+icode     ----            offset          ----
  */
 int
 addr(esp)
 register struct expr *esp;
 {
-       register int c, mode = 0, indx;
+        register int c, mode = 0, indx;
 
-       if ((c = getnb()) == '#') {
-               expr(esp, 0);
-               esp->e_mode = S_IMMED;
-       } else
-       if (c == LFIND) {
-               if ((indx = admode(R8)) != 0) {
-                       mode = S_INDB;
-               } else
-               if ((indx = admode(R16)) != 0) {
-                       mode = S_INDR;
-               } else  
-               if ((indx = admode(R8X)) != 0) {
-                       mode = S_R8X;
-                       aerr();
-               } else
-               if ((indx = admode(R16X)) != 0) {
-                       mode = S_R16X;
-                       aerr();
-               } else {
-                       expr(esp, 0);
-                       esp->e_mode = S_INDM;
-               }
-               if (indx) {
-                       esp->e_mode = (mode + indx)&0xFF;
-                       esp->e_base.e_ap = NULL;
-               }
-               if ((c = getnb()) != RTIND)
-                       qerr();
-       } else {
-               unget(c);
-               if ((indx = admode(R8)) != 0) {
-                       mode = S_R8;
-               } else
-               if ((indx = admode(R16)) != 0) {
-                       mode = S_R16;
-               } else  
-               if ((indx = admode(R8X)) != 0) {
-                       mode = S_R8X;
-               } else
-               if ((indx = admode(R16X)) != 0) {
-                       mode = S_R16X;
-               } else {
-                       expr(esp, 0);
-                       esp->e_mode = S_USER;
-               }
-               if (indx) {
-                       esp->e_addr = indx&0xFF;
-                       esp->e_mode = mode;
-                       esp->e_base.e_ap = NULL;
-               }
-               if ((c = getnb()) == LFIND) {
+        if ((c = getnb()) == '#') {
+                expr(esp, 0);
+                esp->e_mode = S_IMMED;
+        } else
+        if (c == LFIND) {
+                if ((indx = admode(R8)) != 0) {
+                        mode = S_INDB;
+                } else
+                if ((indx = admode(R16)) != 0) {
+                        mode = S_INDR;
+                } else
+                if ((indx = admode(R8X)) != 0) {
+                        mode = S_R8X;
+                        aerr();
+                } else
+                if ((indx = admode(R16X)) != 0) {
+                        mode = S_R16X;
+                        aerr();
+                } else {
+                        expr(esp, 0);
+                        esp->e_mode = S_INDM;
+                }
+                if (indx) {
+                        esp->e_mode = (mode + indx)&0xFF;
+                        esp->e_base.e_ap = NULL;
+                }
+                if ((c = getnb()) != RTIND)
+                        qerr();
+        } else {
+                unget(c);
+                if ((indx = admode(R8)) != 0) {
+                        mode = S_R8;
+                } else
+                if ((indx = admode(R16)) != 0) {
+                        mode = S_R16;
+                } else
+                if ((indx = admode(R8X)) != 0) {
+                        mode = S_R8X;
+                } else
+                if ((indx = admode(R16X)) != 0) {
+                        mode = S_R16X;
+                } else {
+                        expr(esp, 0);
+                        esp->e_mode = S_USER;
+                }
+                if (indx) {
+                        esp->e_addr = indx&0xFF;
+                        esp->e_mode = mode;
+                        esp->e_base.e_ap = NULL;
+                }
+                if ((c = getnb()) == LFIND) {
 #ifndef GAMEBOY
-                       if ((indx=admode(R16))!=0
-                               && ((indx&0xFF)==IX || (indx&0xFF)==IY)) {
+                        if ((indx=admode(R16))!=0
+                                && ((indx&0xFF)==IX || (indx&0xFF)==IY)) {
 #else /* GAMEBOY */
-                       if ((indx=admode(R16))!=0) {
+                        if ((indx=admode(R16))!=0) {
 #endif /* GAMEBOY */
-                               esp->e_mode = S_INDR + (indx&0xFF);
-                       } else {
-                               aerr();
-                       }
-                       if ((c = getnb()) != RTIND)
-                               qerr();
-               } else {
-                       unget(c);
-               }
-       }
-       return (esp->e_mode);
+                                esp->e_mode = S_INDR + (indx&0xFF);
+                        } else {
+                                aerr();
+                        }
+                        if ((c = getnb()) != RTIND)
+                                qerr();
+                } else {
+                        unget(c);
+                }
+        }
+        return (esp->e_mode);
 }
 
 /*
@@ -118,22 +118,22 @@ int
 admode(sp)
 register struct adsym *sp;
 {
-       register char *ptr;
-       register int i;
-       register char *ips;
+        register char *ptr;
+        register int i;
+        register const char *ips;
 
-       ips = ip;
-       unget(getnb());
+        ips = ip;
+        unget(getnb());
 
-       i = 0;
-       while ( *(ptr = (char *) &sp[i]) ) {
-               if (srch(ptr)) {
-                       return(sp[i].a_val);
-               }
-               i++;
-       }
-       ip = ips;
-       return(0);
+        i = 0;
+        while ( *(ptr = (char *) &sp[i]) ) {
+                if (srch(ptr)) {
+                        return(sp[i].a_val);
+                }
+                i++;
+        }
+        ip = ips;
+        return(0);
 }
 
 /*
@@ -143,39 +143,39 @@ int
 srch(str)
 register char *str;
 {
-       register char *ptr;
-       ptr = ip;
+        register const char *ptr;
+        ptr = ip;
 
-#if    CASE_SENSITIVE
-       while (*ptr && *str) {
-               if (*ptr != *str)
-                       break;
-               ptr++;
-               str++;
-       }
-       if (*ptr == *str) {
-               ip = ptr;
-               return(1);
-       }
+#if     CASE_SENSITIVE
+        while (*ptr && *str) {
+                if (*ptr != *str)
+                        break;
+                ptr++;
+                str++;
+        }
+        if (*ptr == *str) {
+                ip = ptr;
+                return(1);
+        }
 #else
-       while (*ptr && *str) {
-               if (ccase[(unsigned char)(*ptr)] != ccase[(unsigned char)(*str)])
-                       break;
-               ptr++;
-               str++;
-       }
-       if (ccase[(unsigned char)(*ptr)] == ccase[(unsigned char)(*str)]) {
-               ip = ptr;
-               return(1);
-       }
+        while (*ptr && *str) {
+                if (ccase[(unsigned char)(*ptr)] != ccase[(unsigned char)(*str)])
+                        break;
+                ptr++;
+                str++;
+        }
+        if (ccase[(unsigned char)(*ptr)] == ccase[(unsigned char)(*str)]) {
+                ip = ptr;
+                return(1);
+        }
 #endif
 
-       if (!*str)
-               if (any(*ptr," \t\n,);")) {
-                       ip = ptr;
-                       return(1);
-               }
-       return(0);
+        if (!*str)
+                if (any(*ptr," \t\n,);")) {
+                        ip = ptr;
+                        return(1);
+                }
+        return(0);
 }
 
 /*
@@ -185,101 +185,101 @@ int
 any(c,str)
 char    c, *str;
 {
-       while (*str)
-               if(*str++ == c)
-                       return(1);
-       return(0);
+        while (*str)
+                if(*str++ == c)
+                        return(1);
+        return(0);
 }
 
 /*
  * Registers
  */
 
-struct adsym   R8[] = {
-    { "b",     B|0400 },
-    { "c",     C|0400 },
-    { "d",     D|0400 },
-    { "e",     E|0400 },
-    { "h",     H|0400 },
-    { "l",     L|0400 },
-    { "a",     A|0400 },
-    { "B",     B|0400 },
-    { "C",     C|0400 },
-    { "D",     D|0400 },
-    { "E",     E|0400 },
-    { "H",     H|0400 },
-    { "L",     L|0400 },
-    { "A",     A|0400 },
-    { "",      000 }
+struct  adsym   R8[] = {
+    { "b",      B|0400 },
+    { "c",      C|0400 },
+    { "d",      D|0400 },
+    { "e",      E|0400 },
+    { "h",      H|0400 },
+    { "l",      L|0400 },
+    { "a",      A|0400 },
+    { "B",      B|0400 },
+    { "C",      C|0400 },
+    { "D",      D|0400 },
+    { "E",      E|0400 },
+    { "H",      H|0400 },
+    { "L",      L|0400 },
+    { "A",      A|0400 },
+    { "",       000 }
 };
 
-struct adsym   R8X[] = {
-    { "i",     I|0400 },
-    { "r",     R|0400 },
-    { "I",     I|0400 },
-    { "R",     R|0400 },
-    { "",      000 }
+struct  adsym   R8X[] = {
+    { "i",      I|0400 },
+    { "r",      R|0400 },
+    { "I",      I|0400 },
+    { "R",      R|0400 },
+    { "",       000 }
 };
 
-struct adsym   R16[] = {
-    { "bc",    BC|0400 },
-    { "de",    DE|0400 },
-    { "hl",    HL|0400 },
-    { "sp",    SP|0400 },
-    { "BC",    BC|0400 },
-    { "DE",    DE|0400 },
-    { "HL",    HL|0400 },
-    { "SP",    SP|0400 },
+struct  adsym   R16[] = {
+    { "bc",     BC|0400 },
+    { "de",     DE|0400 },
+    { "hl",     HL|0400 },
+    { "sp",     SP|0400 },
+    { "BC",     BC|0400 },
+    { "DE",     DE|0400 },
+    { "HL",     HL|0400 },
+    { "SP",     SP|0400 },
 #ifndef GAMEBOY
-    { "ix",    IX|0400 },
-    { "iy",    IY|0400 },
-    { "IX",    IX|0400 },
-    { "IY",    IY|0400 },
+    { "ix",     IX|0400 },
+    { "iy",     IY|0400 },
+    { "IX",     IX|0400 },
+    { "IY",     IY|0400 },
 #else /* GAMEBOY */
-    { "hl-",   HLD|0400 },
-    { "hl+",   HLI|0400 },
-    { "hld",   HLD|0400 },
-    { "hli",   HLI|0400 },
-    { "HL-",   HLD|0400 },
-    { "HL+",   HLI|0400 },
-    { "HLD",   HLD|0400 },
-    { "HLI",   HLI|0400 },
+    { "hl-",    HLD|0400 },
+    { "hl+",    HLI|0400 },
+    { "hld",    HLD|0400 },
+    { "hli",    HLI|0400 },
+    { "HL-",    HLD|0400 },
+    { "HL+",    HLI|0400 },
+    { "HLD",    HLD|0400 },
+    { "HLI",    HLI|0400 },
 #endif /* GAMEBOY */
-    { "",      000 }
+    { "",       000 }
 };
 
-struct adsym   R16X[] = {
-    { "af",    AF|0400 },
+struct  adsym   R16X[] = {
+    { "af",     AF|0400 },
     { "AF",     AF|0400 },
 #ifndef GAMEBOY
-    { "af'",   AF|0400 },
-    { "AF'",   AF|0400 },
+    { "af'",    AF|0400 },
+    { "AF'",    AF|0400 },
 #endif /* GAMEBOY */
-    { "",      000 }
+    { "",       000 }
 };
 
 /*
  * Conditional definitions
  */
 
-struct adsym   CND[] = {
-    { "NZ",    NZ|0400 },
-    { "Z",     Z |0400 },
-    { "NC",    NC|0400 },
-    { "C",     CS|0400 },
-    { "nz",    NZ|0400 },
-    { "z",     Z |0400 },
-    { "nc",    NC|0400 },
-    { "c",     CS|0400 },
+struct  adsym   CND[] = {
+    { "NZ",     NZ|0400 },
+    { "Z",      Z |0400 },
+    { "NC",     NC|0400 },
+    { "C",      CS|0400 },
+    { "nz",     NZ|0400 },
+    { "z",      Z |0400 },
+    { "nc",     NC|0400 },
+    { "c",      CS|0400 },
 #ifndef GAMEBOY
-    { "PO",    PO|0400 },
-    { "PE",    PE|0400 },
-    { "P",     P |0400 },
-    { "M",     M |0400 },
-    { "po",    PO|0400 },
-    { "pe",    PE|0400 },
-    { "p",     P |0400 },
-    { "m",     M |0400 },
+    { "PO",     PO|0400 },
+    { "PE",     PE|0400 },
+    { "P",      P |0400 },
+    { "M",      M |0400 },
+    { "po",     PO|0400 },
+    { "pe",     PE|0400 },
+    { "p",      P |0400 },
+    { "m",      M |0400 },
 #endif /* GAMEBOY */
-    { "",      000 }
+    { "",       000 }
 };
index b8ce3b39ff714a92c7b9627bf6998356efc95e6a..08d373031d284025f6f3bb03e32aae8fdab5adc3 100644 (file)
@@ -247,6 +247,7 @@ printILine (iCode *ic)
 {
   char *verbalICode;
   struct dbuf_s tmpBuf;
+  size_t len;
   iCodeTable *icTab = getTableEntry (ic->op);
 
   dbuf_init (&tmpBuf, 1024);
@@ -259,13 +260,15 @@ printILine (iCode *ic)
       icTab->iCodePrint (&tmpBuf, ic, icTab->printName);
     }
 
+  len = dbuf_get_length (&tmpBuf);
+
   /* null terminate the buffer */
   dbuf_c_str (&tmpBuf);
   verbalICode = dbuf_detach (&tmpBuf);
 
   /* kill the trailing NL */
-  if ('\n' == verbalICode[strlen(verbalICode) - 1])
-    verbalICode[strlen(verbalICode) - 1] = '\0';
+  if (len > 0 && '\n' == verbalICode[len - 1])
+    verbalICode[--len] = '\0';
 
   /* and throw it up */
   return verbalICode;
@@ -295,7 +298,7 @@ skipLine (FILE *infp)
           /* EOF in the middle of the line */
           is_eof = 1;
           return 1;
-        }  
+        }
       else
         return 0;
     }
@@ -315,6 +318,7 @@ printCLine (const char *srcFile, int lineno)
   static struct dbuf_s lastSrcFile;
   static char dbufInitialized = 0;
   static int inLineNo = 0;
+  size_t len;
 
   if (!dbufInitialized)
     {
@@ -374,17 +378,16 @@ printCLine (const char *srcFile, int lineno)
     }
 
    /* get the line */
-  if (dbuf_getline (&line, inFile))
+  if (0 != (len = dbuf_getline (&line, inFile)))
     {
       const char *inLineString = dbuf_c_str (&line);
-      size_t len = strlen (inLineString);
 
       ++inLineNo;
 
       /* remove the trailing NL */
-      if ('\n' == inLineString[len - 1])
+      if (len > 0 &&'\n' == inLineString[len - 1])
         {
-          dbuf_set_length (&line, len - 1);
+          dbuf_set_length (&line, --len);
           inLineString = dbuf_c_str (&line);
         }