cfad47cfa3/t3compiler/tads3/tct3unas.h

4b825dc642cb6eb9a060e54bf8d69288fbee4904cfad47cfa334b206c65f22086bcc5d63e6f70944
1
/* $Header: d:/cvsroot/tads/tads3/TCT3UNAS.H,v 1.2 1999/05/17 02:52:28 MJRoberts Exp $ */
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_H
22
23
#include "tcunas.h"
24
25
/* ------------------------------------------------------------------------ */
26
/* 
27
 *   operand types, for instruction descriptions 
28
 */
29
enum t3_oper_type_t
30
{
31
    /* 8-bit signed integer */
32
    T3OP_TYPE_8S,
33
34
    /* 8-bit unsigned integer */
35
    T3OP_TYPE_8U,
36
37
    /* 16-bit signed integer */
38
    T3OP_TYPE_16S,
39
40
    /* 16-bit unsigned integer */
41
    T3OP_TYPE_16U,
42
43
    /* 32-bit signed integer */
44
    T3OP_TYPE_32S,
45
46
    /* 32-bit unsigned integer */
47
    T3OP_TYPE_32U,
48
49
    /* string offset */
50
    T3OP_TYPE_STR,
51
52
    /* list offset */
53
    T3OP_TYPE_LIST,
54
55
    /* absolute (32-bit) code address */
56
    T3OP_TYPE_CODE_ABS,
57
58
    /* relative (16-bit) code address */
59
    T3OP_TYPE_CODE_REL,
60
61
    /* object ID */
62
    T3OP_TYPE_OBJ,
63
64
    /* property ID */
65
    T3OP_TYPE_PROP,
66
67
    /* enum ID */
68
    T3OP_TYPE_ENUM,
69
70
    /* context element type */
71
    T3OP_TYPE_CTX_ELE,
72
73
    /* in-line string */
74
    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_t
84
{
85
    /* name of the instruction */
86
    const char *nm;
87
88
    /* number of operands */
89
    int op_cnt;
90
91
    /* 
92
     *   operand types (allow for a fixed upper limit to the number of
93
     *   operands) 
94
     */
95
    t3_oper_type_t op_type[3];
96
};
97
98
99
/* ------------------------------------------------------------------------ */
100
/*
101
 *   T3 Disassembler 
102
 */
103
class CTcT3Unasm
104
{
105
public:
106
    /* disassemble a byte stream */
107
    static void disasm(class CTcUnasSrc *src, class CTcUnasOut *out);
108
109
    /* show an exception table */
110
    static void show_exc_table(class CTcUnasSrc *src, class CTcUnasOut *out,
111
                               unsigned long base_ofs);
112
113
    /* get the instruction information array (read-only) */
114
    static const t3_instr_info_t *get_instr_info() { return instr_info; }
115
116
protected:
117
    /* disassemble an instruction */
118
    static void disasm_instr(class CTcUnasSrc *src, class CTcUnasOut *out,
119
                             char ch);
120
121
    /* instruction information array */
122
    static t3_instr_info_t instr_info[];
123
};
124
125
#endif /* TCT3UNAS_H */
126