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