-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetOpcodeTable.js
142 lines (136 loc) · 8.74 KB
/
getOpcodeTable.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
const table = [
{ code: 0x01, operandCount: '2OP', op: 'je', branch: true },
{ code: 0x02, operandCount: '2OP', op: 'jl', branch: true },
{ code: 0x03, operandCount: '2OP', op: 'jg', branch: true },
{ code: 0x04, operandCount: '2OP', op: 'dec_chk', branch: true },
{ code: 0x05, operandCount: '2OP', op: 'inc_chk', branch: true },
{ code: 0x06, operandCount: '2OP', op: 'jin', branch: true },
{ code: 0x07, operandCount: '2OP', op: 'test', branch: true },
{ code: 0x08, operandCount: '2OP', op: 'or', store: true },
{ code: 0x09, operandCount: '2OP', op: 'and', store: true },
{ code: 0x0A, operandCount: '2OP', op: 'test_attr', branch: true },
{ code: 0x0B, operandCount: '2OP', op: 'set_attr' },
{ code: 0x0C, operandCount: '2OP', op: 'clear_attr' },
{ code: 0x0D, operandCount: '2OP', op: 'store' },
{ code: 0x0E, operandCount: '2OP', op: 'insert_obj' },
{ code: 0x0F, operandCount: '2OP', op: 'loadw', store: true },
{ code: 0x10, operandCount: '2OP', op: 'loadb', store: true },
{ code: 0x11, operandCount: '2OP', op: 'get_prop', store: true },
{ code: 0x12, operandCount: '2OP', op: 'get_prop_addr', store: true },
{ code: 0x13, operandCount: '2OP', op: 'get_next_prop', store: true },
{ code: 0x14, operandCount: '2OP', op: 'add', store: true },
{ code: 0x15, operandCount: '2OP', op: 'sub', store: true },
{ code: 0x16, operandCount: '2OP', op: 'mul', store: true },
{ code: 0x17, operandCount: '2OP', op: 'div', store: true },
{ code: 0x18, operandCount: '2OP', op: 'mod', store: true },
{ code: 0x19, operandCount: '2OP', op: 'call_2s', store: true, minVersion: 4 },
{ code: 0x1A, operandCount: '2OP', op: 'call_2n', minVersion: 5 },
{ code: 0x1B, operandCount: '2OP', op: 'set_colour', minVersion: 5 },
{ code: 0x1C, operandCount: '2OP', op: 'throw', minVersion: 5 },
{ code: 0x00, operandCount: '1OP', op: 'jz', branch: true },
{ code: 0x01, operandCount: '1OP', op: 'get_sibling', store: true, branch: true, },
{ code: 0x02, operandCount: '1OP', op: 'get_child', store: true, branch: true, },
{ code: 0x03, operandCount: '1OP', op: 'get_parent', store: true },
{ code: 0x04, operandCount: '1OP', op: 'get_prop_len', store: true },
{ code: 0x05, operandCount: '1OP', op: 'inc' },
{ code: 0x06, operandCount: '1OP', op: 'dec' },
{ code: 0x07, operandCount: '1OP', op: 'print_addr' },
{ code: 0x08, operandCount: '1OP', op: 'call_1s', minVersion: 4, store: true },
{ code: 0x09, operandCount: '1OP', op: 'remove_obj' },
{ code: 0x0A, operandCount: '1OP', op: 'print_obj' },
{ code: 0x0B, operandCount: '1OP', op: 'ret' },
{ code: 0x0C, operandCount: '1OP', op: 'jump' },
{ code: 0x0D, operandCount: '1OP', op: 'print_paddr' },
{ code: 0x0E, operandCount: '1OP', op: 'load', store: true },
{ code: 0x0F, operandCount: '1OP', op: 'not', maxVersion: 4, store: true },
{ code: 0x0F, operandCount: '1OP', op: 'call_1n', minVersion: 5 },
{ code: 0x00, operandCount: '0OP', op: 'rtrue' },
{ code: 0x01, operandCount: '0OP', op: 'rfalse' },
{ code: 0x02, operandCount: '0OP', op: 'print', text: true },
{ code: 0x03, operandCount: '0OP', op: 'print_ret', text: true },
{ code: 0x04, operandCount: '0OP', op: 'nop' },
{ code: 0x05, operandCount: '0OP', op: 'save', maxVersion: 3, branch: true },
{ code: 0x05, operandCount: '0OP', op: 'save', minVersion: 4, maxVersion: 4 },
{ code: 0x06, operandCount: '0OP', op: 'restore', maxVersion: 3, branch: true },
{ code: 0x06, operandCount: '0OP', op: 'restore', minVersion: 4, maxVersion: 4 },
{ code: 0x07, operandCount: '0OP', op: 'restart' },
{ code: 0x08, operandCount: '0OP', op: 'ret_popped' },
{ code: 0x09, operandCount: '0OP', op: 'pop', maxVersion: 4 },
{ code: 0x09, operandCount: '0OP', op: 'catch', minVersion: 5, store: true },
{ code: 0x0A, operandCount: '0OP', op: 'quit' },
{ code: 0x0B, operandCount: '0OP', op: 'new_line' },
{ code: 0x0C, operandCount: '0OP', op: 'show_status', minVersion: 3, maxVersion: 3 },
{ code: 0x0D, operandCount: '0OP', op: 'verify', minVersion: 3, branch: true},
{ code: 0x0F, operandCount: '0OP', op: 'piracy', minVersion: 5, branch: true },
{ code: 0x00, operandCount: 'VAR', op: 'call', maxVersion: 3, store: true },
{ code: 0x00, operandCount: 'VAR', op: 'call_vs', minVersion: 4, store: true },
{ code: 0x01, operandCount: 'VAR', op: 'storew' },
{ code: 0x02, operandCount: 'VAR', op: 'storeb' },
{ code: 0x03, operandCount: 'VAR', op: 'put_prop' },
{ code: 0x04, operandCount: 'VAR', op: 'read', maxVersion: 4, input: true },
{ code: 0x04, operandCount: 'VAR', op: 'read', minVersion: 5, store: true, input: true },
{ code: 0x05, operandCount: 'VAR', op: 'print_char' },
{ code: 0x06, operandCount: 'VAR', op: 'print_num' },
{ code: 0x07, operandCount: 'VAR', op: 'random', store: true },
{ code: 0x08, operandCount: 'VAR', op: 'push' },
{ code: 0x09, operandCount: 'VAR', op: 'pull', maxVersion: 5 },
{ code: 0x09, operandCount: 'VAR', op: 'pull', minVersion: 6, store: true },
{ code: 0x0A, operandCount: 'VAR', op: 'split_window', minVersion: 3 },
{ code: 0x0B, operandCount: 'VAR', op: 'set_window', minVersion: 3 },
{ code: 0x0C, operandCount: 'VAR', op: 'call_vs2', minVersion: 4, store: true },
{ code: 0x0D, operandCount: 'VAR', op: 'erase_window', minVersion: 4 },
{ code: 0x0E, operandCount: 'VAR', op: 'erase_line', minVersion: 4 },
{ code: 0x0F, operandCount: 'VAR', op: 'set_cursor', minVersion: 4 },
{ code: 0x10, operandCount: 'VAR', op: 'get_cursor', minVersion: 4 },
{ code: 0x11, operandCount: 'VAR', op: 'set_text_style', minVersion: 4 },
{ code: 0x12, operandCount: 'VAR', op: 'buffer_mode', minVersion: 4 },
{ code: 0x13, operandCount: 'VAR', op: 'output_stream', minVersion: 3 },
{ code: 0x14, operandCount: 'VAR', op: 'input_stream', minVersion: 3 },
{ code: 0x15, operandCount: 'VAR', op: 'sound_effect', minVersion: 3 },
{ code: 0x16, operandCount: 'VAR', op: 'read_char', minVersion: 4, store: true},
{ code: 0x17, operandCount: 'VAR', op: 'scan_table', minVersion: 4, store: true, branch: true },
{ code: 0x18, operandCount: 'VAR', op: 'not', minVersion: 5, store: true },
{ code: 0x19, operandCount: 'VAR', op: 'call_vn', minVersion: 5 },
{ code: 0x1A, operandCount: 'VAR', op: 'call_vn2', minVersion: 5 },
{ code: 0x1B, operandCount: 'VAR', op: 'tokenise', minVersion: 5 },
{ code: 0x1C, operandCount: 'VAR', op: 'encode_text', minVersion: 5 },
{ code: 0x1D, operandCount: 'VAR', op: 'copy_table', minVersion: 5 },
{ code: 0x1E, operandCount: 'VAR', op: 'print_table', minVersion: 5 },
{ code: 0x1F, operandCount: 'VAR', op: 'check_arg_count', minVersion: 5, branch: true },
{ code: 0x00, operandCount: 'EXT', op: 'save', minVersion: 5, store: true },
{ code: 0x01, operandCount: 'EXT', op: 'restore', minVersion: 5, store: true },
{ code: 0x02, operandCount: 'EXT', op: 'log_shift', minVersion: 5, store: true },
{ code: 0x03, operandCount: 'EXT', op: 'art_shift', minVersion: 5, store: true },
{ code: 0x04, operandCount: 'EXT', op: 'set_font', minVersion: 5, store: true },
{ code: 0x05, operandCount: 'EXT', op: 'draw_picture', minVersion: 6 },
{ code: 0x06, operandCount: 'EXT', op: 'picture_data', minVersion: 6, branch: true },
{ code: 0x07, operandCount: 'EXT', op: 'erase_picture', minVersion: 6 },
{ code: 0x08, operandCount: 'EXT', op: 'set_margins', minVersion: 6 },
{ code: 0x09, operandCount: 'EXT', op: 'save_undo', minVersion: 5, store: true },
{ code: 0x0A, operandCount: 'EXT', op: 'restore_undo', minVersion: 5, store: true },
{ code: 0x0B, operandCount: 'EXT', op: 'print_unicode', minVersion: 5 },
{ code: 0x0C, operandCount: 'EXT', op: 'check_unicode', minVersion: 5 },
{ code: 0x10, operandCount: 'EXT', op: 'move_window', minVersion: 6 },
{ code: 0x11, operandCount: 'EXT', op: 'window_size', minVersion: 6 },
{ code: 0x12, operandCount: 'EXT', op: 'window_style', minVersion: 6 },
{ code: 0x13, operandCount: 'EXT', op: 'get_wind_prop', minVersion: 6, store: true },
{ code: 0x14, operandCount: 'EXT', op: 'scroll_window', minVersion: 6 },
{ code: 0x15, operandCount: 'EXT', op: 'pop_stack', minVersion: 6 },
{ code: 0x16, operandCount: 'EXT', op: 'read_mouse', minVersion: 6 },
{ code: 0x17, operandCount: 'EXT', op: 'mouse_window', minVersion: 6 },
{ code: 0x18, operandCount: 'EXT', op: 'push_stack', minVersion: 6, branch: true },
{ code: 0x19, operandCount: 'EXT', op: 'put_wind_prop', minVersion: 6 },
{ code: 0x1A, operandCount: 'EXT', op: 'print_form', minVersion: 6 },
{ code: 0x1B, operandCount: 'EXT', op: 'make_menu', minVersion: 6, branch: true },
{ code: 0x1C, operandCount: 'EXT', op: 'picture_table', minVersion: 6 },
];
const versionTables = {};
[1, 2, 3, 4, 5, 7, 8].forEach(version => {
versionTables[version] = table.filter(entry => (
(!entry.minVersion || (version >= entry.minVersion)) &&
(!entry.maxVersion || (version <= entry.maxVersion))
));
});
module.exports = function getOpcodeTable(version) {
return versionTables[version];
}