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