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