dis.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*
  2. ** @(#) dis.h, Ver. 2.1 created 00:00:00 87/09/01
  3. */
  4. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  5. * *
  6. * Copyright (C) 1987 G. M. Harding, all rights reserved *
  7. * *
  8. * Permission to copy and redistribute is hereby granted, *
  9. * provided full source code, with all copyright notices, *
  10. * accompanies any redistribution. *
  11. * *
  12. * This file contains declarations and definitions used by *
  13. * the 8088 disassembler program. The program was designed *
  14. * for execution on a machine of its own type (i.e., it is *
  15. * not designed as a cross-disassembler); consequently, A *
  16. * SIXTEEN-BIT INTEGER SIZE HAS BEEN ASSUMED. This assump- *
  17. * tion is not particularly important, however, except in *
  18. * the machine-specific portions of the code (i.e., the *
  19. * handler routines and the optab[] array). It should be *
  20. * possible to override this assumption, for execution on *
  21. * 32-bit machines, by use of a pre-processor directive *
  22. * (see below); however, this has not been tested. *
  23. * *
  24. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  25. #include <sys/types.h>
  26. #include <fcntl.h> /* System file-control definitions */
  27. #include <unistd.h>
  28. #include <string.h>
  29. #include <stdlib.h>
  30. #include <stdio.h> /* System standard I/O definitions */
  31. #include "a.out.h" /* Object file format definitions */
  32. #include "ansi.h"
  33. #define MAXSYM ((sizeof(int)-1)*32400/ \
  34. (sizeof(struct nlist)+sizeof(struct reloc)))
  35. /* Maximum entries in symbol table */
  36. extern struct nlist /* Array to hold the symbol table */
  37. symtab[MAXSYM];
  38. extern struct reloc /* Array to hold relocation table */
  39. relo[MAXSYM];
  40. extern int symptr; /* Index into the symtab[] array */
  41. extern int relptr; /* Index into the relo[] array */
  42. struct opcode /* Format for opcode data records */
  43. {
  44. char *text; /* Pointer to mnemonic text */
  45. void (*func)(); /* Pointer to handler routine */
  46. unsigned min; /* Minimum # of object bytes */
  47. unsigned max; /* Maximum # of object bytes */
  48. };
  49. extern struct opcode /* Array to hold the opcode table */
  50. optab[256];
  51. extern char *REGS[]; /* Table of register names */
  52. extern char *REGS0[]; /* Mode 0 register name table */
  53. extern char *REGS1[]; /* Mode 1 register name table */
  54. #define AL REGS[0] /* CPU register manifests */
  55. #define CL REGS[1]
  56. #define DL REGS[2]
  57. #define BL REGS[3]
  58. #define AH REGS[4]
  59. #define CH REGS[5]
  60. #define DH REGS[6]
  61. #define BH REGS[7]
  62. #define AX REGS[8]
  63. #define CX REGS[9]
  64. #define DX REGS[10]
  65. #define BX REGS[11]
  66. #define SP REGS[12]
  67. #define BP REGS[13]
  68. #define SI REGS[14]
  69. #define DI REGS[15]
  70. #define ES REGS[16]
  71. #define CS REGS[17]
  72. #define SS REGS[18]
  73. #define DS REGS[19]
  74. #define BX_SI REGS0[0]
  75. #define BX_DI REGS0[1]
  76. #define BP_SI REGS0[2]
  77. #define BP_DI REGS0[3]
  78. extern int symrank[6][6]; /* Symbol type/rank matrix */
  79. extern unsigned long PC; /* Current program counter */
  80. extern int segflg; /* Flag: segment override in effect */
  81. extern int objflg; /* Flag: output object as a comment */
  82. #define OBJMAX 8 /* Size of the object code buffer */
  83. extern unsigned char /* Internal buffer for object code */
  84. objbuf[OBJMAX];
  85. extern int objptr; /* Index into the objbuf[] array */
  86. extern char ADD[], /* Opcode family mnemonic strings */
  87. OR[],
  88. ADC[],
  89. SBB[],
  90. AND[],
  91. SUB[],
  92. XOR[],
  93. CMP[],
  94. NOT[],
  95. NEG[],
  96. MUL[],
  97. DIV[],
  98. MOV[],
  99. ESC[],
  100. TEST[],
  101. AMBIG[];
  102. extern char *OPFAM[]; /* Indexed mnemonic family table */
  103. extern struct exec HDR; /* Holds the object file's header */
  104. #define LOOK_ABS 0 /* Arguments to lookup() function */
  105. #define LOOK_REL 1
  106. #define LOOK_LNG 2
  107. #define TR_STD 0 /* Arguments to mtrans() function */
  108. #define TR_SEG 8
  109. /* Macro for byte input primitive */
  110. /* #define FETCH(p) ++PC; p = getchar() & 0xff; objbuf[objptr++] = p */
  111. static int _F_;
  112. #define FETCH(p) (p)=_F_ = Fetch(); if(_F_<0) {printf("???\n"); return FRV; }
  113. #define FRV
  114. /* disfp.c */
  115. _PROTOTYPE(void eshand, (int j ));
  116. _PROTOTYPE(void fphand, (int j ));
  117. _PROTOTYPE(void inhand, (int j ));
  118. /* dishand.c */
  119. _PROTOTYPE(void objini, (int j ));
  120. _PROTOTYPE(void objout, (void));
  121. _PROTOTYPE(void badseq, (int j, int k ));
  122. _PROTOTYPE(void dfhand, (int j ));
  123. _PROTOTYPE(void sbhand, (int j ));
  124. _PROTOTYPE(void aohand, (int j ));
  125. _PROTOTYPE(void sjhand, (int j ));
  126. _PROTOTYPE(void imhand, (int j ));
  127. _PROTOTYPE(void mvhand, (int j ));
  128. _PROTOTYPE(void mshand, (int j ));
  129. _PROTOTYPE(void pohand, (int j ));
  130. _PROTOTYPE(void cihand, (int j ));
  131. _PROTOTYPE(void mihand, (int j ));
  132. _PROTOTYPE(void mqhand, (int j ));
  133. _PROTOTYPE(void tqhand, (int j ));
  134. _PROTOTYPE(void rehand, (int j ));
  135. _PROTOTYPE(void mmhand, (int j ));
  136. _PROTOTYPE(void srhand, (int j ));
  137. _PROTOTYPE(void aahand, (int j ));
  138. _PROTOTYPE(void iohand, (int j ));
  139. _PROTOTYPE(void ljhand, (int j ));
  140. _PROTOTYPE(void mahand, (int j ));
  141. _PROTOTYPE(void mjhand, (int j ));
  142. /* dismain.c */
  143. _PROTOTYPE(void main, (int argc, char **argv ));
  144. /* distabs.c */
  145. _PROTOTYPE(char *getnam, (int k ));
  146. _PROTOTYPE(int lookext, (long off, long loc, char *buf ));
  147. _PROTOTYPE(char *lookup, (long addr, int type, int kind, long ext ));
  148. _PROTOTYPE(char *mtrans, (int c, int m, int type ));
  149. _PROTOTYPE(void mtrunc, (char *a ));