MegaProcessor

Check-in [ec4efbf308]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:First stab at a complete disassembler.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:ec4efbf3082f70f9cb5693e6b05cf40d4106eb5c
User & Date: jos 2015-07-09 15:02:56
Context
2015-07-11
12:46
Made dis_00_ff.lua executable. check-in: 9ec2579260 user: jos tags: trunk
2015-07-09
15:02
First stab at a complete disassembler. check-in: ec4efbf308 user: jos tags: trunk
2015-07-06
22:39
First stab at disassembling instructions 0xd8..0xdf check-in: 2f9d29a723 user: jos tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to bit_ops.txt.

108
109
110
111
112
113
114



115
116
117
118
119
120
121
122
0xb8..0xbc  :   -- Redundant
0xbd..0xbf  :   -- Redundant
0xc0..0xcf  :   BSET Rx,   #0 .. #15
0xd0..0xdf  :   -- Redundant
0xe0..0xe3  :   BSET Rx,    R0 .. R3
0xe4..0xe7  :   -- Redundant
0xe8..0xec  :   -- Redundant



0xed..0xef  :   -- Redundant
0xf0..0xf3  :   -- Redundant
0xf4..0xf7  :   -- Redundant
0xf8..0xfc  :   -- Redundant
0xfd..0xff  :   -- Redundant

</table>








>
>
>








108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
0xb8..0xbc  :   -- Redundant
0xbd..0xbf  :   -- Redundant
0xc0..0xcf  :   BSET Rx,   #0 .. #15
0xd0..0xdf  :   -- Redundant
0xe0..0xe3  :   BSET Rx,    R0 .. R3
0xe4..0xe7  :   -- Redundant
0xe8..0xec  :   -- Redundant

There are 8 different instructions in the category 'test-or-set'.
These are positioned at the bytes with even values for the high-nibble.
0xed..0xef  :   -- Redundant
0xf0..0xf3  :   -- Redundant
0xf4..0xf7  :   -- Redundant
0xf8..0xfc  :   -- Redundant
0xfd..0xff  :   -- Redundant

</table>

Added dis_00_ff.lua.





















































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
#!/usr/bin/env lua

-- 
-- Table CPU_Instr is organised as 1 tuple per instruction.
--   t1 = instruction length: 1, 2, or 3 bytes
--   t2 = mnemonic text:
--

CPU_Instr = { [0] =
--[[ 00 ]] { 1 : "SXT R0" },
{ 1 : "MOVE R1,R0" },
{ 1 : "MOVE R2,R0" },
{ 1 : "MOVE R3,R0" },
{ 1 : "MOVE R0,R1" },
{ 1 : "SXT R1" },
{ 1 : "MOVE R2,R1" },
{ 1 : "MOVE R3,R1" },
{ 1 : "MOVE R0,R2" },
{ 1 : "MOVE R1,R2" },
{ 1 : "SXT R2" },
{ 1 : "MOVE R3,R2" },
{ 1 : "MOVE R0,R3" },
{ 1 : "MOVE R1,R3" },
{ 1 : "MOVE R2,R3" },
{ 1 : "SXT R3" },
{ 1 : "TEST R0" },
{ 1 : "AND R1,R0" },
{ 1 : "AND R2,R0" },
{ 1 : "AND R3,R0" },
{ 1 : "AND R0,R1" },
{ 1 : "TEST R1" },
{ 1 : "AND R2,R1" },
{ 1 : "AND R3,R1" },
{ 1 : "AND R0,R2" },
{ 1 : "AND R1,R2" },
{ 1 : "TEST R2" },
{ 1 : "AND R3,R2" },
{ 1 : "AND R0,R3" },
{ 1 : "AND R1,R3" },
{ 1 : "AND R2,R3" },
{ 1 : "TEST R3" },
{ 1 : "CLR R0" },
{ 1 : "XOR R1,R0" },
{ 1 : "XOR R2,R0" },
{ 1 : "XOR R3,R0" },
{ 1 : "XOR R0,R1" },
{ 1 : "CLR R1" },
{ 1 : "XOR R2,R1" },
{ 1 : "XOR R3,R1" },
{ 1 : "XOR R0,R2" },
{ 1 : "XOR R1,R2" },
{ 1 : "CLR R2" },
{ 1 : "XOR R3,R2" },
{ 1 : "XOR R0,R3" },
{ 1 : "XOR R1,R3" },
{ 1 : "XOR R2,R3" },
{ 1 : "CLR R3" },
{ 1 : "INV R0" },
{ 1 : "OR R1,R0" },
{ 1 : "OR R2,R0" },
{ 1 : "OR R3,R0" },
{ 1 : "OR R0,R1" },
{ 1 : "INV R1" },
{ 1 : "OR R2,R1" },
{ 1 : "OR R3,R1" },
{ 1 : "OR R0,R2" },
{ 1 : "OR R1,R2" },
{ 1 : "INV R2" },
{ 1 : "OR R3, R2" },
{ 1 : "OR R0, R3" },
{ 1 : "OR R1, R3" },
{ 1 : "OR R2, R3" },
{ 1 : "INV R3" },
{ 1 : "ADD R0,R0" },
{ 1 : "ADD R1,R0" },
{ 2 : "ADD R2,R0" },
{ 1 : "ADD R3,R0" },
{ 1 : "ADD R0,R1" },
{ 1 : "ADD R1,R1" },
{ 1 : "ADD R2,R1" },
{ 1 : "ADD R3,R1" },
{ 1 : "ADD R0,R2" },
{ 1 : "ADD R1,R2" },
{ 1 : "ADD R2,R2" },
{ 1 : "ADD R3,R2" },
{ 1 : "ADD R0,R3" },
{ 1 : "ADD R1,R3" },
{ 1 : "ADD R2,R3" },
{ 1 : "ADD R3,R3" },
{ 1 : "ADDQ R0, #2" },
{ 1 : "ADDQ R1, #2" },
{ 1 : "ADDQ R2, #2" },
{ 1 : "ADDQ R3, #2" },
{ 1 : "ADDQ R0, #1" },
{ 1 : "ADDQ R1, #1" },
{ 1 : "ADDQ R2, #1" },
{ 1 : "ADDQ R3, #1" },
{ 1 : "ADDQ R0,#-2" },
{ 1 : "ADDQ R1,#-2" },
{ 1 : "ADDQ R2,#-2" },
{ 1 : "ADDQ R3,#-2" },
{ 1 : "ADDQ R0,#-1" },
{ 1 : "ADDQ R1,#-1" },
{ 1 : "ADDQ R2,#-1" },
{ 1 : "ADDQ R3,#-1" },
{ 1 : "NEG R0" },
{ 1 : "SUB R1,R0" },
{ 1 : "SUB R2,R0" },
{ 1 : "SUB R3,R0" },
{ 1 : "SUB R0,R1" },
{ 1 : "NEG R1" },
{ 1 : "SUB R2,R1" },
{ 1 : "SUB R3,R1" },
{ 1 : "SUB R0,R2" },
{ 1 : "SUB R1,R2" },
{ 1 : "NEG R2" },
{ 1 : "SUB R3,R2" },
{ 1 : "SUB R0,R3" },
{ 1 : "SUB R1,R3" },
{ 1 : "SUB R2,R3" },
{ 1 : "NEG R3" },
{ 1 : "ABS R0" },
{ 1 : "CMP R1,R0" },
{ 1 : "CMP R2,R0" },
{ 1 : "CMP R3,R0" },
{ 1 : "CMP R0,R1" },
{ 1 : "ABS R1" },
{ 1 : "CMP R2,R1" },
{ 1 : "CMP R3,R1" },
{ 1 : "CMP R0,R2" },
{ 1 : "CMP R1,R2" },
{ 1 : "ABS R2" },
{ 1 : "CMP R3,R2" },
{ 1 : "CMP R0,R3" },
{ 1 : "CMP R1,R3" },
{ 1 : "CMP R2,R3" },
{ 1 : "ABS R3" },
{ 1 : "LD.W R0,(R2)" },
{ 1 : "LD.W R1,(R2)" },
{ 1 : "LD.W R0,(R3)" },
{ 1 : "LD.W R1,(R3)" },
{ 1 : "LD.B R0,(R2)" },
{ 1 : "LD.B R1,(R2)" },
{ 1 : "LD.B R0,(R3)" },
{ 1 : "LD.B R1,(R3)" },
{ 1 : "ST.W (R2),R0" },
{ 1 : "ST.W (R2),R1" },
{ 1 : "ST.W (R3),R0" },
{ 1 : "ST.W (R3),R1" },
{ 1 : "ST.B (R2),R0" },
{ 1 : "ST.B (R2),R1" },
{ 1 : "ST.B (R3),R0" },
{ 1 : "ST.B (R3),R1" },
{ 1 : "LD.W R0, (R2++)" },
{ 1 : "LD.W R1, (R2++)" },
{ 1 : "LD.W R0, (R3++)" },
{ 1 : "LD.W R1, (R3++)" },
{ 1 : "LD.B R0, (R2++)" },
{ 1 : "LD.B R1, (R2++)" },
{ 1 : "LD.B R0, (R3++)" },
{ 1 : "LD.B R1, (R3++)" },
{ 1 : "ST.W (R2++),R0" },
{ 1 : "ST.W (R2++),R1" },
{ 1 : "ST.W (R3++),R0" },
{ 1 : "ST.W (R3++),R1" },
{ 1 : "ST.B (R2++),R0" },
{ 1 : "ST.B (R2++),R1" },
{ 1 : "ST.B (R3++),R0" },
{ 1 : "ST.B (R3++),R1" },
{ 2 : "LD.W R0,(SP,0xXX)" },
{ 2 : "LD.W R1,(SP,0xXX)" },
{ 2 : "LD.W R2,(SP,0xXX)" },
{ 2 : "LD.W R3,(SP,0xXX)" },
{ 2 : "LD.B R0,(SP,0xXX)" },
{ 2 : "LD.B R1,(SP,0xXX)" },
{ 2 : "LD.B R2,(SP,0xXX)" },
{ 2 : "LD.B R3,(SP,0xXX)" },
{ 2 : "ST.W (SP,0xXX),R0" },
{ 2 : "ST.W (SP,0xXX),R1" },
{ 2 : "ST.W (SP,0xXX),R2" },
{ 2 : "ST.W (SP,0xXX),R3" },
{ 2 : "ST.B (SP,0xXX),R0" },
{ 2 : "ST.B (SP,0xXX),R1" },
{ 2 : "ST.B (SP,0xXX),R2	" },
{ 2 : "ST.B (SP,0xXX),R3" },
{ 3 : "LD.W R0, 0xXXXX" },
{ 3 : "LD.W R1, 0xXXXX" },
{ 3 : "LD.W R2, 0xXXXX" },
{ 3 : "LD.W R3, 0xXXXX" },
{ 3 : "LD.B R0, 0xXXXX" },
{ 3 : "LD.B R1, 0xXXXX" },
{ 3 : "LD.B R2, 0xXXXX" },
{ 3 : "LD.B R3, 0xXXXX" },
{ 3 : "ST.W 0xXXXX,R0" },
{ 3 : "ST.W 0xXXXX,R1" },
{ 3 : "ST.W 0xXXXX,R2" },
{ 3 : "ST.W 0xXXXX,R3" },
{ 3 : "ST.B 0xXXXX,R0" },
{ 3 : "ST.B 0xXXXX,R1" },
{ 3 : "ST.B 0xXXXX,R2" },
{ 3 : "ST.B 0xXXXX,R3" },
{ 1 : "POP R0" },
{ 1 : "POP R1" },
{ 1 : "POP R2" },
{ 1 : "POP R3" },
{ 1 : "POP PS" },
{ 1 : "NOP_x" },
{ 1 : "RET" },
{ 1 : "RETI" },
{ 1 : "PUSH R0" },
{ 1 : "PUSH R1" },
{ 1 : "PUSH R2" },
{ 1 : "PUSH R3" },
{ 1 : "PUSH PS" },
{ 1 : "TRAP #3" },
{ 1 : "JSR (R0)" },
{ 3 : "JSR 0xXXXX" },
{ 3 : "LD.W R0,#0xXXXX" },
{ 3 : "LD.W R1,#0xXXXX" },
{ 3 : "LD.W R2,#0xXXXX" },
{ 3 : "LD.W R3,#0xXXXX" },
{ 2 : "LD.B R0,#0xXX" },
{ 2 : "LD.B R1,#0xXX" },
{ 2 : "LD.B R2,#0xXX" },
{ 2 : "LD.B R3,#0xXX" },
{ 2 : "shift/rotate" },
{ 2 : "shift/rotate" },
{ 2 : "shift/rotate" },
{ 2 : "shift/rotate" },
{ 2 : "bit-test/change" },
{ 2 : "bit-test/change" },
{ 2 : "bit-test/change" },
{ 2 : "bit-test/change" },
{ 2 : "BUC" },
{ 2 : "BUS" },
{ 2 : "BHI" },
{ 2 : "BLS" },
{ 2 : "BCC" },
{ 2 : "BCS" },
{ 2 : "BNE" },
{ 2 : "BEQ" },
{ 2 : "BVC" },
{ 2 : "BVS" },
{ 2 : "BPL" },
{ 2 : "BMI" },
{ 2 : "BGE" },
{ 2 : "BLT" },
{ 2 : "BGT" },
{ 2 : "BLE" },
{ 1 : "MOVE R0, SP" },
{ 1 : "MOVE SP, R0" },
{ 1 : "JMP (R0)" },
{ 3 : "JMP 0xXXXX" },
{ 2 : "AND PS,#0xXX" },
{ 2 : "OR PS,#0xXX" },
{ 2 : "ADD SP,#0xXX" },
{ 1 : "SQRT" },
{ 1 : "MULU" },
{ 1 : "MULS" },
{ 1 : "DIV.U" },
{ 1 : "DIV.S" },
{ 1 : "ADDX R0,R1" },
{ 1 : "SUBX R0,R1" },
{ 1 : "NEGX R0" },
{ 1 : "NOP" }
};

Changes to dis_d8_db.lua.

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





#!/usr/bin/env lua

function printf( f, ... )
	print( string.format(f, ...) );
end














--
-- Disassembly function for instructions 0xd8..0xdf
-- which take one post-byte


--

local Mnemotic = {

[0] = "LSL RX, #0 .. #15",   -- 0x00..0x0f  :   
"LSL RX, #0 .. #15",   -- 0x00..0x0f  :   
"LSL RX, #-16 .. #-1", -- 0x10..0x1f  :   
"LSL RX, #-16 .. #-1", -- 0x10..0x1f  :   
"LSL RX, R0 .. R3",    -- 0x20..0x23  :   0x24..0x27  :   "-- redundant"
"LSL.WT RX, R0 .. R3",    -- 0x28..0x2b  :   0x2c..0x2f  :   "-- redundant"
"LSR RX, R0 .. R3",    -- 0x30..0x33  :   0x34..0x37  :   "-- redundant"
"LSR.WT RX, R0 .. R3",    -- 0x38..0x3b  :   0x3c..0x3f  :   "-- redundant"
"ASL RX, #0 .. #15",   -- 0x40..0x4f  :   
"ASL RX, #0 .. #15",   -- 0x40..0x4f  :   
"ASL RX, #-16 .. #-1", -- 0x50..0x5f  :   
"ASL RX, #-16 .. #-1", -- 0x50..0x5f  :   
"ASL RX, R0 .. R3",    -- 0x60..0x63  :   0x64..0x67  :   "-- redundant"
"ASL.WT, R0 .. R3",    -- 0x68..0x6b  :   0x6c..0x6f  :   "-- redundant"
"ASR RX, R0 .. R3",    -- 0x70..0x73  :	0x74..0x77  :   "-- redundant"
"ASR.WT RX, R0 .. R3",    -- 0x78..0x7b  :   0x7c..0x7f  :   "-- redundant"
"ROL RX, #0 .. #15",   -- 0x80..0x8f  :   
"ROL RX, #0 .. #15",   -- 0x80..0x8f  :   
"ROL RX, #-16 .. #-1", -- 0x90..0x9f  :   
"ROL RX, #-16 .. #-1", -- 0x90..0x9f  :   
"ROL RX, R0 .. R3",    -- 0xa0..0xa3  :   0xa4..0xa7  :   "-- redundant"
"ROL.WT RX, R0 .. R3",    -- 0xa8..0xab  :   0xac..0xaf  :   "-- redundant"
"ROR RX, R0 .. R3",    -- 0xb0..0xbb  :   0xb4..0xb7  :   "-- redundant"
"ROR.WT RX, R0 .. R3",    -- 0xb8..0xbb  :   0xbc..0xbf  :   "-- redundant"
"ROXL RX, #0 .. #15",   -- 0xc0..0xcf  :   
"ROXL RX, #0 .. #15",   -- 0xc0..0xcf  :   
"ROXL RX, #-16 .. #-1", -- 0xd0..0xdf  :   
"ROXL RX, #-16 .. #-1", -- 0xd0..0xdf  :   
"ROXL RX, R0 .. R3",    -- 0xe0..0xe3  :   0xe4..0xe7  :   "-- redundant"
"ROXL.WT RX, R0 .. R3",   -- 0xe8..0xeb  :    0xec..0xef  :   "-- redundant"
"ROXR RX, R0 .. R3",   -- 0xf0..0xf3  :	 0xf4..0xf7  :   "-- redundant"
"ROXR.WT RX, R0 .. R3"    -- 0xf8..0xfb  :    0xfc..0xff  :   "-- redundant"
}












































a = arg[1];


if(  a == nil
  or a:len() ~= 2
  or a:match("%x%x") == nil) then
  print( "Please enter a 2 hexdigit number" );
else







end--if









|


>
>
>
>
>
>
>
>
>
>
>
>
>



>
>


<
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

>
>
|
>
>
>
>
>
>
>
>
|
>
>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>

<
<
<
<
<
>
>
>
>
>
>
>
|

>
>
>
>
>
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
#!/usr/bin/env lua

function printf( f, ... )
    io.write( string.format(f, ...) );
end

function htob_2( s )
    local hi,lo = s:byte(1,2);
    local hiA,loA;

    hi = bit32.band(hi,0xDF);   hiA = bit32.band(hi,0x0F);
    lo = bit32.band(lo,0xDF);   loA = bit32.band(lo,0x0F);

    if( hi >= 0x40 ) then hiA = hiA + 9 end
    if( lo >= 0x40 ) then loA = loA + 9 end

    return( bit32.bor( bit32.lshift(hiA,4), loA ) );
end

--
-- Disassembly function for instructions 0xd8..0xdf
-- which take one post-byte
-- The lower-case 'd' in each line will be replaced with the destination (0..3)
-- as derived from the instruction.
--


local I_d8_db = { [0] = 
"LSL    Rd, #",   -- 0x00..0x0f  :   
"LSL    Rd, #",   -- 0x00..0x0f  :   
"LSL    Rd, #-", -- 0x10..0x1f  :   
"LSL    Rd, #-", -- 0x10..0x1f  :   
"LSL    Rd, R",    -- 0x20..0x23  :   0x24..0x27  :   "-- redundant"
"LSL.WT Rd, R",    -- 0x28..0x2b  :   0x2c..0x2f  :   "-- redundant"
"LSR    Rd, R",    -- 0x30..0x33  :   0x34..0x37  :   "-- redundant"
"LSR.WT Rd, R",    -- 0x38..0x3b  :   0x3c..0x3f  :   "-- redundant"
"ASL    Rd, #",   -- 0x40..0x4f  :   
"ASL    Rd, #",   -- 0x40..0x4f  :   
"ASL    Rd, #-", -- 0x50..0x5f  :   
"ASL    Rd, #-", -- 0x50..0x5f  :   
"ASL    Rd, R",    -- 0x60..0x63  :   0x64..0x67  :   "-- redundant"
"ASL.WT Rd, R",    -- 0x68..0x6b  :   0x6c..0x6f  :   "-- redundant"
"ASR    Rd, R",    -- 0x70..0x73  :   0x74..0x77  :   "-- redundant"
"ASR.WT Rd, R",    -- 0x78..0x7b  :   0x7c..0x7f  :   "-- redundant"
"ROL    Rd, #",   -- 0x80..0x8f  :   
"ROL    Rd, #",   -- 0x80..0x8f  :   
"ROL    Rd, #-", -- 0x90..0x9f  :   
"ROL    Rd, #-", -- 0x90..0x9f  :   
"ROL    Rd, R",    -- 0xa0..0xa3  :   0xa4..0xa7  :   "-- redundant"
"ROL.WT Rd, R",    -- 0xa8..0xab  :   0xac..0xaf  :   "-- redundant"
"ROR    Rd, R",    -- 0xb0..0xbb  :   0xb4..0xb7  :   "-- redundant"
"ROR.WT Rd, R",    -- 0xb8..0xbb  :   0xbc..0xbf  :   "-- redundant"
"ROXL   Rd, #",   -- 0xc0..0xcf  :   
"ROXL   Rd, #",   -- 0xc0..0xcf  :   
"ROXL   Rd, #-", -- 0xd0..0xdf  :   
"ROXL   Rd, #-", -- 0xd0..0xdf  :   
"ROXL   Rd, R",    -- 0xe0..0xe3  :   0xe4..0xe7  :   "-- redundant"
"ROXL.WT Rd, R",   -- 0xe8..0xeb  :    0xec..0xef  :   "-- redundant"
"ROXR   Rd, R",   -- 0xf0..0xf3  : 0xf4..0xf7  :   "-- redundant"
"ROXR.WT Rd, R"    -- 0xf8..0xfb  :    0xfc..0xff  :   "-- redundant"
};

function dis_d8_db( instr, postb)
        printf( "%02x %02x .. : ", instr, postb );
        
        if( instr >= 0xd8 and instr <= 0xdb ) then
            local dst = bit32.band( instr, 0x03 );
            local src = bit32.rshift(postb,3);
            local result = I_d8_db[src]:gsub("d",tostring(dst),1);
            local lastChar = result:sub(-1);
            if( lastChar == 'R' ) then result = result .. tostring( bit32.band( postb,0x03) ) end;
            if( lastChar == '#' ) then result = result .. tostring( bit32.band( postb,0x0f) ) end; 
            if( lastChar == '-' ) then result = result .. tostring( 16-bit32.band( postb,0x0f) ) end; 
            
            print( result );
        end--if
end

local I_dc_df = { [0] = 
"BTST  Rd, #",
"BTST  Rd, R",
"BCHG  Rd, #",
"BCHG  Rd, R",
"BCLR  Rd, #",
"BCLR  Rd, R",
"BSET  Rd, #",
"BSET  Rd, R"
};

function dis_dc_df( instr, postb)
        printf( "%02x %02x .. : ", instr, postb );
        if( instr >= 0xdc and instr <= 0xdf ) then
                local dst = bit32.band(instr, 0x03);
                local src = bit32.rshift(postb,5);
                -- printf( "%02x %02x", dst, src );
                local result = I_dc_df[src]:gsub("d",tostring(dst),1);
                local lastchar = result:sub(-1);
                if( lastchar == '#' ) then result = result .. tostring( bit32.band(postb,0x0f) ) end;
                if( lastchar == 'R' ) then result = result .. tostring( bit32.band(postb,0x03) ) end;
                print( result );
        end
end

-- Main line
--[[
instr = arg[1];
postb = arg[2];






assert(   instr and instr:match('%x%x') 
      and postb and postb:match('%x%x'),
      "Please supply 2 hex-format bytevalues");


dis_d8_db( htob_2(instr), htob_2(postb) );
--]]
--

for instr = 0xdc,0xdf do
        for postb = 0x00,0xff do
                dis_dc_df(instr,postb);
        end
end