home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume15 / dis88 / part01 / dis.h next >
Encoding:
C/C++ Source or Header  |  1988-05-23  |  7.4 KB  |  204 lines

  1.  /*
  2.  ** @(#) dis.h, Ver. 2.1 created 00:00:00 87/09/01
  3.  */
  4.  
  5.  /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6.   *                                                         *
  7.   *  Copyright (C) 1987 G. M. Harding, all rights reserved  *
  8.   *                                                         *
  9.   * Permission to copy and  redistribute is hereby granted, *
  10.   * provided full source code,  with all copyright notices, *
  11.   * accompanies any redistribution.                         *
  12.   *                                                         *
  13.   * This file contains declarations and definitions used by *
  14.   * the 8088 disassembler program. The program was designed *
  15.   * for execution on a machine of its own type (i.e., it is *
  16.   * not designed as a cross-disassembler);  consequently, A *
  17.   * SIXTEEN-BIT INTEGER SIZE HAS BEEN ASSUMED. This assump- *
  18.   * tion is not particularly important,  however, except in *
  19.   * the machine-specific  portions of the code  (i.e.,  the *
  20.   * handler  routines and the optab[] array).  It should be *
  21.   * possible to override this assumption,  for execution on *
  22.   * 32-bit machines,  by use of a  pre-processor  directive *
  23.   * (see below); however, this has not been tested.         *
  24.   *                                                         *
  25.   * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  26.  
  27. #include <stdio.h>      /* System standard I/O definitions  */
  28. #include <fcntl.h>      /* System file-control definitions  */
  29. #include <a.out.h>      /* Object file format definitions   */
  30.  
  31. #if i8086 || i8088      /* For CPU's with 16-bit integers   */
  32. #undef int
  33. #else                   /* Defaults (for 32-bit CPU types)  */
  34. #define int short
  35. #endif
  36.  
  37. #define MAXSYM 1500     /* Maximum entries in symbol table  */
  38.  
  39. extern struct nlist     /* Array to hold the symbol table   */
  40.    symtab[MAXSYM];
  41.  
  42. extern struct reloc     /* Array to hold relocation table   */
  43.    relo[MAXSYM];
  44.  
  45. extern int symptr;      /* Index into the symtab[] array    */
  46.  
  47. extern int relptr;      /* Index into the relo[] array      */
  48.  
  49. struct opcode           /* Format for opcode data records   */
  50.    {
  51.    char     *text;            /* Pointer to mnemonic text   */
  52.    void     (*func)();        /* Pointer to handler routine */
  53.    unsigned min;              /* Minimum # of object bytes  */
  54.    unsigned max;              /* Maximum # of object bytes  */
  55.    };
  56.  
  57. extern struct opcode    /* Array to hold the opcode table   */
  58.   optab[256];
  59.  
  60.  /*
  61.    +---------------------------------------------
  62.    | The following  functions are the specialized
  63.    | handlers for each opcode group. They are, of
  64.    | course, highly MACHINE-SPECIFIC.  Each entry
  65.    | in the opcode[]  array contains a pointer to
  66.    | one of these  handlers.  The handlers in the
  67.    | first group are in  dishand.c;  those in the
  68.    | second group are in disfp.c.
  69.    +---------------------------------------------
  70.  */
  71.  
  72. extern void dfhand(),   /* Default handler routine          */
  73.             sbhand(),   /* Single-byte handler              */
  74.             aohand(),   /* Arithmetic-op handler            */
  75.             sjhand(),   /* Short-jump handler               */
  76.             imhand(),   /* Immediate-operand handler        */
  77.             mvhand(),   /* Simple move handler              */
  78.             mshand(),   /* Segreg-move handler              */
  79.             pohand(),   /* Pop memory/reg handler           */
  80.             cihand(),   /* Intersegment call handler        */
  81.             mihand(),   /* Immediate-move handler           */
  82.             mqhand(),   /* Quick-move handler               */
  83.             tqhand(),   /* Quick-test handler               */
  84.             rehand(),   /* Return handler                   */
  85.             mmhand(),   /* Move-to-memory handler           */
  86.             srhand(),   /* Shift and rotate handler         */
  87.             aahand(),   /* ASCII-adjust handler             */
  88.             iohand(),   /* Immediate port I/O handler       */
  89.             ljhand(),   /* Long-jump handler                */
  90.             mahand(),   /* Misc. arithmetic handler         */
  91.             mjhand();   /* Miscellaneous jump handler       */
  92.  
  93. extern void eshand(),   /* Bus-escape opcode handler        */
  94.             fphand(),   /* Floating-point handler           */
  95.             inhand();   /* Interrupt-opcode handler         */
  96.  
  97. extern char *REGS[];    /* Table of register names          */
  98.  
  99. extern char *REGS0[];   /* Mode 0 register name table       */
  100.  
  101. extern char *REGS1[];   /* Mode 1 register name table       */
  102.  
  103. #define AL REGS[0]      /* CPU register manifests           */
  104. #define CL REGS[1]
  105. #define DL REGS[2]
  106. #define BL REGS[3]
  107. #define AH REGS[4]
  108. #define CH REGS[5]
  109. #define DH REGS[6]
  110. #define BH REGS[7]
  111. #define AX REGS[8]
  112. #define CX REGS[9]
  113. #define DX REGS[10]
  114. #define BX REGS[11]
  115. #define SP REGS[12]
  116. #define BP REGS[13]
  117. #define SI REGS[14]
  118. #define DI REGS[15]
  119. #define ES REGS[16]
  120. #define CS REGS[17]
  121. #define SS REGS[18]
  122. #define DS REGS[19]
  123. #define BX_SI REGS0[0]
  124. #define BX_DI REGS0[1]
  125. #define BP_SI REGS0[2]
  126. #define BP_DI REGS0[3]
  127.  
  128. extern int symrank[6][6];     /* Symbol type/rank matrix    */
  129.  
  130. extern unsigned long PC;      /* Current program counter    */
  131.  
  132. extern int segflg;      /* Flag: segment override in effect */
  133.  
  134. extern int objflg;      /* Flag: output object as a comment */
  135.  
  136. #define OBJMAX 8        /* Size of the object code buffer   */
  137.  
  138. extern unsigned char    /* Internal buffer for object code  */
  139.    objbuf[OBJMAX];
  140.  
  141. extern void objini(),   /* Object-buffer init routine       */
  142.             objout();   /* Object-code output routine       */
  143.  
  144. extern int objptr;      /* Index into the objbuf[] array    */
  145.  
  146. extern void badseq();   /* Bad-code-sequence function       */
  147.  
  148. extern char *getnam();  /* Symbol-name string function      */
  149.  
  150. extern char *lookup();  /* Symbol-table lookup function     */
  151.  
  152. extern int lookext();   /* Extern-definition lookup routine */
  153.  
  154. extern char *mtrans();  /* Interpreter for the mode byte    */
  155.  
  156. extern void mtrunc();   /* Mode string truncator function   */
  157.  
  158. extern char ADD[],      /* Opcode family mnemonic strings   */
  159.             OR[],
  160.             ADC[],
  161.             SBB[],
  162.             AND[],
  163.             SUB[],
  164.             XOR[],
  165.             CMP[],
  166.             NOT[],
  167.             NEG[],
  168.             MUL[],
  169.             DIV[],
  170.             MOV[],
  171.             ESC[],
  172.             TEST[],
  173.             AMBIG[];
  174.  
  175. extern char *OPFAM[];   /* Indexed mnemonic family table    */
  176.  
  177. extern struct exec HDR; /* Holds the object file's header   */
  178.  
  179. #define LOOK_ABS 0      /* Arguments to lookup() function   */
  180. #define LOOK_REL 1
  181. #define LOOK_LNG 2
  182.  
  183. #define TR_STD 0        /* Arguments to mtrans() function   */
  184. #define TR_SEG 8
  185.  
  186.                         /* Macro for byte input primitive   */
  187. #define FETCH(p) \
  188.    ++PC; p = getchar() & 0xff; objbuf[objptr++] = p
  189.  
  190. extern int close();     /* System file-close primitive      */
  191. extern int fprintf();   /* Library file-output function     */
  192. extern long lseek();    /* System file-position primitive   */
  193. extern int open();      /* System file-open primitive       */
  194. extern int printf();    /* Library output-format function   */
  195. extern int read();      /* System file-read primitive       */
  196. extern int sprintf();   /* Library string-output function   */
  197. extern char *strcat();  /* Library string-join function     */
  198. extern char *strcpy();  /* Library string-copy function     */
  199. extern int strlen();    /* Library string-length function   */
  200.  
  201.  /* * * * * * * * * * *  END OF  dis.h  * * * * * * * * * * */
  202.  
  203.  
  204.