/src/binutils-gdb/opcodes/z8k-dis.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* Disassemble z8000 code. |
2 | | Copyright (C) 1992-2025 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 | 24.9M | ((nibble) < ((instr_data_s *) (info->private_data))->max_fetched \ |
61 | 24.9M | ? 1 : fetch_data ((info), (nibble))) |
62 | | |
63 | | static int |
64 | | fetch_data (struct disassemble_info *info, int nibble) |
65 | 17.8M | { |
66 | 17.8M | unsigned char mybuf[20]; |
67 | 17.8M | int status; |
68 | 17.8M | instr_data_s *priv = (instr_data_s *) info->private_data; |
69 | | |
70 | 17.8M | if ((nibble % 4) != 0) |
71 | 0 | abort (); |
72 | | |
73 | 17.8M | status = (*info->read_memory_func) (priv->insn_start, |
74 | 17.8M | (bfd_byte *) mybuf, |
75 | 17.8M | nibble / 2, |
76 | 17.8M | info); |
77 | 17.8M | if (status != 0) |
78 | 503 | { |
79 | 503 | (*info->memory_error_func) (status, priv->insn_start, info); |
80 | 503 | OPCODES_SIGLONGJMP (priv->bailout, 1); |
81 | 503 | } |
82 | | |
83 | 17.8M | { |
84 | 17.8M | int i; |
85 | 17.8M | unsigned char *p = mybuf; |
86 | | |
87 | 42.1M | for (i = 0; i < nibble;) |
88 | 24.2M | { |
89 | 24.2M | priv->words[i] = (p[0] << 8) | p[1]; |
90 | | |
91 | 24.2M | priv->bytes[i] = *p; |
92 | 24.2M | priv->nibbles[i++] = *p >> 4; |
93 | 24.2M | priv->nibbles[i++] = *p & 0xf; |
94 | | |
95 | 24.2M | ++p; |
96 | 24.2M | priv->bytes[i] = *p; |
97 | 24.2M | priv->nibbles[i++] = *p >> 4; |
98 | 24.2M | priv->nibbles[i++] = *p & 0xf; |
99 | | |
100 | 24.2M | ++p; |
101 | 24.2M | } |
102 | 17.8M | } |
103 | 17.8M | priv->max_fetched = nibble; |
104 | 17.8M | return 1; |
105 | 17.8M | } |
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 | 3.74M | { |
148 | 3.74M | instr_data_s instr_data; |
149 | | |
150 | 3.74M | info->private_data = &instr_data; |
151 | 3.74M | instr_data.max_fetched = 0; |
152 | 3.74M | instr_data.insn_start = addr; |
153 | 3.74M | if (OPCODES_SIGSETJMP (instr_data.bailout) != 0) |
154 | | /* Error return. */ |
155 | 503 | return -1; |
156 | | |
157 | 3.74M | info->bytes_per_chunk = 2; |
158 | 3.74M | info->bytes_per_line = 6; |
159 | 3.74M | info->display_endian = BFD_ENDIAN_BIG; |
160 | | |
161 | 3.74M | instr_data.tabl_index = z8k_lookup_instr (instr_data.nibbles, info); |
162 | 3.74M | if (instr_data.tabl_index >= 0) |
163 | 3.40M | { |
164 | 3.40M | unpack_instr (&instr_data, is_segmented, info); |
165 | 3.40M | unparse_instr (&instr_data, is_segmented); |
166 | 3.40M | output_instr (&instr_data, addr, info); |
167 | 3.40M | return z8k_table[instr_data.tabl_index].length + seg_length; |
168 | 3.40M | } |
169 | 342k | else |
170 | 342k | { |
171 | 342k | FETCH_DATA (info, 4); |
172 | 342k | (*info->fprintf_func) (info->stream, ".word %02x%02x", |
173 | 342k | instr_data.bytes[0], instr_data.bytes[2]); |
174 | 342k | return 2; |
175 | 342k | } |
176 | 3.74M | } |
177 | | |
178 | | int |
179 | | print_insn_z8001 (bfd_vma addr, disassemble_info *info) |
180 | 401k | { |
181 | 401k | return print_insn_z8k (addr, info, 1); |
182 | 401k | } |
183 | | |
184 | | int |
185 | | print_insn_z8002 (bfd_vma addr, disassemble_info *info) |
186 | 3.34M | { |
187 | 3.34M | return print_insn_z8k (addr, info, 0); |
188 | 3.34M | } |
189 | | |
190 | | int |
191 | | z8k_lookup_instr (unsigned char *nibbles, disassemble_info *info) |
192 | 3.74M | { |
193 | 3.74M | unsigned int nibl_index, tabl_index; |
194 | 3.74M | int nibl_matched; |
195 | 3.74M | int need_fetch = 0; |
196 | 3.74M | unsigned short instr_nibl; |
197 | 3.74M | unsigned short tabl_datum, datum_class, datum_value; |
198 | | |
199 | 3.74M | nibl_matched = 0; |
200 | 3.74M | tabl_index = 0; |
201 | 3.74M | FETCH_DATA (info, 4); |
202 | 572M | while (!nibl_matched && z8k_table[tabl_index].name) |
203 | 571M | { |
204 | 571M | nibl_matched = 1; |
205 | 571M | for (nibl_index = 0; |
206 | 1.20G | nibl_matched |
207 | 1.20G | && nibl_index < ARRAY_SIZE (z8k_table[0].byte_info) |
208 | 1.20G | && nibl_index < z8k_table[tabl_index].length * 2; |
209 | 633M | nibl_index++) |
210 | 633M | { |
211 | 633M | if ((nibl_index % 4) == 0) |
212 | 573M | { |
213 | | /* Fetch data only if it isn't already there. */ |
214 | 573M | if (nibl_index >= 4 || (nibl_index < 4 && need_fetch)) |
215 | 2.02M | FETCH_DATA (info, nibl_index + 4); /* Fetch one word at a time. */ |
216 | 573M | if (nibl_index < 4) |
217 | 571M | need_fetch = 0; |
218 | 1.86M | else |
219 | 1.86M | need_fetch = 1; |
220 | 573M | } |
221 | 633M | instr_nibl = nibbles[nibl_index]; |
222 | | |
223 | 633M | tabl_datum = z8k_table[tabl_index].byte_info[nibl_index]; |
224 | 633M | datum_class = tabl_datum & CLASS_MASK; |
225 | 633M | datum_value = ~CLASS_MASK & tabl_datum; |
226 | | |
227 | 633M | switch (datum_class) |
228 | 633M | { |
229 | 617M | case CLASS_BIT: |
230 | 617M | if (datum_value != instr_nibl) |
231 | 566M | nibl_matched = 0; |
232 | 617M | break; |
233 | 960 | case CLASS_IGNORE: |
234 | 960 | break; |
235 | 1.55k | case CLASS_00II: |
236 | 1.55k | if (!((~instr_nibl) & 0x4)) |
237 | 154 | nibl_matched = 0; |
238 | 1.55k | break; |
239 | 154 | case CLASS_01II: |
240 | 154 | if (!(instr_nibl & 0x4)) |
241 | 0 | nibl_matched = 0; |
242 | 154 | break; |
243 | 2.26k | case CLASS_0CCC: |
244 | 2.26k | if (!((~instr_nibl) & 0x8)) |
245 | 0 | nibl_matched = 0; |
246 | 2.26k | break; |
247 | 7.24k | case CLASS_1CCC: |
248 | 7.24k | if (!(instr_nibl & 0x8)) |
249 | 2.26k | nibl_matched = 0; |
250 | 7.24k | break; |
251 | 381k | case CLASS_0DISP7: |
252 | 381k | if (!((~instr_nibl) & 0x8)) |
253 | 286k | nibl_matched = 0; |
254 | 381k | nibl_index += 1; |
255 | 381k | break; |
256 | 286k | case CLASS_1DISP7: |
257 | 286k | if (!(instr_nibl & 0x8)) |
258 | 0 | nibl_matched = 0; |
259 | 286k | nibl_index += 1; |
260 | 286k | break; |
261 | 3.16M | case CLASS_REGN0: |
262 | 3.16M | if (instr_nibl == 0) |
263 | 1.52M | nibl_matched = 0; |
264 | 3.16M | break; |
265 | 23.2k | case CLASS_BIT_1OR2: |
266 | 23.2k | if ((instr_nibl | 0x2) != (datum_value | 0x2)) |
267 | 19.7k | nibl_matched = 0; |
268 | 23.2k | break; |
269 | 11.8M | default: |
270 | 11.8M | break; |
271 | 633M | } |
272 | 633M | } |
273 | | |
274 | 571M | if (nibl_matched) |
275 | 3.40M | return tabl_index; |
276 | | |
277 | 568M | tabl_index++; |
278 | 568M | } |
279 | 342k | return -1; |
280 | 3.74M | } |
281 | | |
282 | | static void |
283 | | output_instr (instr_data_s *instr_data, |
284 | | unsigned long addr ATTRIBUTE_UNUSED, |
285 | | disassemble_info *info) |
286 | 3.40M | { |
287 | 3.40M | unsigned int num_bytes; |
288 | 3.40M | char out_str[100]; |
289 | | |
290 | 3.40M | out_str[0] = 0; |
291 | | |
292 | 3.40M | num_bytes = (z8k_table[instr_data->tabl_index].length + seg_length) * 2; |
293 | 3.40M | FETCH_DATA (info, num_bytes); |
294 | | |
295 | 3.40M | strcat (out_str, instr_data->instr_asmsrc); |
296 | | |
297 | 3.40M | (*info->fprintf_func) (info->stream, "%s", out_str); |
298 | 3.40M | } |
299 | | |
300 | | static void |
301 | | unpack_instr (instr_data_s *instr_data, int is_segmented, disassemble_info *info) |
302 | 3.40M | { |
303 | 3.40M | unsigned int nibl_count, loop; |
304 | 3.40M | unsigned short instr_nibl, instr_byte, instr_word; |
305 | 3.40M | long instr_long; |
306 | 3.40M | unsigned int tabl_datum, datum_class; |
307 | 3.40M | unsigned short datum_value; |
308 | | |
309 | 3.40M | nibl_count = 0; |
310 | 3.40M | loop = 0; |
311 | 3.40M | seg_length = 0; |
312 | | |
313 | 18.8M | while (z8k_table[instr_data->tabl_index].byte_info[loop] != 0) |
314 | 15.3M | { |
315 | 15.3M | FETCH_DATA (info, nibl_count + 4 - (nibl_count % 4)); |
316 | 15.3M | instr_nibl = instr_data->nibbles[nibl_count]; |
317 | 15.3M | instr_byte = instr_data->bytes[nibl_count & ~1]; |
318 | 15.3M | instr_word = instr_data->words[nibl_count & ~3]; |
319 | | |
320 | 15.3M | tabl_datum = z8k_table[instr_data->tabl_index].byte_info[loop]; |
321 | 15.3M | datum_class = tabl_datum & CLASS_MASK; |
322 | 15.3M | datum_value = tabl_datum & ~CLASS_MASK; |
323 | | |
324 | 15.3M | switch (datum_class) |
325 | 15.3M | { |
326 | 90.8k | case CLASS_DISP: |
327 | 90.8k | switch (datum_value) |
328 | 90.8k | { |
329 | 9.03k | case ARG_DISP16: |
330 | 9.03k | instr_data->displacement = instr_data->insn_start + 4 |
331 | 9.03k | + (signed short) (instr_word & 0xffff); |
332 | 9.03k | nibl_count += 3; |
333 | 9.03k | break; |
334 | 81.8k | case ARG_DISP12: |
335 | 81.8k | if (instr_word & 0x800) |
336 | | /* Negative 12 bit displacement. */ |
337 | 34.9k | instr_data->displacement = instr_data->insn_start + 2 |
338 | 34.9k | - (signed short) ((instr_word & 0xfff) | 0xf000) * 2; |
339 | 46.8k | else |
340 | 46.8k | instr_data->displacement = instr_data->insn_start + 2 |
341 | 46.8k | - (instr_word & 0x0fff) * 2; |
342 | | |
343 | 81.8k | nibl_count += 2; |
344 | 81.8k | break; |
345 | 0 | default: |
346 | 0 | break; |
347 | 90.8k | } |
348 | 90.8k | break; |
349 | 2.69M | case CLASS_IMM: |
350 | 2.69M | switch (datum_value) |
351 | 2.69M | { |
352 | 226k | case ARG_IMM4: |
353 | 226k | instr_data->immediate = instr_nibl; |
354 | 226k | break; |
355 | 106 | case ARG_NIM4: |
356 | 106 | instr_data->immediate = (- instr_nibl) & 0xf; |
357 | 106 | break; |
358 | 26 | case ARG_NIM8: |
359 | 26 | instr_data->immediate = (- instr_byte) & 0xff; |
360 | 26 | nibl_count += 1; |
361 | 26 | break; |
362 | 2.13M | case ARG_IMM8: |
363 | 2.13M | instr_data->immediate = instr_byte; |
364 | 2.13M | nibl_count += 1; |
365 | 2.13M | break; |
366 | 201k | case ARG_IMM16: |
367 | 201k | instr_data->immediate = instr_word; |
368 | 201k | nibl_count += 3; |
369 | 201k | break; |
370 | 28.2k | case ARG_IMM32: |
371 | 28.2k | FETCH_DATA (info, nibl_count + 8); |
372 | 28.2k | instr_long = ((unsigned) instr_data->words[nibl_count] << 16 |
373 | 28.2k | | instr_data->words[nibl_count + 4]); |
374 | 28.2k | instr_data->immediate = instr_long; |
375 | 28.2k | nibl_count += 7; |
376 | 28.2k | break; |
377 | 0 | case ARG_IMMN: |
378 | 0 | instr_data->immediate = instr_nibl - 1; |
379 | 0 | break; |
380 | 102k | case ARG_IMM4M1: |
381 | 102k | instr_data->immediate = instr_nibl + 1; |
382 | 102k | 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 | 2.69M | } |
395 | 2.69M | break; |
396 | 2.69M | case CLASS_CC: |
397 | 166k | instr_data->cond_code = instr_nibl; |
398 | 166k | break; |
399 | 477k | case CLASS_ADDRESS: |
400 | 477k | if (is_segmented) |
401 | 93.8k | { |
402 | 93.8k | if (instr_nibl & 0x8) |
403 | 11.1k | { |
404 | 11.1k | FETCH_DATA (info, nibl_count + 8); |
405 | 11.1k | instr_long = ((unsigned) instr_data->words[nibl_count] << 16 |
406 | 11.1k | | instr_data->words[nibl_count + 4]); |
407 | 11.1k | instr_data->address = ((instr_word & 0x7f00) << 16 |
408 | 11.1k | | (instr_long & 0xffff)); |
409 | 11.1k | nibl_count += 7; |
410 | 11.1k | seg_length = 2; |
411 | 11.1k | } |
412 | 82.7k | else |
413 | 82.7k | { |
414 | 82.7k | instr_data->address = ((instr_word & 0x7f00) << 16 |
415 | 82.7k | | (instr_word & 0x00ff)); |
416 | 82.7k | nibl_count += 3; |
417 | 82.7k | } |
418 | 93.8k | } |
419 | 384k | else |
420 | 384k | { |
421 | 384k | instr_data->address = instr_word; |
422 | 384k | nibl_count += 3; |
423 | 384k | } |
424 | 477k | break; |
425 | 2.26k | case CLASS_0CCC: |
426 | 7.24k | case CLASS_1CCC: |
427 | 7.24k | instr_data->ctrl_code = instr_nibl & 0x7; |
428 | 7.24k | break; |
429 | 95.0k | case CLASS_0DISP7: |
430 | 95.0k | instr_data->displacement = |
431 | 95.0k | instr_data->insn_start + 2 - (instr_byte & 0x7f) * 2; |
432 | 95.0k | nibl_count += 1; |
433 | 95.0k | break; |
434 | 286k | case CLASS_1DISP7: |
435 | 286k | instr_data->displacement = |
436 | 286k | instr_data->insn_start + 2 - (instr_byte & 0x7f) * 2; |
437 | 286k | nibl_count += 1; |
438 | 286k | break; |
439 | 154 | case CLASS_01II: |
440 | 154 | instr_data->interrupts = instr_nibl & 0x3; |
441 | 154 | break; |
442 | 1.39k | case CLASS_00II: |
443 | 1.39k | instr_data->interrupts = instr_nibl & 0x3; |
444 | 1.39k | break; |
445 | 220 | case CLASS_IGNORE: |
446 | 7.36M | case CLASS_BIT: |
447 | 7.36M | instr_data->ctrl_code = instr_nibl & 0x7; |
448 | 7.36M | break; |
449 | 1.77k | case CLASS_FLAGS: |
450 | 1.77k | instr_data->flags = instr_nibl; |
451 | 1.77k | break; |
452 | 2.94M | case CLASS_REG: |
453 | 2.94M | instr_data->arg_reg[datum_value] = instr_nibl; |
454 | 2.94M | break; |
455 | 1.11M | case CLASS_REGN0: |
456 | 1.11M | instr_data->arg_reg[datum_value] = instr_nibl; |
457 | 1.11M | break; |
458 | 145k | case CLASS_DISP8: |
459 | 145k | instr_data->displacement = |
460 | 145k | instr_data->insn_start + 2 + (signed char) instr_byte * 2; |
461 | 145k | nibl_count += 1; |
462 | 145k | break; |
463 | 3.46k | case CLASS_BIT_1OR2: |
464 | 3.46k | instr_data->immediate = ((instr_nibl >> 1) & 0x1) + 1; |
465 | 3.46k | nibl_count += 1; |
466 | 3.46k | break; |
467 | 0 | default: |
468 | 0 | abort (); |
469 | 0 | break; |
470 | 15.3M | } |
471 | | |
472 | 15.3M | loop += 1; |
473 | 15.3M | nibl_count += 1; |
474 | 15.3M | } |
475 | 3.40M | } |
476 | | |
477 | | static void |
478 | | print_intr(char *tmp_str, unsigned long interrupts) |
479 | 1.55k | { |
480 | 1.55k | int comma = 0; |
481 | | |
482 | 1.55k | *tmp_str = 0; |
483 | 1.55k | if (! (interrupts & 2)) |
484 | 1.15k | { |
485 | 1.15k | strcat (tmp_str, "vi"); |
486 | 1.15k | comma = 1; |
487 | 1.15k | } |
488 | 1.55k | if (! (interrupts & 1)) |
489 | 1.11k | { |
490 | 1.11k | if (comma) strcat (tmp_str, ","); |
491 | 1.11k | strcat (tmp_str, "nvi"); |
492 | 1.11k | } |
493 | 1.55k | } |
494 | | |
495 | | static void |
496 | | print_flags(char *tmp_str, unsigned long flags) |
497 | 1.77k | { |
498 | 1.77k | int comma = 0; |
499 | | |
500 | 1.77k | *tmp_str = 0; |
501 | 1.77k | if (flags & 8) |
502 | 540 | { |
503 | 540 | strcat (tmp_str, "c"); |
504 | 540 | comma = 1; |
505 | 540 | } |
506 | 1.77k | if (flags & 4) |
507 | 915 | { |
508 | 915 | if (comma) strcat (tmp_str, ","); |
509 | 915 | strcat (tmp_str, "z"); |
510 | 915 | comma = 1; |
511 | 915 | } |
512 | 1.77k | if (flags & 2) |
513 | 947 | { |
514 | 947 | if (comma) strcat (tmp_str, ","); |
515 | 947 | strcat (tmp_str, "s"); |
516 | 947 | comma = 1; |
517 | 947 | } |
518 | 1.77k | if (flags & 1) |
519 | 381 | { |
520 | 381 | if (comma) strcat (tmp_str, ","); |
521 | 381 | strcat (tmp_str, "p"); |
522 | 381 | } |
523 | 1.77k | } |
524 | | |
525 | | static void |
526 | | unparse_instr (instr_data_s *instr_data, int is_segmented) |
527 | 3.40M | { |
528 | 3.40M | unsigned short datum_value; |
529 | 3.40M | unsigned int tabl_datum, datum_class; |
530 | 3.40M | int loop, loop_limit; |
531 | 3.40M | char out_str[80], tmp_str[25]; |
532 | | |
533 | 3.40M | sprintf (out_str, "%s\t", z8k_table[instr_data->tabl_index].name); |
534 | | |
535 | 3.40M | loop_limit = z8k_table[instr_data->tabl_index].noperands; |
536 | 9.92M | for (loop = 0; loop < loop_limit; loop++) |
537 | 6.52M | { |
538 | 6.52M | if (loop) |
539 | 3.18M | strcat (out_str, ","); |
540 | | |
541 | 6.52M | tabl_datum = z8k_table[instr_data->tabl_index].arg_info[loop]; |
542 | 6.52M | datum_class = tabl_datum & CLASS_MASK; |
543 | 6.52M | datum_value = tabl_datum & ~CLASS_MASK; |
544 | | |
545 | 6.52M | switch (datum_class) |
546 | 6.52M | { |
547 | 407k | case CLASS_X: |
548 | 407k | sprintf (tmp_str, "0x%0lx(r%ld)", instr_data->address, |
549 | 407k | instr_data->arg_reg[datum_value]); |
550 | 407k | strcat (out_str, tmp_str); |
551 | 407k | break; |
552 | 70.7k | case CLASS_BA: |
553 | 70.7k | if (is_segmented) |
554 | 2.88k | sprintf (tmp_str, "rr%ld(#0x%lx)", instr_data->arg_reg[datum_value], |
555 | 2.88k | instr_data->immediate); |
556 | 67.8k | else |
557 | 67.8k | sprintf (tmp_str, "r%ld(#0x%lx)", instr_data->arg_reg[datum_value], |
558 | 67.8k | instr_data->immediate); |
559 | 70.7k | strcat (out_str, tmp_str); |
560 | 70.7k | break; |
561 | 3.80k | case CLASS_BX: |
562 | 3.80k | if (is_segmented) |
563 | 348 | sprintf (tmp_str, "rr%ld(r%ld)", instr_data->arg_reg[datum_value], |
564 | 348 | instr_data->arg_reg[ARG_RX]); |
565 | 3.45k | else |
566 | 3.45k | sprintf (tmp_str, "r%ld(r%ld)", instr_data->arg_reg[datum_value], |
567 | 3.45k | instr_data->arg_reg[ARG_RX]); |
568 | 3.80k | strcat (out_str, tmp_str); |
569 | 3.80k | break; |
570 | 617k | case CLASS_DISP: |
571 | 617k | sprintf (tmp_str, "0x%0lx", instr_data->displacement); |
572 | 617k | strcat (out_str, tmp_str); |
573 | 617k | break; |
574 | 1.59M | case CLASS_IMM: |
575 | 1.59M | if (datum_value == ARG_IMM2) /* True with EI/DI instructions only. */ |
576 | 1.55k | { |
577 | 1.55k | print_intr (tmp_str, instr_data->interrupts); |
578 | 1.55k | strcat (out_str, tmp_str); |
579 | 1.55k | break; |
580 | 1.55k | } |
581 | 1.59M | sprintf (tmp_str, "#0x%0lx", instr_data->immediate); |
582 | 1.59M | strcat (out_str, tmp_str); |
583 | 1.59M | break; |
584 | 166k | case CLASS_CC: |
585 | 166k | sprintf (tmp_str, "%s", codes[instr_data->cond_code]); |
586 | 166k | strcat (out_str, tmp_str); |
587 | 166k | break; |
588 | 8.01k | case CLASS_CTRL: |
589 | 8.01k | sprintf (tmp_str, "%s", ctrl_names[instr_data->ctrl_code]); |
590 | 8.01k | strcat (out_str, tmp_str); |
591 | 8.01k | break; |
592 | 70.2k | case CLASS_DA: |
593 | 70.2k | case CLASS_ADDRESS: |
594 | 70.2k | sprintf (tmp_str, "0x%0lx", instr_data->address); |
595 | 70.2k | strcat (out_str, tmp_str); |
596 | 70.2k | break; |
597 | 633k | case CLASS_IR: |
598 | 633k | if (is_segmented) |
599 | 74.4k | sprintf (tmp_str, "@rr%ld", instr_data->arg_reg[datum_value]); |
600 | 559k | else |
601 | 559k | sprintf (tmp_str, "@r%ld", instr_data->arg_reg[datum_value]); |
602 | 633k | strcat (out_str, tmp_str); |
603 | 633k | break; |
604 | 32.5k | case CLASS_IRO: |
605 | 32.5k | sprintf (tmp_str, "@r%ld", instr_data->arg_reg[datum_value]); |
606 | 32.5k | strcat (out_str, tmp_str); |
607 | 32.5k | break; |
608 | 1.77k | case CLASS_FLAGS: |
609 | 1.77k | print_flags(tmp_str, instr_data->flags); |
610 | 1.77k | strcat (out_str, tmp_str); |
611 | 1.77k | break; |
612 | 1.86M | case CLASS_REG_BYTE: |
613 | 1.86M | if (instr_data->arg_reg[datum_value] >= 0x8) |
614 | 457k | sprintf (tmp_str, "rl%ld", |
615 | 457k | instr_data->arg_reg[datum_value] - 0x8); |
616 | 1.40M | else |
617 | 1.40M | sprintf (tmp_str, "rh%ld", instr_data->arg_reg[datum_value]); |
618 | 1.86M | strcat (out_str, tmp_str); |
619 | 1.86M | break; |
620 | 812k | case CLASS_REG_WORD: |
621 | 812k | sprintf (tmp_str, "r%ld", instr_data->arg_reg[datum_value]); |
622 | 812k | strcat (out_str, tmp_str); |
623 | 812k | break; |
624 | 41.6k | case CLASS_REG_QUAD: |
625 | 41.6k | sprintf (tmp_str, "rq%ld", instr_data->arg_reg[datum_value]); |
626 | 41.6k | strcat (out_str, tmp_str); |
627 | 41.6k | break; |
628 | 180k | case CLASS_REG_LONG: |
629 | 180k | sprintf (tmp_str, "rr%ld", instr_data->arg_reg[datum_value]); |
630 | 180k | strcat (out_str, tmp_str); |
631 | 180k | break; |
632 | 17.3k | case CLASS_PR: |
633 | 17.3k | if (is_segmented) |
634 | 984 | sprintf (tmp_str, "rr%ld", instr_data->arg_reg[datum_value]); |
635 | 16.3k | else |
636 | 16.3k | sprintf (tmp_str, "r%ld", instr_data->arg_reg[datum_value]); |
637 | 17.3k | strcat (out_str, tmp_str); |
638 | 17.3k | break; |
639 | 0 | default: |
640 | 0 | abort (); |
641 | 0 | break; |
642 | 6.52M | } |
643 | 6.52M | } |
644 | | |
645 | 3.40M | strcpy (instr_data->instr_asmsrc, out_str); |
646 | 3.40M | } |