replace non-ANSI strcmpi by as_strcmpi
[fw/sdcc] / as / mcs51 / asm.h
index e02290541db561c7d368be95029e047a455f23c1..b66ab5118009f7ce80dd09f456b6b62a693bd70b 100644 (file)
  *           - prototypes for DefineNoICE_Line
  * 30-Jan-98 JLH:
  *           - add memory space flags to a_flag for 8051
+ *
+ *  3-Feb-00 KV:
+ *          - add DS80C390 flat mode support.
  */
 
-#define        VERSION "V01.70 + NoICE + SDCC mods Feb-1999"
+#define        VERSION "V01.70 + NoICE + SDCC mods + Flat24 Feb-1999"
+
+#if !defined(__BORLANDC__) && !defined(_MSC_VER)
+#include <unistd.h>
+#endif
 
 /*
  * Case Sensitivity Flag
 #define        OTHERSYSTEM
 #endif
 
+/*
+ * PATH_MAX
+ */
+#include <limits.h>
+#ifndef PATH_MAX               /* POSIX, but not required   */
+#ifdef _MSC_VER                        /* Microsoft C */
+#include <stdlib.h>
+#define PATH_MAX       _MAX_PATH
+#else
+#define PATH_MAX               /* define a reasonable value */
+#endif
+#endif
+
 /*
  * Assembler definitions.
  */
@@ -78,7 +98,7 @@
 #define NCPS   80              /* Chars. per symbol (JLH: change from 8) */
 #define        HUGE    1000            /* A huge number */
 #define NERR   3               /* Errors per line */
-#define NINPUT 128             /* Input buffer size */
+#define        NINPUT  PATH_MAX        /* Input buffer size (BH: change from 128) */
 #define NCODE  128             /* Listing code buffer size */
 #define NTITL  64              /* Title buffer size */
 #define        NSBTL   64              /* SubTitle buffer size */
 #define        MAXFIL  6               /* Maximum command line input files */
 #define        MAXINC  6               /* Maximum nesting of include files */
 #define        MAXIF   10              /* Maximum nesting of if/else/endif */
-#define        FILSPC  80              /* Chars. in filespec */
 
 #define NLIST  0               /* No listing */
 #define SLIST  1               /* Source only */
 #define        dca     area[0]         /* Dca, default code area */
 
 
-typedef        unsigned int addr_t;
+/* NB: for Flat24 extentions to work, Addr_T must be at least 24
+ * bits. This is checked at runtime when the .flat24 directive 
+ * is processed.
+ */
+typedef        unsigned int Addr_T;
 
 /*
  *     The area structure contains the parameter values for a
@@ -122,8 +145,8 @@ struct      area
        struct  area *a_ap;     /* Area link */
        char    a_id[NCPS];     /* Area Name */
        int     a_ref;          /* Ref. number */
-       addr_t  a_size;         /* Area size */
-       addr_t  a_fuzz;         /* Area fuzz */
+       Addr_T  a_size;         /* Area size */
+       Addr_T  a_fuzz;         /* Area fuzz */
        int     a_flag;         /* Area flags */
 };
 
@@ -165,29 +188,50 @@ struct    area
  *     +-----+-----+-----+-----+-----+-----+-----+-----+
  */
 
-#define        R_WORD  0000            /* 16 bit */
-#define        R_BYTE  0001            /*  8 bit */
+#define        R_WORD  0x00            /* 16 bit */
+#define        R_BYTE  0x01            /*  8 bit */
+
+#define        R_AREA  0x00            /* Base type */
+#define        R_SYM   0x02
 
-#define        R_AREA  0000            /* Base type */
-#define        R_SYM   0002
+#define        R_NORM  0x00            /* PC adjust */
+#define        R_PCR   0x04
 
-#define        R_NORM  0000            /* PC adjust */
-#define        R_PCR   0004
+#define        R_BYT1  0x00            /* Byte count for R_BYTE = 1 */
+#define        R_BYT2  0x08            /* Byte count for R_BYTE = 2 */
 
-#define        R_BYT1  0000            /* Byte count for R_BYTE = 1 */
-#define        R_BYT2  0010            /* Byte count for R_BYTE = 2 */
+#define        R_SGND  0x00            /* Signed Byte */
+#define        R_USGN  0x10            /* Unsigned Byte */
 
-#define        R_SGND  0000            /* Signed Byte */
-#define        R_USGN  0020            /* Unsigned Byte */
+#define        R_NOPAG 0x00            /* Page Mode */
+#define        R_PAG0  0x20            /* Page '0' */
+#define        R_PAG   0x40            /* Page 'nnn' */
 
-#define        R_NOPAG 0000            /* Page Mode */
-#define        R_PAG0  0040            /* Page '0' */
-#define        R_PAG   0100            /* Page 'nnn' */
+#define        R_LSB   0x00            /* low byte */
+#define        R_MSB   0x80            /* high byte */
 
-#define        R_LSB   0000            /* low byte */
-#define        R_MSB   0200            /* high byte */
+#define R_BYT3 0x100           /* if R_BYTE is set, this is a 
+                                * 3 byte address, of which
+                                * the linker must select one byte.
+                                */
+#define R_HIB  0x200           /* If R_BYTE & R_BYT3 are set, linker
+                                * will select byte 3 of the relocated
+                                * 24 bit address.
+                                */
 
 #define R_J11   (R_WORD|R_BYT2)        /* JLH: 11 bit JMP and CALL (8051) */
+#define R_J19   (R_WORD|R_BYT2|R_MSB) /* 19 bit JMP/CALL (DS80C390) */
+#define R_C24   (R_WORD|R_BYT1|R_MSB) /* 24 bit address (DS80C390) */
+#define R_J19_MASK (R_BYTE|R_BYT2|R_MSB)
+
+#define IS_R_J19(x) (((x) & R_J19_MASK) == R_J19)
+#define IS_R_J11(x) (((x) & R_J19_MASK) == R_J11)
+#define IS_C24(x) (((x) & R_J19_MASK) == R_C24)
+
+#define R_ESCAPE_MASK  0xf0    /* Used to escape relocation modes
+                                * greater than 0xff in the .rel
+                                * file.
+                                */
 
 /*
  * Listing Control Flags
@@ -222,7 +266,7 @@ struct      mne
        char    *m_id;          /* Mnemonic JLH: change from [NCPS] */
        char    m_type;         /* Mnemonic subtype */
        char    m_flag;         /* Mnemonic flags */
-       addr_t  m_valu;         /* Value */
+       Addr_T  m_valu;         /* Value */
 };
 
 /*
@@ -247,7 +291,7 @@ struct      sym
        char    s_flag;         /* Symbol flags */
        struct  area *s_area;   /* Area line, 0 if absolute */
        int     s_ref;          /* Ref. number */
-       addr_t  s_addr;         /* Address */
+       Addr_T  s_addr;         /* Address */
 };
 
 #define        S_GBL           01      /* Global */
@@ -283,6 +327,7 @@ struct      sym
 #define        S_ORG           24      /* .org */
 #define        S_MODUL         25      /* .module */
 #define        S_ASCIS         26      /* .ascis */
+#define        S_FLAT24        27      /* .flat24 */
 
 
 /*
@@ -305,7 +350,7 @@ struct      tsym
        int t_flg;              /* flags */
 
        struct  area *t_area;   /* Area */
-       addr_t  t_addr;         /* Address */
+       Addr_T  t_addr;         /* Address */
 };
 
 /*
@@ -338,16 +383,16 @@ extern    int     iflvl[MAXIF+1]; /*      array of IF-ELSE-ENDIF flevel
                                 *      values indexed by tlevel
                                 */
 extern char
-       afn[FILSPC];            /*      afile() temporary filespec
+       afn[PATH_MAX];          /*      afile() temporary filespec
                                 */
 extern char
-       srcfn[MAXFIL][FILSPC];  /*      array of source file names
+       srcfn[MAXFIL][PATH_MAX];        /*      array of source file names
                                 */
 extern int
        srcline[MAXFIL];        /*      current source file line
                                 */
 extern char
-       incfn[MAXINC][FILSPC];  /*      array of include file names
+       incfn[MAXINC][PATH_MAX];        /*      array of include file names
                                 */
 extern int
        incline[MAXINC];        /*      current include file line
@@ -385,10 +430,10 @@ extern    int     xflag;          /*      -x, listing radix flag
                                 */
 extern int     fflag;          /*      -f(f), relocations flagged flag
                                 */
-extern addr_t  laddr;          /*      address of current assembler line
+extern Addr_T  laddr;          /*      address of current assembler line
                                 *      or value of .if argument
                                 */
-extern addr_t  fuzz;           /*      tracks pass to pass changes in the
+extern Addr_T  fuzz;           /*      tracks pass to pass changes in the
                                 *      address of symbols caused by
                                 *      variable length instruction formats
                                 */
@@ -433,6 +478,9 @@ extern      char    tb[NTITL];      /*      Title string buffer
                                 */
 extern char    stb[NSBTL];     /*      Subtitle string buffer
                                 */
+extern         int     flat24Mode;     /*      non-zero if we are using DS390 24 bit 
+                                *      flat mode (via .flat24 directive). 
+                                */
 extern char    symtbl[];       /*      string "Symbol Table"
                                 */
 extern char    aretbl[];       /*      string "Area Table"
@@ -495,12 +543,12 @@ struct    expr
 {
        char    e_mode;         /* Address mode */
        char    e_flag;         /* Symbol flag */
-       addr_t  e_addr;         /* Address */
+       Addr_T  e_addr;         /* Address */
        union   {
                struct area *e_ap;
                struct sym  *e_sp;
        } e_base;               /* Rel. base */
-       char    e_rlcf;         /* Rel. flags */
+       int     e_rlcf;         /* Rel. flags */
 };
 
 /* C Library functions */
@@ -543,6 +591,7 @@ extern      char            getnb();
 extern VOID            getst();
 extern int             more();
 extern VOID            unget();
+extern VOID            chop_crlf();
 
 /* assym.c */
 extern struct  area *  alookup();
@@ -559,13 +608,14 @@ extern    VOID            allglob();
 extern VOID            aerr();
 extern VOID            diag();
 extern VOID            err();
+extern         VOID            warnBanner(void);
 extern char *          geterr();
 extern VOID            qerr();
 extern VOID            rerr();
 
 /* asexpr.c */
 extern VOID            abscheck();
-extern addr_t          absexpr();
+extern Addr_T          absexpr();
 extern VOID            clrexpr();
 extern int             digit();
 extern int             is_abs();
@@ -583,6 +633,7 @@ extern      VOID            slew();
 /* asout.c */
 extern int             hibyte();
 extern int             lobyte();
+extern         int             byte3(int);
 extern VOID            out();
 extern VOID            outab();
 extern VOID            outarea();
@@ -593,13 +644,17 @@ extern    VOID            outbuf();
 extern VOID            outchk();
 extern VOID            outgsd();
 extern VOID            outrb();
-extern VOID            outrw();
+extern VOID            outrw(struct expr *, int);
+extern VOID            outr24(struct expr *, int);
 extern VOID            outsym();
 extern VOID            out_lb();
 extern VOID            out_lw();
+extern VOID            out_l24(int, int);
 extern VOID            out_rw();
 extern VOID            out_tw();
+extern VOID            out_t24(int);
 extern VOID            outr11();       /* JLH */
+extern VOID            outr19(struct expr *, int, int);
 
 /* asstore.c */
 extern char *StoreString( char *str );
@@ -617,9 +672,5 @@ extern      struct  mne     mne[];
 
 /* Machine dependent functions */
 
-extern VOID            machin();
 extern VOID            minit();
-
-/* SD added THIS define to change
-   strcmpi --> strcmp (strcmpi is NOT ANSI) */
-#define strcmpi strcmp
+extern VOID machine(struct mne *);