| 1 | /* $Header: d:/cvsroot/tads/tads3/TCT3UNAS.H,v 1.2 1999/05/17 02:52:28 MJRoberts Exp $ */cxx . . $ `<file>/tads3/tct3unas.h`/ |
| 2 | |
| 3 | /* |
| 4 | * Copyright (c) 1999, 2002 Michael J. Roberts. All Rights Reserved. |
| 5 | * |
| 6 | * Please see the accompanying license file, LICENSE.TXT, for information |
| 7 | * on using and copying this software. |
| 8 | */ |
| 9 | /* |
| 10 | Name |
| 11 | tct3unas.h - TADS 3 Compiler - T3 Unassembler |
| 12 | Function |
| 13 | Takes a T3 byte-code stream and disassembles it to a printable display |
| 14 | Notes |
| 15 | |
| 16 | Modified |
| 17 | 05/10/99 MJRoberts - Creation |
| 18 | */ |
| 19 | |
| 20 | #ifndef TCT3UNAS_H |
| 21 | #define TCT3UNAS_Hcxx . . $ `tads3/tct3unas.h:21:9`! |
| 22 | |
| 23 | #include "tcunas.h"cxx . . $ `<file>/tads3/tcunas.h`/ |
| 24 | |
| 25 | /* ------------------------------------------------------------------------ */ |
| 26 | /* |
| 27 | * operand types, for instruction descriptions |
| 28 | */ |
| 29 | enum t3_oper_type_tcxx . . $ t3_oper_type_t# |
| 30 | { |
| 31 | /* 8-bit signed integer */ |
| 32 | T3OP_TYPE_8Scxx . . $ T3OP_TYPE_8S., |
| 33 | |
| 34 | /* 8-bit unsigned integer */ |
| 35 | T3OP_TYPE_8Ucxx . . $ T3OP_TYPE_8U., |
| 36 | |
| 37 | /* 16-bit signed integer */ |
| 38 | T3OP_TYPE_16Scxx . . $ T3OP_TYPE_16S., |
| 39 | |
| 40 | /* 16-bit unsigned integer */ |
| 41 | T3OP_TYPE_16Ucxx . . $ T3OP_TYPE_16U., |
| 42 | |
| 43 | /* 32-bit signed integer */ |
| 44 | T3OP_TYPE_32Scxx . . $ T3OP_TYPE_32S., |
| 45 | |
| 46 | /* 32-bit unsigned integer */ |
| 47 | T3OP_TYPE_32Ucxx . . $ T3OP_TYPE_32U., |
| 48 | |
| 49 | /* string offset */ |
| 50 | T3OP_TYPE_STRcxx . . $ T3OP_TYPE_STR., |
| 51 | |
| 52 | /* list offset */ |
| 53 | T3OP_TYPE_LISTcxx . . $ T3OP_TYPE_LIST., |
| 54 | |
| 55 | /* absolute (32-bit) code address */ |
| 56 | T3OP_TYPE_CODE_ABScxx . . $ T3OP_TYPE_CODE_ABS., |
| 57 | |
| 58 | /* relative (16-bit) code address */ |
| 59 | T3OP_TYPE_CODE_RELcxx . . $ T3OP_TYPE_CODE_REL., |
| 60 | |
| 61 | /* object ID */ |
| 62 | T3OP_TYPE_OBJcxx . . $ T3OP_TYPE_OBJ., |
| 63 | |
| 64 | /* property ID */ |
| 65 | T3OP_TYPE_PROPcxx . . $ T3OP_TYPE_PROP., |
| 66 | |
| 67 | /* enum ID */ |
| 68 | T3OP_TYPE_ENUMcxx . . $ T3OP_TYPE_ENUM., |
| 69 | |
| 70 | /* context element type */ |
| 71 | T3OP_TYPE_CTX_ELEcxx . . $ T3OP_TYPE_CTX_ELE., |
| 72 | |
| 73 | /* in-line string */ |
| 74 | T3OP_TYPE_INLINE_STRcxx . . $ T3OP_TYPE_INLINE_STR. |
| 75 | }; |
| 76 | |
| 77 | |
| 78 | /* ------------------------------------------------------------------------ */ |
| 79 | /* |
| 80 | * Instruction information - this structure describes one T3 byte-code |
| 81 | * instruction. |
| 82 | */ |
| 83 | struct t3_instr_info_tcxx . . $ t3_instr_info_t# |
| 84 | { |
| 85 | /* name of the instruction */ |
| 86 | const char *nmcxx . . $ t3_instr_info_t#nm.; |
| 87 | |
| 88 | /* number of operands */ |
| 89 | int op_cntcxx . . $ t3_instr_info_t#op_cnt.; |
| 90 | |
| 91 | /* |
| 92 | * operand types (allow for a fixed upper limit to the number of |
| 93 | * operands) |
| 94 | */ |
| 95 | t3_oper_type_tcxx . . $ t3_oper_type_t# op_typecxx . . $ t3_instr_info_t#op_type.[3]; |
| 96 | }; |
| 97 | |
| 98 | |
| 99 | /* ------------------------------------------------------------------------ */ |
| 100 | /* |
| 101 | * T3 Disassembler |
| 102 | */ |
| 103 | class CTcT3Unasmcxx . . $ CTcT3Unasm# |
| 104 | { |
| 105 | public: |
| 106 | /* disassemble a byte stream */ |
| 107 | static void disasmcxx . . $ CTcT3Unasm#disasm(ecb2ce03bcac4f04).(class CTcUnasSrccxx . . $ CTcUnasSrc# *src, class CTcUnasOutcxx . . $ CTcUnasOut# *out); |
| 108 | |
| 109 | /* show an exception table */ |
| 110 | static void show_exc_tablecxx . . $ CTcT3Unasm#show_exc_table(a7b9bfc59643d8fc).(class CTcUnasSrccxx . . $ CTcUnasSrc# *src, class CTcUnasOutcxx . . $ CTcUnasOut# *out, |
| 111 | unsigned long base_ofs); |
| 112 | |
| 113 | /* get the instruction information array (read-only) */ |
| 114 | static const t3_instr_info_tcxx . . $ t3_instr_info_t# *get_instr_infocxx . . $ CTcT3Unasm#get_instr_info(f7018e043ae86e2a).() { return instr_infocxx . . $ CTcT3Unasm#instr_info.; } |
| 115 | |
| 116 | protected: |
| 117 | /* disassemble an instruction */ |
| 118 | static void disasm_instrcxx . . $ CTcT3Unasm#disasm_instr(44333c712cea0889).(class CTcUnasSrccxx . . $ CTcUnasSrc# *src, class CTcUnasOutcxx . . $ CTcUnasOut# *out, |
| 119 | char ch); |
| 120 | |
| 121 | /* instruction information array */ |
| 122 | static t3_instr_info_tcxx . . $ t3_instr_info_t# instr_infocxx . . $ CTcT3Unasm#instr_info.[]; |
| 123 | }; |
| 124 | |
| 125 | #endif /* TCT3UNAS_H */ |
| 126 |