[9] | 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 <sys/types.h>
|
---|
| 28 | #include <a.out.h> /* Object file format definitions */
|
---|
| 29 | #include <fcntl.h> /* System file-control definitions */
|
---|
| 30 | #include <unistd.h>
|
---|
| 31 | #include <string.h>
|
---|
| 32 | #include <stdlib.h>
|
---|
| 33 | #include <stdio.h> /* System standard I/O definitions */
|
---|
| 34 |
|
---|
| 35 | #define MAXSYM 1500 /* Maximum entries in symbol table */
|
---|
| 36 |
|
---|
| 37 | extern struct nlist /* Array to hold the symbol table */
|
---|
| 38 | symtab[MAXSYM];
|
---|
| 39 |
|
---|
| 40 | extern struct reloc /* Array to hold relocation table */
|
---|
| 41 | relo[MAXSYM];
|
---|
| 42 |
|
---|
| 43 | extern int symptr; /* Index into the symtab[] array */
|
---|
| 44 | extern int relptr; /* Index into the relo[] array */
|
---|
| 45 |
|
---|
| 46 | struct opcode /* Format for opcode data records */
|
---|
| 47 | {
|
---|
| 48 | char *text; /* Pointer to mnemonic text */
|
---|
| 49 | void (*func)(); /* Pointer to handler routine */
|
---|
| 50 | unsigned min; /* Minimum # of object bytes */
|
---|
| 51 | unsigned max; /* Maximum # of object bytes */
|
---|
| 52 | };
|
---|
| 53 |
|
---|
| 54 | extern struct opcode /* Array to hold the opcode table */
|
---|
| 55 | optab[256];
|
---|
| 56 |
|
---|
| 57 | extern char *REGS[]; /* Table of register names */
|
---|
| 58 | extern char *REGS0[]; /* Mode 0 register name table */
|
---|
| 59 | extern char *REGS1[]; /* Mode 1 register name table */
|
---|
| 60 |
|
---|
| 61 | #define AL REGS[0] /* CPU register manifests */
|
---|
| 62 | #define CL REGS[1]
|
---|
| 63 | #define DL REGS[2]
|
---|
| 64 | #define BL REGS[3]
|
---|
| 65 | #define AH REGS[4]
|
---|
| 66 | #define CH REGS[5]
|
---|
| 67 | #define DH REGS[6]
|
---|
| 68 | #define BH REGS[7]
|
---|
| 69 | #define AX REGS[8]
|
---|
| 70 | #define CX REGS[9]
|
---|
| 71 | #define DX REGS[10]
|
---|
| 72 | #define BX REGS[11]
|
---|
| 73 | #define SP REGS[12]
|
---|
| 74 | #define BP REGS[13]
|
---|
| 75 | #define SI REGS[14]
|
---|
| 76 | #define DI REGS[15]
|
---|
| 77 | #define ES REGS[16]
|
---|
| 78 | #define CS REGS[17]
|
---|
| 79 | #define SS REGS[18]
|
---|
| 80 | #define DS REGS[19]
|
---|
| 81 | #define BX_SI REGS0[0]
|
---|
| 82 | #define BX_DI REGS0[1]
|
---|
| 83 | #define BP_SI REGS0[2]
|
---|
| 84 | #define BP_DI REGS0[3]
|
---|
| 85 |
|
---|
| 86 | extern int symrank[6][6]; /* Symbol type/rank matrix */
|
---|
| 87 | extern unsigned long PC; /* Current program counter */
|
---|
| 88 | extern int segflg; /* Flag: segment override in effect */
|
---|
| 89 | extern int objflg; /* Flag: output object as a comment */
|
---|
| 90 |
|
---|
| 91 | #define OBJMAX 8 /* Size of the object code buffer */
|
---|
| 92 |
|
---|
| 93 | extern unsigned char /* Internal buffer for object code */
|
---|
| 94 | objbuf[OBJMAX];
|
---|
| 95 |
|
---|
| 96 | extern int objptr; /* Index into the objbuf[] array */
|
---|
| 97 |
|
---|
| 98 | extern char ADD[], /* Opcode family mnemonic strings */
|
---|
| 99 | OR[],
|
---|
| 100 | ADC[],
|
---|
| 101 | SBB[],
|
---|
| 102 | AND[],
|
---|
| 103 | SUB[],
|
---|
| 104 | XOR[],
|
---|
| 105 | CMP[],
|
---|
| 106 | NOT[],
|
---|
| 107 | NEG[],
|
---|
| 108 | MUL[],
|
---|
| 109 | DIV[],
|
---|
| 110 | MOV[],
|
---|
| 111 | ESC[],
|
---|
| 112 | TEST[],
|
---|
| 113 | AMBIG[];
|
---|
| 114 |
|
---|
| 115 | extern char *OPFAM[]; /* Indexed mnemonic family table */
|
---|
| 116 | extern struct exec HDR; /* Holds the object file's header */
|
---|
| 117 |
|
---|
| 118 | #define LOOK_ABS 0 /* Arguments to lookup() function */
|
---|
| 119 | #define LOOK_REL 1
|
---|
| 120 | #define LOOK_LNG 2
|
---|
| 121 |
|
---|
| 122 | #define TR_STD 0 /* Arguments to mtrans() function */
|
---|
| 123 | #define TR_SEG 8
|
---|
| 124 |
|
---|
| 125 | /* Macro for byte input primitive */
|
---|
| 126 | #define FETCH(p) ++PC; p = getchar() & 0xff; objbuf[objptr++] = p
|
---|
| 127 |
|
---|
| 128 |
|
---|
| 129 | /* disfp.c */
|
---|
| 130 | _PROTOTYPE(void eshand, (int j ));
|
---|
| 131 | _PROTOTYPE(void fphand, (int j ));
|
---|
| 132 | _PROTOTYPE(void inhand, (int j ));
|
---|
| 133 |
|
---|
| 134 | /* dishand.c */
|
---|
| 135 | _PROTOTYPE(void objini, (int j ));
|
---|
| 136 | _PROTOTYPE(void objout, (void));
|
---|
| 137 | _PROTOTYPE(void badseq, (int j, int k ));
|
---|
| 138 | _PROTOTYPE(void dfhand, (int j ));
|
---|
| 139 | _PROTOTYPE(void sbhand, (int j ));
|
---|
| 140 | _PROTOTYPE(void aohand, (int j ));
|
---|
| 141 | _PROTOTYPE(void sjhand, (int j ));
|
---|
| 142 | _PROTOTYPE(void imhand, (int j ));
|
---|
| 143 | _PROTOTYPE(void mvhand, (int j ));
|
---|
| 144 | _PROTOTYPE(void mshand, (int j ));
|
---|
| 145 | _PROTOTYPE(void pohand, (int j ));
|
---|
| 146 | _PROTOTYPE(void cihand, (int j ));
|
---|
| 147 | _PROTOTYPE(void mihand, (int j ));
|
---|
| 148 | _PROTOTYPE(void mqhand, (int j ));
|
---|
| 149 | _PROTOTYPE(void tqhand, (int j ));
|
---|
| 150 | _PROTOTYPE(void rehand, (int j ));
|
---|
| 151 | _PROTOTYPE(void mmhand, (int j ));
|
---|
| 152 | _PROTOTYPE(void srhand, (int j ));
|
---|
| 153 | _PROTOTYPE(void aahand, (int j ));
|
---|
| 154 | _PROTOTYPE(void iohand, (int j ));
|
---|
| 155 | _PROTOTYPE(void ljhand, (int j ));
|
---|
| 156 | _PROTOTYPE(void mahand, (int j ));
|
---|
| 157 | _PROTOTYPE(void mjhand, (int j ));
|
---|
| 158 |
|
---|
| 159 | /* dismain.c */
|
---|
| 160 | _PROTOTYPE(void main, (int argc, char **argv ));
|
---|
| 161 |
|
---|
| 162 | /* distabs.c */
|
---|
| 163 | _PROTOTYPE(char *getnam, (int k ));
|
---|
| 164 | _PROTOTYPE(int lookext, (long off, long loc, char *buf ));
|
---|
| 165 | _PROTOTYPE(char *lookup, (long addr, int type, int kind, long ext ));
|
---|
| 166 | _PROTOTYPE(char *mtrans, (int c, int m, int type ));
|
---|
| 167 | _PROTOTYPE(void mtrunc, (char *a ));
|
---|