📄 distabs.c
字号:
static char *sccsid = "@(#) distabs.c, Ver. 2.1 created 00:00:00 87/09/01"; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright (C) 1987 G. M. Harding, all rights reserved * * * * Permission to copy and redistribute is hereby granted, * * provided full source code, with all copyright notices, * * accompanies any redistribution. * * * * This file contains the lookup tables and other data * * structures for the Intel 8088 symbolic disassembler. It * * also contains a few global routines which facilitate * * access to the tables, for use primarily by the handler * * functions. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */#include "dis.h" /* Disassembler declarations */struct exec HDR; /* Used to hold header info */struct nlist symtab[MAXSYM]; /* Array of symbol table info */struct reloc relo[MAXSYM]; /* Array of relocation info */int symptr = -1, /* Index into symtab[] */ relptr = -1; /* Index into relo[] */char *REGS[] = /* Table of register names */ { "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh", "ax", "cx", "dx", "bx", "sp", "bp", "si", "di", "es", "cs", "ss", "ds" };char *REGS0[] = /* Mode 0 register name table */ { "bx_si", "bx_di", "bp_si", "bp_di", "si", "di", "", "bx" };char *REGS1[] = /* Mode 1 register name table */ { "bx_si", "bx_di", "bp_si", "bp_di", "si", "di", "bp", "bx" };int symrank[6][6] = /* Symbol type/rank matrix */ { /* UND ABS TXT DAT BSS COM */ /* UND */ 5, 4, 1, 2, 3, 0, /* ABS */ 1, 5, 4, 3, 2, 0, /* TXT */ 4, 1, 5, 3, 2, 0, /* DAT */ 3, 1, 2, 5, 4, 0, /* BSS */ 3, 1, 2, 4, 5, 0, /* COM */ 2, 0, 1, 3, 4, 5 }; /* * * * * * * * * * * * OPCODE DATA * * * * * * * * * * * */char ADD[] = "\tadd", /* Mnemonics by family */ OR[] = "\tor", ADC[] = "\tadc", SBB[] = "\tsbb", AND[] = "\tand", SUB[] = "\tsub", XOR[] = "\txor", CMP[] = "\tcmp", NOT[] = "\tnot", NEG[] = "\tneg", MUL[] = "\tmul", DIV[] = "\tdiv", MOV[] = "\tmov", ESC[] = "\tesc", TEST[] = "\ttest", AMBIG[] = "", ROL[] = "\trol", ROR[] = "\tror", RCL[] = "\trcl", RCR[] = "\trcr", SAL[] = "\tsal", SHR[] = "\tshr", SHL[] = "\tshl", SAR[] = "\tsar";char *OPFAM[] = /* Family lookup table */ { ADD, OR, ADC, SBB, AND, SUB, XOR, CMP, NOT, NEG, MUL, DIV, MOV, ESC, TEST, AMBIG, ROL, ROR, RCL, RCR, SAL, SHR, SHL, SAR };struct opcode optab[] = /* Table of opcode data */ { ADD, aohand, 2, 4, /* 0x00 */ ADD, aohand, 2, 4, /* 0x01 */ ADD, aohand, 2, 4, /* 0x02 */ ADD, aohand, 2, 4, /* 0x03 */ ADD, aohand, 2, 2, /* 0x04 */ ADD, aohand, 3, 3, /* 0x05 */ "\tpush\tes", sbhand, 1, 1, /* 0x06 */ "\tpop\tes", sbhand, 1, 1, /* 0x07 */ OR, aohand, 2, 4, /* 0x08 */ OR, aohand, 2, 4, /* 0x09 */ OR, aohand, 2, 4, /* 0x0a */ OR, aohand, 2, 4, /* 0x0b */ OR, aohand, 2, 2, /* 0x0c */ OR, aohand, 3, 3, /* 0x0d */ "\tpush\tcs", sbhand, 1, 1, /* 0x0e */ NULL, dfhand, 0, 0, /* 0x0f */ ADC, aohand, 2, 4, /* 0x10 */ ADC, aohand, 2, 4, /* 0x11 */ ADC, aohand, 2, 4, /* 0x12 */ ADC, aohand, 2, 4, /* 0x13 */ ADC, aohand, 2, 2, /* 0x14 */ ADC, aohand, 3, 3, /* 0x15 */ "\tpush\tss", sbhand, 1, 1, /* 0x16 */ "\tpop\tss", sbhand, 1, 1, /* 0x17 */ SBB, aohand, 2, 4, /* 0x18 */ SBB, aohand, 2, 4, /* 0x19 */ SBB, aohand, 2, 4, /* 0x1a */ SBB, aohand, 2, 4, /* 0x1b */ SBB, aohand, 2, 2, /* 0x1c */ SBB, aohand, 3, 3, /* 0x1d */ "\tpush\tds", sbhand, 1, 1, /* 0x1e */ "\tpop\tds", sbhand, 1, 1, /* 0x1f */ AND, aohand, 2, 4, /* 0x20 */ AND, aohand, 2, 4, /* 0x21 */ AND, aohand, 2, 4, /* 0x22 */ AND, aohand, 2, 4, /* 0x23 */ AND, aohand, 2, 2, /* 0x24 */ AND, aohand, 3, 3, /* 0x25 */ "\tseg\tes", sbhand, 1, 1, /* 0x26 */ "\tdaa", sbhand, 1, 1, /* 0x27 */ SUB, aohand, 2, 4, /* 0x28 */ SUB, aohand, 2, 4, /* 0x29 */ SUB, aohand, 2, 4, /* 0x2a */ SUB, aohand, 2, 4, /* 0x2b */ SUB, aohand, 2, 2, /* 0x2c */ SUB, aohand, 3, 3, /* 0x2d */ "\tseg\tcs", sbhand, 1, 1, /* 0x2e */ "\tdas", sbhand, 1, 1, /* 0x2f */ XOR, aohand, 2, 4, /* 0x30 */ XOR, aohand, 2, 4, /* 0x31 */ XOR, aohand, 2, 4, /* 0x32 */ XOR, aohand, 2, 4, /* 0x33 */ XOR, aohand, 2, 2, /* 0x34 */ XOR, aohand, 3, 3, /* 0x35 */ "\tseg\tss", sbhand, 1, 1, /* 0x36 */ "\taaa", sbhand, 1, 1, /* 0x37 */ CMP, aohand, 2, 4, /* 0x38 */ CMP, aohand, 2, 4, /* 0x39 */ CMP, aohand, 2, 4, /* 0x3a */ CMP, aohand, 2, 4, /* 0x3b */ CMP, aohand, 2, 2, /* 0x3c */ CMP, aohand, 3, 3, /* 0x3d */ "\tseg\tds", sbhand, 1, 1, /* 0x3e */ "\taas", sbhand, 1, 1, /* 0x3f */ "\tinc\tax", sbhand, 1, 1, /* 0x40 */ "\tinc\tcx", sbhand, 1, 1, /* 0x41 */ "\tinc\tdx", sbhand, 1, 1, /* 0x42 */ "\tinc\tbx", sbhand, 1, 1, /* 0x43 */ "\tinc\tsp", sbhand, 1, 1, /* 0x44 */ "\tinc\tbp", sbhand, 1, 1, /* 0x45 */ "\tinc\tsi", sbhand, 1, 1, /* 0x46 */ "\tinc\tdi", sbhand, 1, 1, /* 0x47 */ "\tdec\tax", sbhand, 1, 1, /* 0x48 */ "\tdec\tcx", sbhand, 1, 1, /* 0x49 */ "\tdec\tdx", sbhand, 1, 1, /* 0x4a */ "\tdec\tbx", sbhand, 1, 1, /* 0x4b */ "\tdec\tsp", sbhand, 1, 1, /* 0x4c */ "\tdec\tbp", sbhand, 1, 1, /* 0x4d */ "\tdec\tsi", sbhand, 1, 1, /* 0x4e */ "\tdec\tdi", sbhand, 1, 1, /* 0x4f */ "\tpush\tax", sbhand, 1, 1, /* 0x50 */ "\tpush\tcx", sbhand, 1, 1, /* 0x51 */ "\tpush\tdx", sbhand, 1, 1, /* 0x52 */ "\tpush\tbx", sbhand, 1, 1, /* 0x53 */ "\tpush\tsp", sbhand, 1, 1, /* 0x54 */ "\tpush\tbp", sbhand, 1, 1, /* 0x55 */ "\tpush\tsi", sbhand, 1, 1, /* 0x56 */ "\tpush\tdi", sbhand, 1, 1, /* 0x57 */ "\tpop\tax", sbhand, 1, 1, /* 0x58 */ "\tpop\tcx", sbhand, 1, 1, /* 0x59 */ "\tpop\tdx", sbhand, 1, 1, /* 0x5a */ "\tpop\tbx", sbhand, 1, 1, /* 0x5b */ "\tpop\tsp", sbhand, 1, 1, /* 0x5c */ "\tpop\tbp", sbhand, 1, 1, /* 0x5d */ "\tpop\tsi", sbhand, 1, 1, /* 0x5e */ "\tpop\tdi", sbhand, 1, 1, /* 0x5f */ NULL, dfhand, 0, 0, /* 0x60 */ NULL, dfhand, 0, 0, /* 0x61 */ NULL, dfhand, 0, 0, /* 0x62 */ NULL, dfhand, 0, 0, /* 0x63 */ NULL, dfhand, 0, 0, /* 0x64 */ NULL, dfhand, 0, 0, /* 0x65 */ NULL, dfhand, 0, 0, /* 0x66 */ NULL, dfhand, 0, 0, /* 0x67 */ NULL, dfhand, 0, 0, /* 0x68 */ NULL, dfhand, 0, 0, /* 0x69 */ NULL, dfhand, 0, 0, /* 0x6a */ NULL, dfhand, 0, 0, /* 0x6b */ NULL, dfhand, 0, 0, /* 0x6c */ NULL, dfhand, 0, 0, /* 0x6d */ NULL, dfhand, 0, 0, /* 0x6e */ NULL, dfhand, 0, 0, /* 0x6f */ "\tjo", sjhand, 2, 2, /* 0x70 */ "\tjno", sjhand, 2, 2, /* 0x71 */ "\tjc", sjhand, 2, 2, /* 0x72 */ "\tjnc", sjhand, 2, 2, /* 0x73 */ "\tjz", sjhand, 2, 2, /* 0x74 */ "\tjnz", sjhand, 2, 2, /* 0x75 */ "\tjna", sjhand, 2, 2, /* 0x76 */ "\tja", sjhand, 2, 2, /* 0x77 */ "\tjs", sjhand, 2, 2, /* 0x78 */ "\tjns", sjhand, 2, 2, /* 0x79 */ "\tjp", sjhand, 2, 2, /* 0x7a */ "\tjnp", sjhand, 2, 2, /* 0x7b */ "\tjl", sjhand, 2, 2, /* 0x7c */ "\tjnl", sjhand, 2, 2, /* 0x7d */ "\tjng", sjhand, 2, 2, /* 0x7e */ "\tjg", sjhand, 2, 2, /* 0x7f */ AMBIG, imhand, 3, 5, /* 0x80 */ AMBIG, imhand, 4, 6, /* 0x81 */ AMBIG, imhand, 3, 5, /* 0x82 */ AMBIG, imhand, 3, 5, /* 0x83 */ TEST, mvhand, 2, 4, /* 0x84 */ TEST, mvhand, 2, 4, /* 0x85 */ "\txchg", mvhand, 2, 4, /* 0x86 */ "\txchg", mvhand, 2, 4, /* 0x87 */ MOV, mvhand, 2, 4, /* 0x88 */ MOV, mvhand, 2, 4, /* 0x89 */ MOV, mvhand, 2, 4, /* 0x8a */ MOV, mvhand, 2, 4, /* 0x8b */ MOV, mshand, 2, 4, /* 0x8c */ "\tlea", mvhand, 2, 4, /* 0x8d */ MOV, mshand, 2, 4, /* 0x8e */ "\tpop", pohand, 2, 4, /* 0x8f */ "\tnop", sbhand, 1, 1, /* 0x90 */ "\txchg\tax,cx", sbhand, 1, 1, /* 0x91 */ "\txchg\tax,dx", sbhand, 1, 1, /* 0x92 */ "\txchg\tax,bx", sbhand, 1, 1, /* 0x93 */ "\txchg\tax,sp", sbhand, 1, 1, /* 0x94 */ "\txchg\tax,bp", sbhand, 1, 1, /* 0x95 */ "\txchg\tax,si", sbhand, 1, 1, /* 0x96 */ "\txchg\tax,di", sbhand, 1, 1, /* 0x97 */ "\tcbw", sbhand, 1, 1, /* 0x98 */ "\tcwd", sbhand, 1, 1, /* 0x99 */ "\tcalli", cihand, 5, 5, /* 0x9a */ "\twait", sbhand, 1, 1, /* 0x9b */ "\tpushf", sbhand, 1, 1, /* 0x9c */ "\tpopf", sbhand, 1, 1, /* 0x9d */ "\tsahf", sbhand, 1, 1, /* 0x9e */ "\tlahf", sbhand, 1, 1, /* 0x9f */ MOV, mqhand, 3, 3, /* 0xa0 */ MOV, mqhand, 3, 3, /* 0xa1 */ MOV, mqhand, 3, 3, /* 0xa2 */ MOV, mqhand, 3, 3, /* 0xa3 */ "\tmovb", sbhand, 1, 1, /* 0xa4 */ "\tmovw", sbhand, 1, 1, /* 0xa5 */ "\tcmpb", sbhand, 1, 1, /* 0xa6 */ "\tcmpw", sbhand, 1, 1, /* 0xa7 */ TEST, tqhand, 2, 2, /* 0xa8 */ TEST, tqhand, 3, 3, /* 0xa9 */ "\tstob", sbhand, 1, 1, /* 0xaa */ "\tstow", sbhand, 1, 1, /* 0xab */ "\tlodb", sbhand, 1, 1, /* 0xac */ "\tlodw", sbhand, 1, 1, /* 0xad */ "\tscab", sbhand, 1, 1, /* 0xae */ "\tscaw", sbhand, 1, 1, /* 0xaf */ "\tmov\tal,", mihand, 2, 2, /* 0xb0 */ "\tmov\tcl,", mihand, 2, 2, /* 0xb1 */ "\tmov\tdl,", mihand, 2, 2, /* 0xb2 */ "\tmov\tbl,", mihand, 2, 2, /* 0xb3 */ "\tmov\tah,", mihand, 2, 2, /* 0xb4 */ "\tmov\tch,", mihand, 2, 2, /* 0xb5 */ "\tmov\tdh,", mihand, 2, 2, /* 0xb6 */ "\tmov\tbh,", mihand, 2, 2, /* 0xb7 */ "\tmov\tax,", mihand, 3, 3, /* 0xb8 */ "\tmov\tcx,", mihand, 3, 3, /* 0xb9 */ "\tmov\tdx,", mihand, 3, 3, /* 0xba */ "\tmov\tbx,", mihand, 3, 3, /* 0xbb */ "\tmov\tsp,", mihand, 3, 3, /* 0xbc */ "\tmov\tbp,", mihand, 3, 3, /* 0xbd */ "\tmov\tsi,", mihand, 3, 3, /* 0xbe */ "\tmov\tdi,", mihand, 3, 3, /* 0xbf */ NULL, dfhand, 0, 0, /* 0xc0 */ NULL, dfhand, 0, 0, /* 0xc1 */ "\tret", rehand, 3, 3, /* 0xc2 */ "\tret", sbhand, 1, 1, /* 0xc3 */ "\tles", mvhand, 2, 4, /* 0xc4 */ "\tlds", mvhand, 2, 4, /* 0xc5 */ MOV, mmhand, 3, 5, /* 0xc6 */ MOV, mmhand, 4, 6, /* 0xc7 */ NULL, dfhand, 0, 0, /* 0xc8 */ NULL, dfhand, 0, 0, /* 0xc9 */ "\treti", rehand, 3, 3, /* 0xca */ "\treti", sbhand, 1, 1, /* 0xcb */ "\tint", sbhand, 1, 1, /* 0xcc */ "\tint", inhand, 2, 2, /* 0xcd */ "\tinto", sbhand, 1, 1, /* 0xce */ "\tiret", sbhand, 1, 1, /* 0xcf */ AMBIG, srhand, 2, 4, /* 0xd0 */ AMBIG, srhand, 2, 4, /* 0xd1 */ AMBIG, srhand, 2, 4, /* 0xd2 */ AMBIG, srhand, 2, 4, /* 0xd3 */ "\taam", aahand, 2, 2, /* 0xd4 */ "\taad", aahand, 2, 2, /* 0xd5 */ NULL, dfhand, 0, 0, /* 0xd6 */ "\txlat", sbhand, 1, 1, /* 0xd7 */ ESC, eshand, 2, 2, /* 0xd8 */ ESC, eshand, 2, 2, /* 0xd9 */ ESC, eshand, 2, 2, /* 0xda */ ESC, eshand, 2, 2, /* 0xdb */ ESC, eshand, 2, 2, /* 0xdc */ ESC, eshand, 2, 2, /* 0xdd */ ESC, eshand, 2, 2, /* 0xde */ ESC, eshand, 2, 2, /* 0xdf */ "\tloopne", sjhand, 2, 2, /* 0xe0 */ "\tloope", sjhand, 2, 2, /* 0xe1 */ "\tloop", sjhand, 2, 2, /* 0xe2 */ "\tjcxz", sjhand, 2, 2, /* 0xe3 */ "\tin", iohand, 2, 2, /* 0xe4 */ "\tinw", iohand, 2, 2, /* 0xe5 */ "\tout", iohand, 2, 2, /* 0xe6 */ "\toutw", iohand, 2, 2, /* 0xe7 */ "\tcall", ljhand, 3, 3, /* 0xe8 */ "\tjmp", ljhand, 3, 3, /* 0xe9 */ "\tjmpi", cihand, 5, 5, /* 0xea */ "\tj", sjhand, 2, 2, /* 0xeb */ "\tin", sbhand, 1, 1, /* 0xec */ "\tinw", sbhand, 1, 1, /* 0xed */ "\tout", sbhand, 1, 1, /* 0xee */ "\toutw", sbhand, 1, 1, /* 0xef */ "\tlock", sbhand, 1, 1, /* 0xf0 */ NULL, dfhand, 0, 0, /* 0xf1 */ "\trepnz", sbhand, 1, 1, /* 0xf2 */ "\trepz", sbhand, 1, 1, /* 0xf3 */ "\thlt", sbhand, 1, 1, /* 0xf4 */ "\tcmc", sbhand, 1, 1, /* 0xf5 */ AMBIG, mahand, 2, 5, /* 0xf6 */ AMBIG, mahand, 2, 6, /* 0xf7 */ "\tclc", sbhand, 1, 1, /* 0xf8 */ "\tstc", sbhand, 1, 1, /* 0xf9 */ "\tcli", sbhand, 1, 1, /* 0xfa */ "\tsti", sbhand, 1, 1, /* 0xfb */ "\tcld", sbhand, 1, 1, /* 0xfc */ "\tstd", sbhand, 1, 1, /* 0xfd */ AMBIG, mjhand, 2, 4, /* 0xfe */ AMBIG, mjhand, 2, 4 /* 0xff */ }; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * This simple routine returns the name field of a symbol *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -