]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - opcodes/disassemble.c
8aac42ec96cf56f3903c01e613fbf8303cc9985f
[thirdparty/binutils-gdb.git] / opcodes / disassemble.c
1 /* Select disassembly routine for specified architecture.
2 Copyright (C) 1994-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 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
20
21 #include "sysdep.h"
22 #include "disassemble.h"
23 #include "safe-ctype.h"
24 #include "opintl.h"
25
26 #ifdef ARCH_all
27 #ifdef BFD64
28 #define ARCH_aarch64
29 #define ARCH_alpha
30 #define ARCH_bpf
31 #define ARCH_ia64
32 #define ARCH_loongarch
33 #define ARCH_mips
34 #define ARCH_mmix
35 #define ARCH_nfp
36 #define ARCH_riscv
37 #define ARCH_score
38 #define ARCH_tilegx
39 #endif
40 #define ARCH_arc
41 #define ARCH_arm
42 #define ARCH_avr
43 #define ARCH_bfin
44 #define ARCH_cr16
45 #define ARCH_cris
46 #define ARCH_crx
47 #define ARCH_csky
48 #define ARCH_d10v
49 #define ARCH_d30v
50 #define ARCH_dlx
51 #define ARCH_epiphany
52 #define ARCH_fr30
53 #define ARCH_frv
54 #define ARCH_ft32
55 #define ARCH_h8300
56 #define ARCH_hppa
57 #define ARCH_i386
58 #define ARCH_ip2k
59 #define ARCH_iq2000
60 #define ARCH_lm32
61 #define ARCH_m32c
62 #define ARCH_m32r
63 #define ARCH_m68hc11
64 #define ARCH_m68hc12
65 #define ARCH_m68k
66 #define ARCH_mcore
67 #define ARCH_mep
68 #define ARCH_metag
69 #define ARCH_microblaze
70 #define ARCH_mn10200
71 #define ARCH_mn10300
72 #define ARCH_moxie
73 #define ARCH_mt
74 #define ARCH_msp430
75 #define ARCH_nds32
76 #define ARCH_nios2
77 #define ARCH_ns32k
78 #define ARCH_or1k
79 #define ARCH_pdp11
80 #define ARCH_pj
81 #define ARCH_powerpc
82 #define ARCH_pru
83 #define ARCH_rs6000
84 #define ARCH_rl78
85 #define ARCH_rx
86 #define ARCH_s12z
87 #define ARCH_s390
88 #define ARCH_sh
89 #define ARCH_sparc
90 #define ARCH_spu
91 #define ARCH_tic30
92 #define ARCH_tic4x
93 #define ARCH_tic54x
94 #define ARCH_tic6x
95 #define ARCH_tilepro
96 #define ARCH_v850
97 #define ARCH_vax
98 #define ARCH_visium
99 #define ARCH_wasm32
100 #define ARCH_xstormy16
101 #define ARCH_xgate
102 #define ARCH_xtensa
103 #define ARCH_z80
104 #define ARCH_z8k
105 #endif
106
107 #ifdef ARCH_m32c
108 #include "m32c-desc.h"
109 #endif
110
111 disassembler_ftype
112 disassembler (enum bfd_architecture a,
113 bool big ATTRIBUTE_UNUSED,
114 unsigned long mach ATTRIBUTE_UNUSED,
115 bfd *abfd ATTRIBUTE_UNUSED)
116 {
117 disassembler_ftype disassemble;
118
119 switch (a)
120 {
121 /* If you add a case to this table, also add it to the
122 ARCH_all definition right above this function. */
123 #ifdef ARCH_aarch64
124 case bfd_arch_aarch64:
125 disassemble = print_insn_aarch64;
126 break;
127 #endif
128 #ifdef ARCH_alpha
129 case bfd_arch_alpha:
130 disassemble = print_insn_alpha;
131 break;
132 #endif
133 #ifdef ARCH_arc
134 case bfd_arch_arc:
135 disassemble = arc_get_disassembler (abfd);
136 break;
137 #endif
138 #ifdef ARCH_arm
139 case bfd_arch_arm:
140 if (big)
141 disassemble = print_insn_big_arm;
142 else
143 disassemble = print_insn_little_arm;
144 break;
145 #endif
146 #ifdef ARCH_avr
147 case bfd_arch_avr:
148 disassemble = print_insn_avr;
149 break;
150 #endif
151 #ifdef ARCH_bfin
152 case bfd_arch_bfin:
153 disassemble = print_insn_bfin;
154 break;
155 #endif
156 #ifdef ARCH_cr16
157 case bfd_arch_cr16:
158 disassemble = print_insn_cr16;
159 break;
160 #endif
161 #ifdef ARCH_cris
162 case bfd_arch_cris:
163 disassemble = cris_get_disassembler (abfd);
164 break;
165 #endif
166 #ifdef ARCH_crx
167 case bfd_arch_crx:
168 disassemble = print_insn_crx;
169 break;
170 #endif
171 #ifdef ARCH_csky
172 case bfd_arch_csky:
173 disassemble = csky_get_disassembler (abfd);
174 break;
175 #endif
176
177 #ifdef ARCH_d10v
178 case bfd_arch_d10v:
179 disassemble = print_insn_d10v;
180 break;
181 #endif
182 #ifdef ARCH_d30v
183 case bfd_arch_d30v:
184 disassemble = print_insn_d30v;
185 break;
186 #endif
187 #ifdef ARCH_dlx
188 case bfd_arch_dlx:
189 /* As far as I know we only handle big-endian DLX objects. */
190 disassemble = print_insn_dlx;
191 break;
192 #endif
193 #ifdef ARCH_h8300
194 case bfd_arch_h8300:
195 if (mach == bfd_mach_h8300h || mach == bfd_mach_h8300hn)
196 disassemble = print_insn_h8300h;
197 else if (mach == bfd_mach_h8300s
198 || mach == bfd_mach_h8300sn
199 || mach == bfd_mach_h8300sx
200 || mach == bfd_mach_h8300sxn)
201 disassemble = print_insn_h8300s;
202 else
203 disassemble = print_insn_h8300;
204 break;
205 #endif
206 #ifdef ARCH_hppa
207 case bfd_arch_hppa:
208 disassemble = print_insn_hppa;
209 break;
210 #endif
211 #ifdef ARCH_i386
212 case bfd_arch_i386:
213 case bfd_arch_iamcu:
214 disassemble = print_insn_i386;
215 break;
216 #endif
217 #ifdef ARCH_ia64
218 case bfd_arch_ia64:
219 disassemble = print_insn_ia64;
220 break;
221 #endif
222 #ifdef ARCH_ip2k
223 case bfd_arch_ip2k:
224 disassemble = print_insn_ip2k;
225 break;
226 #endif
227 #ifdef ARCH_bpf
228 case bfd_arch_bpf:
229 disassemble = print_insn_bpf;
230 break;
231 #endif
232 #ifdef ARCH_epiphany
233 case bfd_arch_epiphany:
234 disassemble = print_insn_epiphany;
235 break;
236 #endif
237 #ifdef ARCH_fr30
238 case bfd_arch_fr30:
239 disassemble = print_insn_fr30;
240 break;
241 #endif
242 #ifdef ARCH_lm32
243 case bfd_arch_lm32:
244 disassemble = print_insn_lm32;
245 break;
246 #endif
247 #ifdef ARCH_m32r
248 case bfd_arch_m32r:
249 disassemble = print_insn_m32r;
250 break;
251 #endif
252 #if defined(ARCH_m68hc11) || defined(ARCH_m68hc12) \
253 || defined(ARCH_9s12x) || defined(ARCH_m9s12xg)
254 case bfd_arch_m68hc11:
255 disassemble = print_insn_m68hc11;
256 break;
257 case bfd_arch_m68hc12:
258 disassemble = print_insn_m68hc12;
259 break;
260 case bfd_arch_m9s12x:
261 disassemble = print_insn_m9s12x;
262 break;
263 case bfd_arch_m9s12xg:
264 disassemble = print_insn_m9s12xg;
265 break;
266 #endif
267 #if defined(ARCH_s12z)
268 case bfd_arch_s12z:
269 disassemble = print_insn_s12z;
270 break;
271 #endif
272 #ifdef ARCH_m68k
273 case bfd_arch_m68k:
274 disassemble = print_insn_m68k;
275 break;
276 #endif
277 #ifdef ARCH_mt
278 case bfd_arch_mt:
279 disassemble = print_insn_mt;
280 break;
281 #endif
282 #ifdef ARCH_microblaze
283 case bfd_arch_microblaze:
284 disassemble = print_insn_microblaze;
285 break;
286 #endif
287 #ifdef ARCH_msp430
288 case bfd_arch_msp430:
289 disassemble = print_insn_msp430;
290 break;
291 #endif
292 #ifdef ARCH_nds32
293 case bfd_arch_nds32:
294 disassemble = print_insn_nds32;
295 break;
296 #endif
297 #ifdef ARCH_nfp
298 case bfd_arch_nfp:
299 disassemble = print_insn_nfp;
300 break;
301 #endif
302 #ifdef ARCH_ns32k
303 case bfd_arch_ns32k:
304 disassemble = print_insn_ns32k;
305 break;
306 #endif
307 #ifdef ARCH_mcore
308 case bfd_arch_mcore:
309 disassemble = print_insn_mcore;
310 break;
311 #endif
312 #ifdef ARCH_mep
313 case bfd_arch_mep:
314 disassemble = print_insn_mep;
315 break;
316 #endif
317 #ifdef ARCH_metag
318 case bfd_arch_metag:
319 disassemble = print_insn_metag;
320 break;
321 #endif
322 #ifdef ARCH_mips
323 case bfd_arch_mips:
324 if (big)
325 disassemble = print_insn_big_mips;
326 else
327 disassemble = print_insn_little_mips;
328 break;
329 #endif
330 #ifdef ARCH_mmix
331 case bfd_arch_mmix:
332 disassemble = print_insn_mmix;
333 break;
334 #endif
335 #ifdef ARCH_mn10200
336 case bfd_arch_mn10200:
337 disassemble = print_insn_mn10200;
338 break;
339 #endif
340 #ifdef ARCH_mn10300
341 case bfd_arch_mn10300:
342 disassemble = print_insn_mn10300;
343 break;
344 #endif
345 #ifdef ARCH_nios2
346 case bfd_arch_nios2:
347 if (big)
348 disassemble = print_insn_big_nios2;
349 else
350 disassemble = print_insn_little_nios2;
351 break;
352 #endif
353 #ifdef ARCH_or1k
354 case bfd_arch_or1k:
355 disassemble = print_insn_or1k;
356 break;
357 #endif
358 #ifdef ARCH_pdp11
359 case bfd_arch_pdp11:
360 disassemble = print_insn_pdp11;
361 break;
362 #endif
363 #ifdef ARCH_pj
364 case bfd_arch_pj:
365 disassemble = print_insn_pj;
366 break;
367 #endif
368 #ifdef ARCH_powerpc
369 case bfd_arch_powerpc:
370 #endif
371 #ifdef ARCH_rs6000
372 case bfd_arch_rs6000:
373 #endif
374 #if defined ARCH_powerpc || defined ARCH_rs6000
375 if (big)
376 disassemble = print_insn_big_powerpc;
377 else
378 disassemble = print_insn_little_powerpc;
379 break;
380 #endif
381 #ifdef ARCH_pru
382 case bfd_arch_pru:
383 disassemble = print_insn_pru;
384 break;
385 #endif
386 #ifdef ARCH_riscv
387 case bfd_arch_riscv:
388 disassemble = riscv_get_disassembler (abfd);
389 break;
390 #endif
391 #ifdef ARCH_rl78
392 case bfd_arch_rl78:
393 disassemble = rl78_get_disassembler (abfd);
394 break;
395 #endif
396 #ifdef ARCH_rx
397 case bfd_arch_rx:
398 disassemble = print_insn_rx;
399 break;
400 #endif
401 #ifdef ARCH_s390
402 case bfd_arch_s390:
403 disassemble = print_insn_s390;
404 break;
405 #endif
406 #ifdef ARCH_score
407 case bfd_arch_score:
408 if (big)
409 disassemble = print_insn_big_score;
410 else
411 disassemble = print_insn_little_score;
412 break;
413 #endif
414 #ifdef ARCH_sh
415 case bfd_arch_sh:
416 disassemble = print_insn_sh;
417 break;
418 #endif
419 #ifdef ARCH_sparc
420 case bfd_arch_sparc:
421 disassemble = print_insn_sparc;
422 break;
423 #endif
424 #ifdef ARCH_spu
425 case bfd_arch_spu:
426 disassemble = print_insn_spu;
427 break;
428 #endif
429 #ifdef ARCH_tic30
430 case bfd_arch_tic30:
431 disassemble = print_insn_tic30;
432 break;
433 #endif
434 #ifdef ARCH_tic4x
435 case bfd_arch_tic4x:
436 disassemble = print_insn_tic4x;
437 break;
438 #endif
439 #ifdef ARCH_tic54x
440 case bfd_arch_tic54x:
441 disassemble = print_insn_tic54x;
442 break;
443 #endif
444 #ifdef ARCH_tic6x
445 case bfd_arch_tic6x:
446 disassemble = print_insn_tic6x;
447 break;
448 #endif
449 #ifdef ARCH_ft32
450 case bfd_arch_ft32:
451 disassemble = print_insn_ft32;
452 break;
453 #endif
454 #ifdef ARCH_v850
455 case bfd_arch_v850:
456 case bfd_arch_v850_rh850:
457 disassemble = print_insn_v850;
458 break;
459 #endif
460 #ifdef ARCH_wasm32
461 case bfd_arch_wasm32:
462 disassemble = print_insn_wasm32;
463 break;
464 #endif
465 #ifdef ARCH_xgate
466 case bfd_arch_xgate:
467 disassemble = print_insn_xgate;
468 break;
469 #endif
470 #ifdef ARCH_xstormy16
471 case bfd_arch_xstormy16:
472 disassemble = print_insn_xstormy16;
473 break;
474 #endif
475 #ifdef ARCH_xtensa
476 case bfd_arch_xtensa:
477 disassemble = print_insn_xtensa;
478 break;
479 #endif
480 #ifdef ARCH_z80
481 case bfd_arch_z80:
482 disassemble = print_insn_z80;
483 break;
484 #endif
485 #ifdef ARCH_z8k
486 case bfd_arch_z8k:
487 if (mach == bfd_mach_z8001)
488 disassemble = print_insn_z8001;
489 else
490 disassemble = print_insn_z8002;
491 break;
492 #endif
493 #ifdef ARCH_vax
494 case bfd_arch_vax:
495 disassemble = print_insn_vax;
496 break;
497 #endif
498 #ifdef ARCH_visium
499 case bfd_arch_visium:
500 disassemble = print_insn_visium;
501 break;
502 #endif
503 #ifdef ARCH_frv
504 case bfd_arch_frv:
505 disassemble = print_insn_frv;
506 break;
507 #endif
508 #ifdef ARCH_moxie
509 case bfd_arch_moxie:
510 disassemble = print_insn_moxie;
511 break;
512 #endif
513 #ifdef ARCH_iq2000
514 case bfd_arch_iq2000:
515 disassemble = print_insn_iq2000;
516 break;
517 #endif
518 #ifdef ARCH_m32c
519 case bfd_arch_m32c:
520 disassemble = print_insn_m32c;
521 break;
522 #endif
523 #ifdef ARCH_tilegx
524 case bfd_arch_tilegx:
525 disassemble = print_insn_tilegx;
526 break;
527 #endif
528 #ifdef ARCH_tilepro
529 case bfd_arch_tilepro:
530 disassemble = print_insn_tilepro;
531 break;
532 #endif
533 #ifdef ARCH_loongarch
534 case bfd_arch_loongarch:
535 disassemble = print_insn_loongarch;
536 break;
537 #endif
538 default:
539 return 0;
540 }
541 return disassemble;
542 }
543
544 void
545 disassembler_usage (FILE *stream ATTRIBUTE_UNUSED)
546 {
547 #ifdef ARCH_aarch64
548 print_aarch64_disassembler_options (stream);
549 #endif
550 #ifdef ARCH_arc
551 print_arc_disassembler_options (stream);
552 #endif
553 #ifdef ARCH_arm
554 print_arm_disassembler_options (stream);
555 #endif
556 #ifdef ARCH_mips
557 print_mips_disassembler_options (stream);
558 #endif
559 #ifdef ARCH_nfp
560 print_nfp_disassembler_options (stream);
561 #endif
562 #ifdef ARCH_powerpc
563 print_ppc_disassembler_options (stream);
564 #endif
565 #ifdef ARCH_riscv
566 print_riscv_disassembler_options (stream);
567 #endif
568 #ifdef ARCH_i386
569 print_i386_disassembler_options (stream);
570 #endif
571 #ifdef ARCH_s390
572 print_s390_disassembler_options (stream);
573 #endif
574 #ifdef ARCH_wasm32
575 print_wasm32_disassembler_options (stream);
576 #endif
577 #ifdef ARCH_loongarch
578 print_loongarch_disassembler_options (stream);
579 #endif
580 #ifdef ARCH_bpf
581 print_bpf_disassembler_options (stream);
582 #endif
583 return;
584 }
585
586 void
587 disassemble_init_for_target (struct disassemble_info * info)
588 {
589 if (info == NULL)
590 return;
591
592 switch (info->arch)
593 {
594 #ifdef ARCH_aarch64
595 case bfd_arch_aarch64:
596 info->symbol_is_valid = aarch64_symbol_is_valid;
597 info->disassembler_needs_relocs = true;
598 info->created_styled_output = true;
599 break;
600 #endif
601 #ifdef ARCH_arc
602 case bfd_arch_arc:
603 info->created_styled_output = true;
604 break;
605 #endif
606 #ifdef ARCH_arm
607 case bfd_arch_arm:
608 info->symbol_is_valid = arm_symbol_is_valid;
609 info->disassembler_needs_relocs = true;
610 info->created_styled_output = true;
611 break;
612 #endif
613 #ifdef ARCH_avr
614 case bfd_arch_avr:
615 info->created_styled_output = true;
616 break;
617 #endif
618 #ifdef ARCH_csky
619 case bfd_arch_csky:
620 info->symbol_is_valid = csky_symbol_is_valid;
621 info->disassembler_needs_relocs = true;
622 break;
623 #endif
624 #ifdef ARCH_i386
625 case bfd_arch_i386:
626 case bfd_arch_iamcu:
627 info->created_styled_output = true;
628 break;
629 #endif
630 #ifdef ARCH_ia64
631 case bfd_arch_ia64:
632 info->skip_zeroes = 16;
633 break;
634 #endif
635 #ifdef ARCH_loongarch
636 case bfd_arch_loongarch:
637 info->created_styled_output = true;
638 break;
639 #endif
640 #ifdef ARCH_tic4x
641 case bfd_arch_tic4x:
642 info->skip_zeroes = 32;
643 break;
644 #endif
645 #ifdef ARCH_m68k
646 case bfd_arch_m68k:
647 info->created_styled_output = true;
648 break;
649 #endif
650 #ifdef ARCH_mep
651 case bfd_arch_mep:
652 info->skip_zeroes = 256;
653 info->skip_zeroes_at_end = 0;
654 break;
655 #endif
656 #ifdef ARCH_metag
657 case bfd_arch_metag:
658 info->disassembler_needs_relocs = true;
659 break;
660 #endif
661 #ifdef ARCH_mips
662 case bfd_arch_mips:
663 info->created_styled_output = true;
664 break;
665 #endif
666 #ifdef ARCH_m32c
667 case bfd_arch_m32c:
668 /* This processor in fact is little endian. The value set here
669 reflects the way opcodes are written in the cgen description. */
670 info->endian = BFD_ENDIAN_BIG;
671 if (!info->private_data)
672 {
673 info->private_data = cgen_bitset_create (ISA_MAX);
674 if (info->mach == bfd_mach_m16c)
675 cgen_bitset_set (info->private_data, ISA_M16C);
676 else
677 cgen_bitset_set (info->private_data, ISA_M32C);
678 }
679 break;
680 #endif
681 #ifdef ARCH_bpf
682 case bfd_arch_bpf:
683 info->created_styled_output = true;
684 break;
685 #endif
686 #ifdef ARCH_pru
687 case bfd_arch_pru:
688 info->disassembler_needs_relocs = true;
689 break;
690 #endif
691 #ifdef ARCH_powerpc
692 case bfd_arch_powerpc:
693 #endif
694 #ifdef ARCH_rs6000
695 case bfd_arch_rs6000:
696 #endif
697 #if defined (ARCH_powerpc) || defined (ARCH_rs6000)
698 disassemble_init_powerpc (info);
699 info->created_styled_output = true;
700 break;
701 #endif
702 #ifdef ARCH_riscv
703 case bfd_arch_riscv:
704 info->symbol_is_valid = riscv_symbol_is_valid;
705 info->created_styled_output = true;
706 break;
707 #endif
708 #ifdef ARCH_wasm32
709 case bfd_arch_wasm32:
710 disassemble_init_wasm32 (info);
711 break;
712 #endif
713 #ifdef ARCH_s390
714 case bfd_arch_s390:
715 disassemble_init_s390 (info);
716 info->created_styled_output = true;
717 break;
718 #endif
719 #ifdef ARCH_nds32
720 case bfd_arch_nds32:
721 disassemble_init_nds32 (info);
722 break;
723 #endif
724 default:
725 break;
726 }
727 }
728
729 void
730 disassemble_free_target (struct disassemble_info *info)
731 {
732 if (info == NULL)
733 return;
734
735 switch (info->arch)
736 {
737 default:
738 return;
739
740 #ifdef ARCH_m32c
741 case bfd_arch_m32c:
742 #endif
743 #if defined ARCH_m32c
744 if (info->private_data)
745 {
746 CGEN_BITSET *mask = info->private_data;
747 free (mask->bits);
748 }
749 break;
750 #endif
751
752 #ifdef ARCH_arc
753 case bfd_arch_arc:
754 break;
755 #endif
756 #ifdef ARCH_cris
757 case bfd_arch_cris:
758 break;
759 #endif
760 #ifdef ARCH_mmix
761 case bfd_arch_mmix:
762 break;
763 #endif
764 #ifdef ARCH_nfp
765 case bfd_arch_nfp:
766 break;
767 #endif
768 #ifdef ARCH_powerpc
769 case bfd_arch_powerpc:
770 break;
771 #endif
772 #ifdef ARCH_riscv
773 case bfd_arch_riscv:
774 disassemble_free_riscv (info);
775 break;
776 #endif
777 #ifdef ARCH_rs6000
778 case bfd_arch_rs6000:
779 break;
780 #endif
781 }
782
783 free (info->private_data);
784 }
785
786 /* Remove whitespace and consecutive commas from OPTIONS. */
787
788 char *
789 remove_whitespace_and_extra_commas (char *options)
790 {
791 char *str;
792 size_t i, len;
793
794 if (options == NULL)
795 return NULL;
796
797 /* Strip off all trailing whitespace and commas. */
798 for (len = strlen (options); len > 0; len--)
799 {
800 if (!ISSPACE (options[len - 1]) && options[len - 1] != ',')
801 break;
802 options[len - 1] = '\0';
803 }
804
805 /* Convert all remaining whitespace to commas. */
806 for (i = 0; options[i] != '\0'; i++)
807 if (ISSPACE (options[i]))
808 options[i] = ',';
809
810 /* Remove consecutive commas. */
811 for (str = options; *str != '\0'; str++)
812 if (*str == ',' && (*(str + 1) == ',' || str == options))
813 {
814 char *next = str + 1;
815 while (*next == ',')
816 next++;
817 len = strlen (next);
818 if (str != options)
819 str++;
820 memmove (str, next, len);
821 next[len - (size_t)(next - str)] = '\0';
822 }
823 return (strlen (options) != 0) ? options : NULL;
824 }
825
826 /* Like STRCMP, but treat ',' the same as '\0' so that we match
827 strings like "foobar" against "foobar,xxyyzz,...". */
828
829 int
830 disassembler_options_cmp (const char *s1, const char *s2)
831 {
832 unsigned char c1, c2;
833
834 do
835 {
836 c1 = (unsigned char) *s1++;
837 if (c1 == ',')
838 c1 = '\0';
839 c2 = (unsigned char) *s2++;
840 if (c2 == ',')
841 c2 = '\0';
842 if (c1 == '\0')
843 return c1 - c2;
844 }
845 while (c1 == c2);
846
847 return c1 - c2;
848 }
849
850 void
851 opcodes_assert (const char *file, int line)
852 {
853 opcodes_error_handler (_("assertion fail %s:%d"), file, line);
854 opcodes_error_handler (_("Please report this bug"));
855 abort ();
856 }
857
858 /* Set the stream, and the styled and unstyled printf functions within
859 INFO. */
860
861 void
862 disassemble_set_printf (struct disassemble_info *info, void *stream,
863 fprintf_ftype unstyled_printf,
864 fprintf_styled_ftype styled_printf)
865 {
866 info->stream = stream;
867 info->fprintf_func = unstyled_printf;
868 info->fprintf_styled_func = styled_printf;
869 }