replace non-ANSI strcmpi by as_strcmpi
[fw/sdcc] / as / mcs51 / aslink.h
index 2fd486eaa4e9016ab8f3123d0e1e3bf795f31cc3..6928054f2e9d00116254e630bc5c0f4bc5b1e66b 100644 (file)
 #define        OTHERSYSTEM 
 #endif
 
+/*
+ * PATH_MAX
+ */
+#include <limits.h>
+#ifndef PATH_MAX               /* POSIX, but not required   */
+ #if defined(__BORLANDC__) || defined(_MSC_VER)
+  #include <stdlib.h>
+  #define PATH_MAX     _MAX_PATH
+ #else
+  #define PATH_MAX     255     /* define a reasonable value */
+ #endif
+#endif
+
 /*
  * This file defines the format of the
  * relocatable binary file.
 
 #define NCPS   80              /* characters per symbol (JLH: change from 8) */
 #define        NDATA   16              /* actual data */
-#define        NINPUT  128             /* Input buffer size */
+#define        NINPUT  PATH_MAX        /* Input buffer size */
 #define        NHASH   64              /* Buckets in hash table */
 #define        HMASK   077             /* Hash mask */
 #define        NLPP    60              /* Lines per page */
 #define        NTXT    16              /* T values */
-#define        FILSPC  80              /* File spec length */
 
 /*
  *     The "R_" relocation constants define values used in
  *         +-----+-----+-----+-----+-----+-----+-----+-----+
  */
 
-#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  0000            /* Base type */
-#define        R_SYM   0002
+#define        R_AREA  0x00            /* Base type */
+#define        R_SYM   0x02
 
-#define        R_NORM  0000            /* PC adjust */
-#define        R_PCR   0004
+#define        R_NORM  0x00            /* PC adjust */
+#define        R_PCR   0x04
 
-#define        R_BYT1  0000            /* Byte count for R_BYTE = 1 */
-#define        R_BYT2  0010            /* Byte count for R_BYTE = 2 */
+#define        R_BYT1  0x00            /* Byte count for R_BYTE = 1 */
+#define        R_BYT2  0x08            /* Byte count for R_BYTE = 2 */
 
-#define        R_SGND  0000            /* Signed value */
-#define        R_USGN  0020            /* Unsigned value */
+#define        R_SGND  0x00            /* Signed Byte */
+#define        R_USGN  0x10            /* Unsigned Byte */
 
-#define        R_NOPAG 0000            /* Page Mode */
-#define        R_PAG0  0040            /* Page '0' */
-#define        R_PAG   0100            /* Page 'nnn' */
+#define        R_NOPAG 0x00            /* Page Mode */
+#define        R_PAG0  0x20            /* Page '0' */
+#define        R_PAG   0x40            /* Page 'nnn' */
 
-/*
- * Valid for R_BYT2:
- */
-#define        R_LSB   0000            /* output low byte */
-#define        R_MSB   0200            /* output high byte */
+#define        R_LSB   0x00            /* low byte */
+#define        R_MSB   0x80            /* 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 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.
+                                */
+
 /*
  * Global symbol types.
  */
 /*
  *     General assembler address type
  */
-typedef unsigned int addr_t;
+typedef unsigned int Addr_T;
 
 /*
  *     The structures of head, area, areax, and sym are created
@@ -219,8 +242,8 @@ struct      area
 {
        struct  area    *a_ap;  /* Area link */
        struct  areax   *a_axp; /* Area extension link */
-       addr_t  a_addr;         /* Beginning address of area */
-       addr_t  a_size;         /* Total size of the area */
+       Addr_T  a_addr;         /* Beginning address of area */
+       Addr_T  a_size;         /* Total size of the area */
        char    a_type;         /* Area subtype */
        char    a_flag;         /* Flag byte */
        char    a_id[NCPS];     /* Name */
@@ -246,8 +269,8 @@ struct      areax
        struct  areax   *a_axp; /* Area extension link */
        struct  area    *a_bap; /* Base area link */
        struct  head    *a_bhp; /* Base header link */
-       addr_t  a_addr;         /* Beginning address of section */
-       addr_t  a_size;         /* Size of the area in section */
+       Addr_T  a_addr;         /* Beginning address of section */
+       Addr_T  a_size;         /* Size of the area in section */
 };
 
 /*
@@ -268,7 +291,7 @@ struct      sym
        struct  areax   *s_axp; /* Symbol area link */
        char    s_type;         /* Symbol subtype */
        char    s_flag;         /* Flag byte */
-       addr_t  s_addr;         /* Address */
+       Addr_T  s_addr;         /* Address */
        char    *s_id;          /* Name: JLH change from [NCPS] */
 };
 
@@ -317,7 +340,7 @@ struct      sdp
 {
        struct  area  *s_area;  /* Paged Area link */
        struct  areax *s_areax; /* Paged Area Extension Link */
-       addr_t  s_addr;         /* Page address offset */
+       Addr_T  s_addr;         /* Page address offset */
 };
 
 /*
@@ -334,9 +357,9 @@ struct      rerr
 {
        int     aindex;         /* Linking area */
        int     mode;           /* Relocation mode */
-       addr_t  rtbase;         /* Base address in section */
+       Addr_T  rtbase;         /* Base address in section */
        int     rindex;         /* Area/Symbol reloaction index */
-       addr_t  rval;           /* Area/Symbol offset value */
+       Addr_T  rval;           /* Area/Symbol offset value */
 };
 
 /*
@@ -431,7 +454,7 @@ extern      char    *rp;            /*      pointer into the LST file
 extern char    rb[NINPUT];     /*      LST file text line being
                                 *      address relocated
                                 */
-extern char    ctype[];        /*      array of character types, one per
+extern unsigned char   ctype[];        /*      array of character types, one per
                                 *      ASCII character
                                 */
 
@@ -547,6 +570,8 @@ extern      int     oflag;          /*      Output file type flag
                                 */
 extern int     mflag;          /*      Map output flag
                                 */
+extern int     sflag;          /*      JCF: Memory usage output flag
+                                */
 extern int     jflag;          /*      NoICE output flag
                                 */
 extern int     xflag;          /*      Map file radix type flag
@@ -572,7 +597,7 @@ extern      int     pass;           /*      linker pass number
 extern int     rtcnt;          /*      count of elements in the
                                 *      rtval[] and rtflg[] arrays
                                 */
-extern addr_t  rtval[];        /*      data associated with relocation
+extern Addr_T  rtval[];        /*      data associated with relocation
                                 */
 extern int     rtflg[];        /*      indicates if rtval[] value is
                                 *      to be sent to the output file.
@@ -595,7 +620,7 @@ extern      struct lbname *lbnhead; /*      pointer to the first
 extern struct lbfile *lbfhead; /*      pointer to the first
                                 *      library file structure
                                 */
-extern addr_t iram_size;       /*      internal ram size
+extern Addr_T iram_size;       /*      internal ram size
                                 */
 
 
@@ -622,7 +647,7 @@ extern      VOID            bassav();
 extern VOID            gblsav();
 extern VOID            iramsav();
 extern VOID            iramcheck();
-extern VOID            link();
+extern VOID            link_main();
 extern VOID            lkexit();
 extern int             main();
 extern VOID            map();
@@ -637,12 +662,14 @@ extern    char            endline();
 extern char            get();
 extern VOID            getfid();
 extern VOID            getid();
+extern VOID            getSid();
 extern int             getline();
 extern int             getmap();
 extern char            getnb();
 extern int             more();
 extern VOID            skip();
 extern VOID            unget();
+extern VOID            chop_crlf();
 
 /* lkarea.c */
 extern VOID            lkparea();
@@ -663,14 +690,14 @@ extern    VOID            symdef();
 extern int             symeq();
 extern VOID            syminit();
 extern VOID            symmod();
-extern addr_t          symval();
+extern Addr_T          symval();
 
 /* lkeval.c */
 extern int             digit();
-extern addr_t          eval();
-extern addr_t          expr();
+extern Addr_T          eval();
+extern Addr_T          expr();
 extern int             oprio();
-extern addr_t          term();
+extern Addr_T          term();
 
 /* lklist.c */
 extern int             dgt();
@@ -682,14 +709,17 @@ extern    VOID            newpag();
 extern VOID            slew();
 
 /* lkrloc.c */
-extern addr_t          adb_b();
-extern addr_t          adb_hi();
-extern addr_t          adb_lo();
-extern addr_t          adw_w();
-extern addr_t          adw_24(addr_t, int);
-extern addr_t          adw_hi();
-extern addr_t          adw_lo();
-extern addr_t          evword();
+extern Addr_T          adb_b();
+extern Addr_T          adb_hi();
+extern Addr_T          adb_lo();
+extern Addr_T          adb_24_hi(Addr_T v, int i);
+extern Addr_T          adb_24_mid(Addr_T v, int i);
+extern Addr_T          adb_24_lo(Addr_T v, int i);
+extern Addr_T          adw_w();
+extern Addr_T          adw_24(Addr_T, int);
+extern Addr_T          adw_hi();
+extern Addr_T          adw_lo();
+extern Addr_T          evword();
 extern VOID            rele();
 extern VOID            reloc();
 extern VOID            relt();
@@ -717,14 +747,16 @@ extern    VOID            s19();
 
 /* lkihx.c */
 extern VOID            ihx();
-extern VOID            ihxEntendedLinearAddress(addr_t);
+extern VOID            ihxEntendedLinearAddress(Addr_T);
 /* lkstore.c */
 extern char            *StoreString( char *str );
 
 /* lknoice.c */
-extern void             DefineNoICE( char *name, addr_t value, int page );
+extern void             DefineNoICE( char *name, Addr_T value, int page );
 
-/* SD added this to change
-       strcmpi --> strcmp (strcmpi NOT ANSI) */
-#define strcmpi strcmp
+/* JCF: lkmem.c */
+extern int summary(struct area * xp);
 
+/* JCF: lkaomf51.c */
+extern void SaveLinkedFilePath(char * filepath);
+extern void CreateAOMF51(void);