/src/binutils-gdb/opcodes/z8k-dis.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* Disassemble z8000 code. |
2 | | Copyright (C) 1992-2023 Free Software Foundation, Inc. |
3 | | |
4 | | This file is part of the GNU opcodes library. |
5 | | |
6 | | This library is free software; you can redistribute it and/or modify |
7 | | it under the terms of the GNU General Public License as published by |
8 | | the Free Software Foundation; either version 3, or (at your option) |
9 | | any later version. |
10 | | |
11 | | It is distributed in the hope that it will be useful, but WITHOUT |
12 | | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
13 | | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public |
14 | | License for more details. |
15 | | |
16 | | You should have received a copy of the GNU General Public License |
17 | | along with this file; see the file COPYING. If not, write to the |
18 | | Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, |
19 | | MA 02110-1301, USA. */ |
20 | | |
21 | | #include "sysdep.h" |
22 | | #include "disassemble.h" |
23 | | #include "libiberty.h" |
24 | | |
25 | | #define DEFINE_TABLE |
26 | | #include "z8k-opc.h" |
27 | | |
28 | | #include <setjmp.h> |
29 | | |
30 | | typedef struct |
31 | | { |
32 | | /* These are all indexed by nibble number (i.e only every other entry |
33 | | of bytes is used, and every 4th entry of words). */ |
34 | | unsigned char nibbles[24]; |
35 | | unsigned char bytes[24]; |
36 | | unsigned short words[24]; |
37 | | |
38 | | /* Nibble number of first word not yet fetched. */ |
39 | | unsigned int max_fetched; |
40 | | bfd_vma insn_start; |
41 | | OPCODES_SIGJMP_BUF bailout; |
42 | | |
43 | | int tabl_index; |
44 | | char instr_asmsrc[80]; |
45 | | unsigned long arg_reg[0x0f]; |
46 | | unsigned long immediate; |
47 | | unsigned long displacement; |
48 | | unsigned long address; |
49 | | unsigned long cond_code; |
50 | | unsigned long ctrl_code; |
51 | | unsigned long flags; |
52 | | unsigned long interrupts; |
53 | | } |
54 | | instr_data_s; |
55 | | |
56 | | /* Make sure that bytes from INFO->PRIVATE_DATA->BUFFER (inclusive) |
57 | | to ADDR (exclusive) are valid. Returns 1 for success, longjmps |
58 | | on error. */ |
59 | | #define FETCH_DATA(info, nibble) \ |
60 | 413k | ((nibble) < ((instr_data_s *) (info->private_data))->max_fetched \ |
61 | 413k | ? 1 : fetch_data ((info), (nibble))) |
62 | | |
63 | | static int |
64 | | fetch_data (struct disassemble_info *info, int nibble) |
65 | 331k | { |
66 | 331k | unsigned char mybuf[20]; |
67 | 331k | int status; |
68 | 331k | instr_data_s *priv = (instr_data_s *) info->private_data; |
69 | | |
70 | 331k | if ((nibble % 4) != 0) |
71 | 0 | abort (); |
72 | | |
73 | 331k | status = (*info->read_memory_func) (priv->insn_start, |
74 | 331k | (bfd_byte *) mybuf, |
75 | 331k | nibble / 2, |
76 | 331k | info); |
77 | 331k | if (status != 0) |
78 | 41 | { |
79 | 41 | (*info->memory_error_func) (status, priv->insn_start, info); |
80 | 41 | OPCODES_SIGLONGJMP (priv->bailout, 1); |
81 | 41 | } |
82 | | |
83 | 331k | { |
84 | 331k | int i; |
85 | 331k | unsigned char *p = mybuf; |
86 | | |
87 | 741k | for (i = 0; i < nibble;) |
88 | 410k | { |
89 | 410k | priv->words[i] = (p[0] << 8) | p[1]; |
90 | | |
91 | 410k | priv->bytes[i] = *p; |
92 | 410k | priv->nibbles[i++] = *p >> 4; |
93 | 410k | priv->nibbles[i++] = *p & 0xf; |
94 | | |
95 | 410k | ++p; |
96 | 410k | priv->bytes[i] = *p; |
97 | 410k | priv->nibbles[i++] = *p >> 4; |
98 | 410k | priv->nibbles[i++] = *p & 0xf; |
99 | | |
100 | 410k | ++p; |
101 | 410k | } |
102 | 331k | } |
103 | 331k | priv->max_fetched = nibble; |
104 | 331k | return 1; |
105 | 331k | } |
106 | | |
107 | | static char *codes[16] = |
108 | | { |
109 | | "f", |
110 | | "lt", |
111 | | "le", |
112 | | "ule", |
113 | | "ov/pe", |
114 | | "mi", |
115 | | "eq", |
116 | | "c/ult", |
117 | | "t", |
118 | | "ge", |
119 | | "gt", |
120 | | "ugt", |
121 | | "nov/po", |
122 | | "pl", |
123 | | "ne", |
124 | | "nc/uge" |
125 | | }; |
126 | | |
127 | | static char *ctrl_names[8] = |
128 | | { |
129 | | "<invld>", |
130 | | "flags", |
131 | | "fcw", |
132 | | "refresh", |
133 | | "psapseg", |
134 | | "psapoff", |
135 | | "nspseg", |
136 | | "nspoff" |
137 | | }; |
138 | | |
139 | | static int seg_length; |
140 | | int z8k_lookup_instr (unsigned char *, disassemble_info *); |
141 | | static void output_instr (instr_data_s *, unsigned long, disassemble_info *); |
142 | | static void unpack_instr (instr_data_s *, int, disassemble_info *); |
143 | | static void unparse_instr (instr_data_s *, int); |
144 | | |
145 | | static int |
146 | | print_insn_z8k (bfd_vma addr, disassemble_info *info, int is_segmented) |
147 | 68.7k | { |
148 | 68.7k | instr_data_s instr_data; |
149 | | |
150 | 68.7k | info->private_data = &instr_data; |
151 | 68.7k | instr_data.max_fetched = 0; |
152 | 68.7k | instr_data.insn_start = addr; |
153 | 68.7k | if (OPCODES_SIGSETJMP (instr_data.bailout) != 0) |
154 | | /* Error return. */ |
155 | 41 | return -1; |
156 | | |
157 | 68.7k | info->bytes_per_chunk = 2; |
158 | 68.7k | info->bytes_per_line = 6; |
159 | 68.7k | info->display_endian = BFD_ENDIAN_BIG; |
160 | | |
161 | 68.7k | instr_data.tabl_index = z8k_lookup_instr (instr_data.nibbles, info); |
162 | 68.7k | if (instr_data.tabl_index >= 0) |
163 | 62.0k | { |
164 | 62.0k | unpack_instr (&instr_data, is_segmented, info); |
165 | 62.0k | unparse_instr (&instr_data, is_segmented); |
166 | 62.0k | output_instr (&instr_data, addr, info); |
167 | 62.0k | return z8k_table[instr_data.tabl_index].length + seg_length; |
168 | 62.0k | } |
169 | 6.62k | else |
170 | 6.62k | { |
171 | 6.62k | FETCH_DATA (info, 4); |
172 | 6.62k | (*info->fprintf_func) (info->stream, ".word %02x%02x", |
173 | 6.62k | instr_data.bytes[0], instr_data.bytes[2]); |
174 | 6.62k | return 2; |
175 | 6.62k | } |
176 | 68.7k | } |
177 | | |
178 | | int |
179 | | print_insn_z8001 (bfd_vma addr, disassemble_info *info) |
180 | 62.2k | { |
181 | 62.2k | return print_insn_z8k (addr, info, 1); |
182 | 62.2k | } |
183 | | |
184 | | int |
185 | | print_insn_z8002 (bfd_vma addr, disassemble_info *info) |
186 | 6.47k | { |
187 | 6.47k | return print_insn_z8k (addr, info, 0); |
188 | 6.47k | } |
189 | | |
190 | | int |
191 | | z8k_lookup_instr (unsigned char *nibbles, disassemble_info *info) |
192 | 68.7k | { |
193 | 68.7k | unsigned int nibl_index, tabl_index; |
194 | 68.7k | int nibl_matched; |
195 | 68.7k | int need_fetch = 0; |
196 | 68.7k | unsigned short instr_nibl; |
197 | 68.7k | unsigned short tabl_datum, datum_class, datum_value; |
198 | | |
199 | 68.7k | nibl_matched = 0; |
200 | 68.7k | tabl_index = 0; |
201 | 68.7k | FETCH_DATA (info, 4); |
202 | 12.5M | while (!nibl_matched && z8k_table[tabl_index].name) |
203 | 12.5M | { |
204 | 12.5M | nibl_matched = 1; |
205 | 12.5M | for (nibl_index = 0; |
206 | 26.3M | nibl_matched |
207 | 26.3M | && nibl_index < ARRAY_SIZE (z8k_table[0].byte_info) |
208 | 26.3M | && nibl_index < z8k_table[tabl_index].length * 2; |
209 | 13.7M | nibl_index++) |
210 | 13.7M | { |
211 | 13.7M | if ((nibl_index % 4) == 0) |
212 | 12.5M | { |
213 | | /* Fetch data only if it isn't already there. */ |
214 | 12.5M | if (nibl_index >= 4 || (nibl_index < 4 && need_fetch)) |
215 | 23.9k | FETCH_DATA (info, nibl_index + 4); /* Fetch one word at a time. */ |
216 | 12.5M | if (nibl_index < 4) |
217 | 12.5M | need_fetch = 0; |
218 | 21.8k | else |
219 | 21.8k | need_fetch = 1; |
220 | 12.5M | } |
221 | 13.7M | instr_nibl = nibbles[nibl_index]; |
222 | | |
223 | 13.7M | tabl_datum = z8k_table[tabl_index].byte_info[nibl_index]; |
224 | 13.7M | datum_class = tabl_datum & CLASS_MASK; |
225 | 13.7M | datum_value = ~CLASS_MASK & tabl_datum; |
226 | | |
227 | 13.7M | switch (datum_class) |
228 | 13.7M | { |
229 | 13.5M | case CLASS_BIT: |
230 | 13.5M | if (datum_value != instr_nibl) |
231 | 12.4M | nibl_matched = 0; |
232 | 13.5M | break; |
233 | 56 | case CLASS_IGNORE: |
234 | 56 | break; |
235 | 50 | case CLASS_00II: |
236 | 50 | if (!((~instr_nibl) & 0x4)) |
237 | 13 | nibl_matched = 0; |
238 | 50 | break; |
239 | 13 | case CLASS_01II: |
240 | 13 | if (!(instr_nibl & 0x4)) |
241 | 0 | nibl_matched = 0; |
242 | 13 | break; |
243 | 123 | case CLASS_0CCC: |
244 | 123 | if (!((~instr_nibl) & 0x8)) |
245 | 0 | nibl_matched = 0; |
246 | 123 | break; |
247 | 307 | case CLASS_1CCC: |
248 | 307 | if (!(instr_nibl & 0x8)) |
249 | 123 | nibl_matched = 0; |
250 | 307 | break; |
251 | 5.49k | case CLASS_0DISP7: |
252 | 5.49k | if (!((~instr_nibl) & 0x8)) |
253 | 3.45k | nibl_matched = 0; |
254 | 5.49k | nibl_index += 1; |
255 | 5.49k | break; |
256 | 3.45k | case CLASS_1DISP7: |
257 | 3.45k | if (!(instr_nibl & 0x8)) |
258 | 0 | nibl_matched = 0; |
259 | 3.45k | nibl_index += 1; |
260 | 3.45k | break; |
261 | 49.0k | case CLASS_REGN0: |
262 | 49.0k | if (instr_nibl == 0) |
263 | 11.7k | nibl_matched = 0; |
264 | 49.0k | break; |
265 | 942 | case CLASS_BIT_1OR2: |
266 | 942 | if ((instr_nibl | 0x2) != (datum_value | 0x2)) |
267 | 792 | nibl_matched = 0; |
268 | 942 | break; |
269 | 189k | default: |
270 | 189k | break; |
271 | 13.7M | } |
272 | 13.7M | } |
273 | | |
274 | 12.5M | if (nibl_matched) |
275 | 62.0k | return tabl_index; |
276 | | |
277 | 12.5M | tabl_index++; |
278 | 12.5M | } |
279 | 6.63k | return -1; |
280 | 68.7k | } |
281 | | |
282 | | static void |
283 | | output_instr (instr_data_s *instr_data, |
284 | | unsigned long addr ATTRIBUTE_UNUSED, |
285 | | disassemble_info *info) |
286 | 62.0k | { |
287 | 62.0k | unsigned int num_bytes; |
288 | 62.0k | char out_str[100]; |
289 | | |
290 | 62.0k | out_str[0] = 0; |
291 | | |
292 | 62.0k | num_bytes = (z8k_table[instr_data->tabl_index].length + seg_length) * 2; |
293 | 62.0k | FETCH_DATA (info, num_bytes); |
294 | | |
295 | 62.0k | strcat (out_str, instr_data->instr_asmsrc); |
296 | | |
297 | 62.0k | (*info->fprintf_func) (info->stream, "%s", out_str); |
298 | 62.0k | } |
299 | | |
300 | | static void |
301 | | unpack_instr (instr_data_s *instr_data, int is_segmented, disassemble_info *info) |
302 | 62.0k | { |
303 | 62.0k | unsigned int nibl_count, loop; |
304 | 62.0k | unsigned short instr_nibl, instr_byte, instr_word; |
305 | 62.0k | long instr_long; |
306 | 62.0k | unsigned int tabl_datum, datum_class; |
307 | 62.0k | unsigned short datum_value; |
308 | | |
309 | 62.0k | nibl_count = 0; |
310 | 62.0k | loop = 0; |
311 | 62.0k | seg_length = 0; |
312 | | |
313 | 310k | while (z8k_table[instr_data->tabl_index].byte_info[loop] != 0) |
314 | 248k | { |
315 | 248k | FETCH_DATA (info, nibl_count + 4 - (nibl_count % 4)); |
316 | 248k | instr_nibl = instr_data->nibbles[nibl_count]; |
317 | 248k | instr_byte = instr_data->bytes[nibl_count & ~1]; |
318 | 248k | instr_word = instr_data->words[nibl_count & ~3]; |
319 | | |
320 | 248k | tabl_datum = z8k_table[instr_data->tabl_index].byte_info[loop]; |
321 | 248k | datum_class = tabl_datum & CLASS_MASK; |
322 | 248k | datum_value = tabl_datum & ~CLASS_MASK; |
323 | | |
324 | 248k | switch (datum_class) |
325 | 248k | { |
326 | 6.22k | case CLASS_DISP: |
327 | 6.22k | switch (datum_value) |
328 | 6.22k | { |
329 | 111 | case ARG_DISP16: |
330 | 111 | instr_data->displacement = instr_data->insn_start + 4 |
331 | 111 | + (signed short) (instr_word & 0xffff); |
332 | 111 | nibl_count += 3; |
333 | 111 | break; |
334 | 6.11k | case ARG_DISP12: |
335 | 6.11k | if (instr_word & 0x800) |
336 | | /* Negative 12 bit displacement. */ |
337 | 1.27k | instr_data->displacement = instr_data->insn_start + 2 |
338 | 1.27k | - (signed short) ((instr_word & 0xfff) | 0xf000) * 2; |
339 | 4.84k | else |
340 | 4.84k | instr_data->displacement = instr_data->insn_start + 2 |
341 | 4.84k | - (instr_word & 0x0fff) * 2; |
342 | | |
343 | 6.11k | nibl_count += 2; |
344 | 6.11k | break; |
345 | 0 | default: |
346 | 0 | break; |
347 | 6.22k | } |
348 | 6.22k | break; |
349 | 28.6k | case CLASS_IMM: |
350 | 28.6k | switch (datum_value) |
351 | 28.6k | { |
352 | 4.25k | case ARG_IMM4: |
353 | 4.25k | instr_data->immediate = instr_nibl; |
354 | 4.25k | break; |
355 | 0 | case ARG_NIM4: |
356 | 0 | instr_data->immediate = (- instr_nibl) & 0xf; |
357 | 0 | break; |
358 | 18 | case ARG_NIM8: |
359 | 18 | instr_data->immediate = (- instr_byte) & 0xff; |
360 | 18 | nibl_count += 1; |
361 | 18 | break; |
362 | 18.9k | case ARG_IMM8: |
363 | 18.9k | instr_data->immediate = instr_byte; |
364 | 18.9k | nibl_count += 1; |
365 | 18.9k | break; |
366 | 3.03k | case ARG_IMM16: |
367 | 3.03k | instr_data->immediate = instr_word; |
368 | 3.03k | nibl_count += 3; |
369 | 3.03k | break; |
370 | 310 | case ARG_IMM32: |
371 | 310 | FETCH_DATA (info, nibl_count + 8); |
372 | 310 | instr_long = ((unsigned) instr_data->words[nibl_count] << 16 |
373 | 310 | | instr_data->words[nibl_count + 4]); |
374 | 310 | instr_data->immediate = instr_long; |
375 | 310 | nibl_count += 7; |
376 | 310 | break; |
377 | 0 | case ARG_IMMN: |
378 | 0 | instr_data->immediate = instr_nibl - 1; |
379 | 0 | break; |
380 | 2.14k | case ARG_IMM4M1: |
381 | 2.14k | instr_data->immediate = instr_nibl + 1; |
382 | 2.14k | break; |
383 | 0 | case ARG_IMM_1: |
384 | 0 | instr_data->immediate = 1; |
385 | 0 | break; |
386 | 0 | case ARG_IMM_2: |
387 | 0 | instr_data->immediate = 2; |
388 | 0 | break; |
389 | 0 | case ARG_IMM2: |
390 | 0 | instr_data->immediate = instr_nibl & 0x3; |
391 | 0 | break; |
392 | 0 | default: |
393 | 0 | break; |
394 | 28.6k | } |
395 | 28.6k | break; |
396 | 28.6k | case CLASS_CC: |
397 | 3.81k | instr_data->cond_code = instr_nibl; |
398 | 3.81k | break; |
399 | 9.21k | case CLASS_ADDRESS: |
400 | 9.21k | if (is_segmented) |
401 | 8.16k | { |
402 | 8.16k | if (instr_nibl & 0x8) |
403 | 3.43k | { |
404 | 3.43k | FETCH_DATA (info, nibl_count + 8); |
405 | 3.43k | instr_long = ((unsigned) instr_data->words[nibl_count] << 16 |
406 | 3.43k | | instr_data->words[nibl_count + 4]); |
407 | 3.43k | instr_data->address = ((instr_word & 0x7f00) << 16 |
408 | 3.43k | | (instr_long & 0xffff)); |
409 | 3.43k | nibl_count += 7; |
410 | 3.43k | seg_length = 2; |
411 | 3.43k | } |
412 | 4.72k | else |
413 | 4.72k | { |
414 | 4.72k | instr_data->address = ((instr_word & 0x7f00) << 16 |
415 | 4.72k | | (instr_word & 0x00ff)); |
416 | 4.72k | nibl_count += 3; |
417 | 4.72k | } |
418 | 8.16k | } |
419 | 1.05k | else |
420 | 1.05k | { |
421 | 1.05k | instr_data->address = instr_word; |
422 | 1.05k | nibl_count += 3; |
423 | 1.05k | } |
424 | 9.21k | break; |
425 | 123 | case CLASS_0CCC: |
426 | 307 | case CLASS_1CCC: |
427 | 307 | instr_data->ctrl_code = instr_nibl & 0x7; |
428 | 307 | break; |
429 | 2.03k | case CLASS_0DISP7: |
430 | 2.03k | instr_data->displacement = |
431 | 2.03k | instr_data->insn_start + 2 - (instr_byte & 0x7f) * 2; |
432 | 2.03k | nibl_count += 1; |
433 | 2.03k | break; |
434 | 3.45k | case CLASS_1DISP7: |
435 | 3.45k | instr_data->displacement = |
436 | 3.45k | instr_data->insn_start + 2 - (instr_byte & 0x7f) * 2; |
437 | 3.45k | nibl_count += 1; |
438 | 3.45k | break; |
439 | 13 | case CLASS_01II: |
440 | 13 | instr_data->interrupts = instr_nibl & 0x3; |
441 | 13 | break; |
442 | 37 | case CLASS_00II: |
443 | 37 | instr_data->interrupts = instr_nibl & 0x3; |
444 | 37 | break; |
445 | 8 | case CLASS_IGNORE: |
446 | 116k | case CLASS_BIT: |
447 | 116k | instr_data->ctrl_code = instr_nibl & 0x7; |
448 | 116k | break; |
449 | 49 | case CLASS_FLAGS: |
450 | 49 | instr_data->flags = instr_nibl; |
451 | 49 | break; |
452 | 52.7k | case CLASS_REG: |
453 | 52.7k | instr_data->arg_reg[datum_value] = instr_nibl; |
454 | 52.7k | break; |
455 | 21.3k | case CLASS_REGN0: |
456 | 21.3k | instr_data->arg_reg[datum_value] = instr_nibl; |
457 | 21.3k | break; |
458 | 3.13k | case CLASS_DISP8: |
459 | 3.13k | instr_data->displacement = |
460 | 3.13k | instr_data->insn_start + 2 + (signed char) instr_byte * 2; |
461 | 3.13k | nibl_count += 1; |
462 | 3.13k | break; |
463 | 150 | case CLASS_BIT_1OR2: |
464 | 150 | instr_data->immediate = ((instr_nibl >> 1) & 0x1) + 1; |
465 | 150 | nibl_count += 1; |
466 | 150 | break; |
467 | 0 | default: |
468 | 0 | abort (); |
469 | 0 | break; |
470 | 248k | } |
471 | | |
472 | 248k | loop += 1; |
473 | 248k | nibl_count += 1; |
474 | 248k | } |
475 | 62.0k | } |
476 | | |
477 | | static void |
478 | | print_intr(char *tmp_str, unsigned long interrupts) |
479 | 50 | { |
480 | 50 | int comma = 0; |
481 | | |
482 | 50 | *tmp_str = 0; |
483 | 50 | if (! (interrupts & 2)) |
484 | 39 | { |
485 | 39 | strcat (tmp_str, "vi"); |
486 | 39 | comma = 1; |
487 | 39 | } |
488 | 50 | if (! (interrupts & 1)) |
489 | 23 | { |
490 | 23 | if (comma) strcat (tmp_str, ","); |
491 | 23 | strcat (tmp_str, "nvi"); |
492 | 23 | } |
493 | 50 | } |
494 | | |
495 | | static void |
496 | | print_flags(char *tmp_str, unsigned long flags) |
497 | 49 | { |
498 | 49 | int comma = 0; |
499 | | |
500 | 49 | *tmp_str = 0; |
501 | 49 | if (flags & 8) |
502 | 15 | { |
503 | 15 | strcat (tmp_str, "c"); |
504 | 15 | comma = 1; |
505 | 15 | } |
506 | 49 | if (flags & 4) |
507 | 41 | { |
508 | 41 | if (comma) strcat (tmp_str, ","); |
509 | 41 | strcat (tmp_str, "z"); |
510 | 41 | comma = 1; |
511 | 41 | } |
512 | 49 | if (flags & 2) |
513 | 14 | { |
514 | 14 | if (comma) strcat (tmp_str, ","); |
515 | 14 | strcat (tmp_str, "s"); |
516 | 14 | comma = 1; |
517 | 14 | } |
518 | 49 | if (flags & 1) |
519 | 34 | { |
520 | 34 | if (comma) strcat (tmp_str, ","); |
521 | 34 | strcat (tmp_str, "p"); |
522 | 34 | } |
523 | 49 | } |
524 | | |
525 | | static void |
526 | | unparse_instr (instr_data_s *instr_data, int is_segmented) |
527 | 62.0k | { |
528 | 62.0k | unsigned short datum_value; |
529 | 62.0k | unsigned int tabl_datum, datum_class; |
530 | 62.0k | int loop, loop_limit; |
531 | 62.0k | char out_str[80], tmp_str[25]; |
532 | | |
533 | 62.0k | sprintf (out_str, "%s\t", z8k_table[instr_data->tabl_index].name); |
534 | | |
535 | 62.0k | loop_limit = z8k_table[instr_data->tabl_index].noperands; |
536 | 175k | for (loop = 0; loop < loop_limit; loop++) |
537 | 113k | { |
538 | 113k | if (loop) |
539 | 52.8k | strcat (out_str, ","); |
540 | | |
541 | 113k | tabl_datum = z8k_table[instr_data->tabl_index].arg_info[loop]; |
542 | 113k | datum_class = tabl_datum & CLASS_MASK; |
543 | 113k | datum_value = tabl_datum & ~CLASS_MASK; |
544 | | |
545 | 113k | switch (datum_class) |
546 | 113k | { |
547 | 8.38k | case CLASS_X: |
548 | 8.38k | sprintf (tmp_str, "0x%0lx(r%ld)", instr_data->address, |
549 | 8.38k | instr_data->arg_reg[datum_value]); |
550 | 8.38k | strcat (out_str, tmp_str); |
551 | 8.38k | break; |
552 | 1.29k | case CLASS_BA: |
553 | 1.29k | if (is_segmented) |
554 | 1.12k | sprintf (tmp_str, "rr%ld(#0x%lx)", instr_data->arg_reg[datum_value], |
555 | 1.12k | instr_data->immediate); |
556 | 171 | else |
557 | 171 | sprintf (tmp_str, "r%ld(#0x%lx)", instr_data->arg_reg[datum_value], |
558 | 171 | instr_data->immediate); |
559 | 1.29k | strcat (out_str, tmp_str); |
560 | 1.29k | break; |
561 | 30 | case CLASS_BX: |
562 | 30 | if (is_segmented) |
563 | 30 | sprintf (tmp_str, "rr%ld(r%ld)", instr_data->arg_reg[datum_value], |
564 | 30 | instr_data->arg_reg[ARG_RX]); |
565 | 0 | else |
566 | 0 | sprintf (tmp_str, "r%ld(r%ld)", instr_data->arg_reg[datum_value], |
567 | 0 | instr_data->arg_reg[ARG_RX]); |
568 | 30 | strcat (out_str, tmp_str); |
569 | 30 | break; |
570 | 14.8k | case CLASS_DISP: |
571 | 14.8k | sprintf (tmp_str, "0x%0lx", instr_data->displacement); |
572 | 14.8k | strcat (out_str, tmp_str); |
573 | 14.8k | break; |
574 | 19.4k | case CLASS_IMM: |
575 | 19.4k | if (datum_value == ARG_IMM2) /* True with EI/DI instructions only. */ |
576 | 50 | { |
577 | 50 | print_intr (tmp_str, instr_data->interrupts); |
578 | 50 | strcat (out_str, tmp_str); |
579 | 50 | break; |
580 | 50 | } |
581 | 19.3k | sprintf (tmp_str, "#0x%0lx", instr_data->immediate); |
582 | 19.3k | strcat (out_str, tmp_str); |
583 | 19.3k | break; |
584 | 3.81k | case CLASS_CC: |
585 | 3.81k | sprintf (tmp_str, "%s", codes[instr_data->cond_code]); |
586 | 3.81k | strcat (out_str, tmp_str); |
587 | 3.81k | break; |
588 | 353 | case CLASS_CTRL: |
589 | 353 | sprintf (tmp_str, "%s", ctrl_names[instr_data->ctrl_code]); |
590 | 353 | strcat (out_str, tmp_str); |
591 | 353 | break; |
592 | 829 | case CLASS_DA: |
593 | 829 | case CLASS_ADDRESS: |
594 | 829 | sprintf (tmp_str, "0x%0lx", instr_data->address); |
595 | 829 | strcat (out_str, tmp_str); |
596 | 829 | break; |
597 | 11.6k | case CLASS_IR: |
598 | 11.6k | if (is_segmented) |
599 | 10.6k | sprintf (tmp_str, "@rr%ld", instr_data->arg_reg[datum_value]); |
600 | 1.04k | else |
601 | 1.04k | sprintf (tmp_str, "@r%ld", instr_data->arg_reg[datum_value]); |
602 | 11.6k | strcat (out_str, tmp_str); |
603 | 11.6k | break; |
604 | 1.59k | case CLASS_IRO: |
605 | 1.59k | sprintf (tmp_str, "@r%ld", instr_data->arg_reg[datum_value]); |
606 | 1.59k | strcat (out_str, tmp_str); |
607 | 1.59k | break; |
608 | 49 | case CLASS_FLAGS: |
609 | 49 | print_flags(tmp_str, instr_data->flags); |
610 | 49 | strcat (out_str, tmp_str); |
611 | 49 | break; |
612 | 24.9k | case CLASS_REG_BYTE: |
613 | 24.9k | if (instr_data->arg_reg[datum_value] >= 0x8) |
614 | 10.5k | sprintf (tmp_str, "rl%ld", |
615 | 10.5k | instr_data->arg_reg[datum_value] - 0x8); |
616 | 14.4k | else |
617 | 14.4k | sprintf (tmp_str, "rh%ld", instr_data->arg_reg[datum_value]); |
618 | 24.9k | strcat (out_str, tmp_str); |
619 | 24.9k | break; |
620 | 15.8k | case CLASS_REG_WORD: |
621 | 15.8k | sprintf (tmp_str, "r%ld", instr_data->arg_reg[datum_value]); |
622 | 15.8k | strcat (out_str, tmp_str); |
623 | 15.8k | break; |
624 | 903 | case CLASS_REG_QUAD: |
625 | 903 | sprintf (tmp_str, "rq%ld", instr_data->arg_reg[datum_value]); |
626 | 903 | strcat (out_str, tmp_str); |
627 | 903 | break; |
628 | 8.70k | case CLASS_REG_LONG: |
629 | 8.70k | sprintf (tmp_str, "rr%ld", instr_data->arg_reg[datum_value]); |
630 | 8.70k | strcat (out_str, tmp_str); |
631 | 8.70k | break; |
632 | 701 | case CLASS_PR: |
633 | 701 | if (is_segmented) |
634 | 410 | sprintf (tmp_str, "rr%ld", instr_data->arg_reg[datum_value]); |
635 | 291 | else |
636 | 291 | sprintf (tmp_str, "r%ld", instr_data->arg_reg[datum_value]); |
637 | 701 | strcat (out_str, tmp_str); |
638 | 701 | break; |
639 | 0 | default: |
640 | 0 | abort (); |
641 | 0 | break; |
642 | 113k | } |
643 | 113k | } |
644 | | |
645 | 62.0k | strcpy (instr_data->instr_asmsrc, out_str); |
646 | 62.0k | } |