home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / SRC / unc.lzh / UNC / unc.h < prev   
Text File  |  1991-06-10  |  4KB  |  165 lines

  1. /*
  2.  *    SCCS:    %W%    %G%    %U%
  3.  *    Header file for uncompile program.
  4.  *
  5.  *EMACS_MODES:c
  6.  */
  7. #include <module.h>
  8.  
  9. #define LWORD unsigned long
  10. #define WORD unsigned short
  11. #define BYTE unsigned char
  12.  
  13. #define    MAXCHARS    50
  14. #define    HASHMOD        97
  15.  
  16. #ifdef __MAIN__
  17. #define GLOBVAR
  18. #else
  19. #define GLOBVAR extern
  20. #endif /* hcz */
  21.  
  22. /*
  23.  *    The following structure is used to keep track of symbols.
  24.  */
  25.  
  26. struct    symstr    {
  27.     struct    symstr    *s_next;        /*  Next in hash chain  */
  28.     struct    symstr    *s_link;        /*  Next in duplicate labels */
  29.     unsigned    s_type    :  3;        /*  Symbol type  */
  30.     unsigned    s_newsym:  1;        /*  A new symbol  */
  31.     unsigned    s_invent:  1;        /*  Invented symbol  */
  32.     long        s_value;        /*  Value if defined  */
  33.     short        s_defs;            /*  Defined count  */
  34.     short        s_used;            /*  Used count  */
  35.     char        s_name[1];        /*  Chars of name null term */
  36. };
  37.  
  38. typedef    struct    symstr    *symbol;
  39.  
  40.  
  41. typedef    struct    {
  42.     int    ef_t;            /*  Text file fd  */
  43.     char   *t_name;            /*  Text filename */
  44.     int    ef_d;            /*  Data file fd  */
  45.     char   *d_name;            /*  Data filename */
  46.     int    ef_stcnt;                /*  Number of symbols */
  47.     int    ef_stmax;                /*  Max. number of symbols */
  48.     symbol *ef_stvec;        /*  Symbol vector */
  49. }  ef_fids;
  50.  
  51. typedef    ef_fids    *ef_fid;
  52.  
  53. /*
  54.  *    Description of word in text file.  This entry is held in the place
  55.  *    corresponding to the address in the text file.
  56.  */
  57.  
  58. typedef    struct    {
  59.     unsigned  short    t_contents;        /*  Actual contents  */
  60.     unsigned  short t_iindex;        /*  Index in table  */
  61.  
  62.     unsigned    t_type    :  2;        /*  Type  */
  63. #define    T_UNKNOWN    0
  64. #define    T_OPCODE    1
  65. #define    T_ARGUMENT    2
  66.  
  67.     unsigned    t_vins  :  1;        /*  Valid instruction  */
  68.     unsigned    t_bdest    :  1;        /*  Is branch dest  */
  69.     unsigned    t_gbdest:  1;        /*  Is global dest  */
  70.     unsigned    t_dref    :  1;        /*  Refered to in data  */
  71.     unsigned    t_bchtyp:  2;        /*  Branch type  */
  72.     unsigned    t_lng    :  3;        /*  Length in words  */
  73.     unsigned    t_amap    :  1;        /*  Worked out  */
  74.     symbol        t_relsymb;        /*  Relocation symbol  */
  75.     symbol        t_lab;            /*  Label  */
  76.     long        t_reflo;        /*  Lowest place referred  */
  77.     long        t_refhi;        /*  Highest place referred  */
  78. }  t_entry;
  79.  
  80.  
  81. #define    R_NONE        0        /*  No relocation  */
  82. #define    R_BYTE        1        /*  Byte relocation  */
  83. #define    R_WORD        2        /*  Word relocation  */
  84. #define    R_LONG        3        /*  Long relocation  */
  85.  
  86. /*
  87.  *    Branch types.
  88.  */
  89.  
  90. #define    T_NOBR        0
  91. #define    T_CONDBR    1
  92. #define    T_UNBR        2
  93. #define    T_JSR        3
  94.  
  95. typedef    struct    {
  96.     unsigned  char    d_contents;        /*  Actual contents  */
  97.     unsigned    d_initialized : 1;    /*  initialized (from file) */
  98.     unsigned    d_type  :  4;        /*  Data type  */
  99.     unsigned    d_reloc :  2;        /*  Relocatable  */
  100.     unsigned    d_rptr    :  2;        /*  Where relocated  */
  101.     short        d_lng;            /*  Length -ve for D_CONT */
  102.     symbol        d_relsymb;        /*  Relocation symbol  */
  103.     long        d_reldisp;        /*  Offset + or - from symb */
  104.     symbol        d_lab;            /*  Label  */
  105. }  d_entry;
  106.  
  107. /*
  108.  *    Data types.
  109.  */
  110.  
  111. #define    D_ASC        0        /*  Ascii chars  */
  112. #define    D_ASCZ        1        /*  Null-term ascii  */
  113. #define    D_BYTE        2        /*  Decimal bytes  */
  114. #define    D_WORD        3        /*  Words  */
  115. #define    D_LONG        4        /*  Longs  */
  116. #define    D_ADDR        5        /*  Address pointer  */
  117. #define    D_CONT        6        /*  Continuation of last  */
  118.  
  119. /*
  120.  *    'Common' items.
  121.  */
  122.  
  123. struct    commit    {
  124.     symbol    *c_symb;        /*  List of symbols  */
  125.     int    c_int;            /*  Current number  */
  126.     int    c_max;            /*  Maximum  */
  127. };
  128.  
  129. /*
  130.  *    Library file description.
  131.  */
  132.  
  133. struct    libit    {
  134.     int    lf_fd;            /*  File descriptor  */
  135.     long    lf_offset;        /*  Offset of current file  */
  136.     long    lf_next;        /*  Offset of next file  */
  137.     char    lf_name[14];        /*  Name of item  */
  138. };
  139.  
  140. #define PFIRST 20
  141. #define LABEL 0
  142. #define OPCODE 10
  143. #define ARGUMENT 20
  144. #define COMMENT 45
  145. #define STRING 45
  146.  
  147. #define ISOK 0
  148. #define ISFALSCH 1
  149. #define ISFEHLER -1
  150.  
  151. /*
  152.  * global variables
  153.  */
  154. extern int errno;
  155. GLOBVAR symbol    symbhash[HASHMOD];
  156. GLOBVAR mod_exec hdr; 
  157. GLOBVAR int popt;
  158. GLOBVAR ef_fids   mainfile;
  159. GLOBVAR int xp;
  160. GLOBVAR short ismodule;
  161. GLOBVAR unsigned long a6offset;
  162. GLOBVAR long endp;
  163. GLOBVAR short  verbose, ropt, debug, xact;
  164.  
  165.