From patchwork Sat Feb 18 19:02:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schwab X-Patchwork-Id: 58951 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp505236wrn; Sat, 18 Feb 2023 11:03:05 -0800 (PST) X-Google-Smtp-Source: AK7set/kGqG8YjPqdn0xA5ph+x33yg2Vo4xG2EdqWD62uaoNVyB5WSc4wMBnlDB5iKPIpJmMhGB4 X-Received: by 2002:a17:906:b05a:b0:8b1:300f:1bdc with SMTP id bj26-20020a170906b05a00b008b1300f1bdcmr4580669ejb.64.1676746985193; Sat, 18 Feb 2023 11:03:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676746985; cv=none; d=google.com; s=arc-20160816; b=DvVR8O3SgmxU3kZE/ecXlRwOe66768VdE0J3VeGCD2ZYDP2Hh5hvyr6CjAifOUw9ac mGI7aDF+i1isXKWc/q9dNA356rKAAqLEvujZO3rYxRKplaIWBXnmhWYWhqnKp8uMteR5 Xad9CBxwOtWKaeVnmT/Np0CUEcUd6AhOHv2GAr+cOeeVoqUDmcwqk/am/gp2kGKQgkyH +q8twt9lusXko9bt0mEfJ6HpWrRjIeo67rlec/+cMmKFc0ajeIDvghz+edntQcgS/RTi gLu87dDjQXmfF4kYpib/8QAzItyA/9ezbHxySKlXktzmLi/EgYYL8lxdPoUtbE9Vd9QC ssdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:user-agent :message-id:date:subject:to:from:dmarc-filter:delivered-to; bh=dDlJQ8u2kDOsBQCUx38ke5Lpt0kNWHUW7HLfOTdxYG8=; b=dOGaRRxURDK1y0bRBQ7Jc7yuuJE+YV6553raqCz2XQ20rjlSI0+ZZVOhzRHrl+DQAe 7VB6DL2qeqpOL1h/a29oaOiEj4rmB3erIxdQDhygoNqpUpOe9utNJez+eexE1083jtPL twRwfTOg0ebm6NG+rGw3d2fWa1II18O8cS15/pGWG0z/cCDwrRk5pag4l3MI2kyuGCt9 L+VanuAug8lMY50zwQ/JLY7/X82GLhFQuiZEhOxVqy1cZRlEB/oKGgl9Uuc5Rh+JpNmm LfmQY8weJcvBwwtNdzAwR+uzJjV+uNwKNGo3FXwzGUMLN0/OA+T8ePLuoj/zx+YM3hYD +keQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id up16-20020a170907cc9000b008b1357271c0si8986726ejc.863.2023.02.18.11.03.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Feb 2023 11:03:05 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F25223854811 for ; Sat, 18 Feb 2023 19:03:02 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by sourceware.org (Postfix) with ESMTPS id AF1223858D32 for ; Sat, 18 Feb 2023 19:02:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AF1223858D32 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nefkom.net Received: from frontend03.mail.m-online.net (unknown [192.168.6.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4PJyk44GLLz1r1gY for ; Sat, 18 Feb 2023 20:02:52 +0100 (CET) Received: from localhost (dynscan3.mnet-online.de [192.168.6.84]) by mail.m-online.net (Postfix) with ESMTP id 4PJyk41D7Nz1qqlR for ; Sat, 18 Feb 2023 20:02:52 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan3.mail.m-online.net [192.168.6.84]) (amavisd-new, port 10024) with ESMTP id XRW3W_TF0vQ4 for ; Sat, 18 Feb 2023 20:02:50 +0100 (CET) X-Auth-Info: cVIxES7u380iOV0nvyCxwSm+NmPFNRiGcJSeC/Fj1iu3dD5YAA2oxknuWWf1x5Hl Received: from igel.home (aftr-82-135-86-224.dynamic.mnet-online.de [82.135.86.224]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA for ; Sat, 18 Feb 2023 20:02:50 +0100 (CET) Received: by igel.home (Postfix, from userid 1000) id DEED72C1403; Sat, 18 Feb 2023 20:02:49 +0100 (CET) From: Andreas Schwab To: binutils@sourceware.org Subject: [PATCH] opcodes: style m68k disassembler output X-Yow: It's the RINSE CYCLE!! They've ALL IGNORED the RINSE CYCLE!! Date: Sat, 18 Feb 2023 20:02:49 +0100 Message-ID: <877cwere3q.fsf@igel.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758196646735455250?= X-GMAIL-MSGID: =?utf-8?q?1758196646735455250?= --- opcodes/m68k-dis.c | 354 ++++++++++++++++++++++++++++++--------------- 1 file changed, 238 insertions(+), 116 deletions(-) diff --git a/opcodes/m68k-dis.c b/opcodes/m68k-dis.c index a416fbe7cfa..fb384640763 100644 --- a/opcodes/m68k-dis.c +++ b/opcodes/m68k-dis.c @@ -213,7 +213,8 @@ fetch_data (struct disassemble_info *info, bfd_byte *addr) /* This function is used to print to the bit-bucket. */ static int -dummy_printer (FILE *file ATTRIBUTE_UNUSED, +dummy_printer (void *file ATTRIBUTE_UNUSED, + enum disassembler_style style ATTRIBUTE_UNUSED, const char *format ATTRIBUTE_UNUSED, ...) { @@ -510,18 +511,39 @@ print_base (int regno, bfd_vma disp, disassemble_info *info) { if (regno == -1) { - (*info->fprintf_func) (info->stream, "%%pc@("); + (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%pc"); + (*info->fprintf_styled_func) (info->stream, dis_style_text, "@("); (*info->print_address_func) (disp, info); } else { - if (regno == -2) - (*info->fprintf_func) (info->stream, "@("); - else if (regno == -3) - (*info->fprintf_func) (info->stream, "%%zpc@("); - else - (*info->fprintf_func) (info->stream, "%s@(", reg_names[regno]); - (*info->fprintf_func) (info->stream, "%" PRIx64, (uint64_t) disp); + if (regno == -3) + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%%zpc"); + else if (regno != -2) + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%s", reg_names[regno]); + (*info->fprintf_styled_func) (info->stream, dis_style_text, "@("); + (*info->fprintf_styled_func) (info->stream, dis_style_immediate, + "%" PRIx64, (uint64_t) disp); + } +} + +/* Print the index register of an indexed argument, as encoded in the + extension word. */ + +static void +print_index_register (int ext, disassemble_info *info) +{ + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%s", reg_names[(ext >> 12) & 0xf]); + (*info->fprintf_styled_func) (info->stream, dis_style_text, + ":%c", ext & 0x800 ? 'l' : 'w'); + if ((ext >> 9) & 3) + { + (*info->fprintf_styled_func) (info->stream, dis_style_text, ":"); + (*info->fprintf_styled_func) (info->stream, dis_style_immediate, + "%d", 1 << ((ext >> 9) & 3)); } } @@ -537,20 +559,12 @@ print_indexed (int basereg, disassemble_info *info) { int word; - static char *const scales[] = { "", ":2", ":4", ":8" }; bfd_vma base_disp; bfd_vma outer_disp; - char buf[40]; + bool print_index = true; NEXTWORD (p, word, NULL); - /* Generate the text for the index register. - Where this will be output is not yet determined. */ - sprintf (buf, "%s:%c%s", - reg_names[(word >> 12) & 0xf], - (word & 0x800) ? 'l' : 'w', - scales[(word >> 9) & 3]); - /* Handle the 68000 style of indexing. */ if ((word & 0x100) == 0) @@ -561,7 +575,9 @@ print_indexed (int basereg, if (basereg == -1) base_disp += addr; print_base (basereg, base_disp, info); - (*info->fprintf_func) (info->stream, ",%s)", buf); + (*info->fprintf_styled_func) (info->stream, dis_style_text, ","); + print_index_register (word, info); + (*info->fprintf_styled_func) (info->stream, dis_style_text, ")"); return p; } @@ -575,7 +591,7 @@ print_indexed (int basereg, basereg = -2; } if (word & 0100) - buf[0] = '\0'; + print_index = false; base_disp = 0; switch ((word >> 4) & 3) { @@ -592,9 +608,12 @@ print_indexed (int basereg, if ((word & 7) == 0) { print_base (basereg, base_disp, info); - if (buf[0] != '\0') - (*info->fprintf_func) (info->stream, ",%s", buf); - (*info->fprintf_func) (info->stream, ")"); + if (print_index) + { + (*info->fprintf_styled_func) (info->stream, dis_style_text, ","); + print_index_register (word, info); + } + (*info->fprintf_styled_func) (info->stream, dis_style_text, ")"); return p; } @@ -610,15 +629,22 @@ print_indexed (int basereg, } print_base (basereg, base_disp, info); - if ((word & 4) == 0 && buf[0] != '\0') + if ((word & 4) == 0 && print_index) { - (*info->fprintf_func) (info->stream, ",%s", buf); - buf[0] = '\0'; + (*info->fprintf_styled_func) (info->stream, dis_style_text, ","); + print_index_register (word, info); + print_index = false; } - (*info->fprintf_func) (info->stream, ")@(%" PRIx64, (uint64_t) outer_disp); - if (buf[0] != '\0') - (*info->fprintf_func) (info->stream, ",%s", buf); - (*info->fprintf_func) (info->stream, ")"); + (*info->fprintf_styled_func) (info->stream, dis_style_text, + ")@("); + (*info->fprintf_styled_func) (info->stream, dis_style_address_offset, + "%" PRIx64, (uint64_t) outer_disp); + if (print_index) + { + (*info->fprintf_styled_func) (info->stream, dis_style_text, ","); + print_index_register (word, info); + } + (*info->fprintf_styled_func) (info->stream, dis_style_text, ")"); return p; } @@ -660,14 +686,17 @@ print_insn_arg (const char *d, { static char *const cacheFieldName[] = { "nc", "dc", "ic", "bc" }; FETCH_ARG (2, val); - (*info->fprintf_func) (info->stream, "%s", cacheFieldName[val]); + (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic, + "%s", cacheFieldName[val]); break; } case 'a': /* Address register indirect only. Cf. case '+'. */ { FETCH_ARG (3, val); - (*info->fprintf_func) (info->stream, "%s@", reg_names[val + 8]); + (*info->fprintf_styled_func) (info->stream, dis_style_register, "%s", + reg_names[val + 8]); + (*info->fprintf_styled_func) (info->stream, dis_style_text, "@"); break; } @@ -679,27 +708,27 @@ print_insn_arg (const char *d, } case 'C': - (*info->fprintf_func) (info->stream, "%%ccr"); + (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%ccr"); break; case 'S': - (*info->fprintf_func) (info->stream, "%%sr"); + (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%sr"); break; case 'U': - (*info->fprintf_func) (info->stream, "%%usp"); + (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%usp"); break; case 'E': - (*info->fprintf_func) (info->stream, "%%acc"); + (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%acc"); break; case 'G': - (*info->fprintf_func) (info->stream, "%%macsr"); + (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%macsr"); break; case 'H': - (*info->fprintf_func) (info->stream, "%%mask"); + (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%mask"); break; case 'J': @@ -749,7 +778,8 @@ print_insn_arg (const char *d, for (regno = ARRAY_SIZE (names_v4e); --regno >= 0;) if (names_v4e[regno].value == val) { - (*info->fprintf_func) (info->stream, "%s", names_v4e[regno].name); + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%s", names_v4e[regno].name); break; } if (regno >= 0) @@ -758,11 +788,12 @@ print_insn_arg (const char *d, for (regno = ARRAY_SIZE (names) - 1; regno >= 0; regno--) if (names[regno].value == val) { - (*info->fprintf_func) (info->stream, "%s", names[regno].name); + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%s", names[regno].name); break; } if (regno < 0) - (*info->fprintf_func) (info->stream, "0x%x", val); + (*info->fprintf_styled_func) (info->stream, dis_style_text, "0x%x", val); } break; @@ -771,7 +802,8 @@ print_insn_arg (const char *d, /* 0 means 8, except for the bkpt instruction... */ if (val == 0 && d[1] != 's') val = 8; - (*info->fprintf_func) (info->stream, "#%d", val); + (*info->fprintf_styled_func) (info->stream, dis_style_immediate, + "#%d", val); break; case 'x': @@ -779,17 +811,20 @@ print_insn_arg (const char *d, /* 0 means -1. */ if (val == 0) val = -1; - (*info->fprintf_func) (info->stream, "#%d", val); + (*info->fprintf_styled_func) (info->stream, dis_style_immediate, + "#%d", val); break; case 'j': FETCH_ARG (3, val); - (*info->fprintf_func) (info->stream, "#%d", val+1); + (*info->fprintf_styled_func) (info->stream, dis_style_immediate, + "#%d", val+1); break; case 'K': FETCH_ARG (9, val); - (*info->fprintf_func) (info->stream, "#%d", val); + (*info->fprintf_styled_func) (info->stream, dis_style_immediate, + "#%d", val); break; case 'M': @@ -798,80 +833,108 @@ print_insn_arg (const char *d, static char *const scalefactor_name[] = { "<<", ">>" }; FETCH_ARG (1, val); - (*info->fprintf_func) (info->stream, "%s", scalefactor_name[val]); + (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic, + "%s", scalefactor_name[val]); } else { FETCH_ARG (8, val); if (val & 0x80) val = val - 0x100; - (*info->fprintf_func) (info->stream, "#%d", val); + (*info->fprintf_styled_func) (info->stream, dis_style_immediate, + "#%d", val); } break; case 'T': FETCH_ARG (4, val); - (*info->fprintf_func) (info->stream, "#%d", val); + (*info->fprintf_styled_func) (info->stream, dis_style_immediate, + "#%d", val); break; case 'D': FETCH_ARG (3, val); - (*info->fprintf_func) (info->stream, "%s", reg_names[val]); + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%s", reg_names[val]); break; case 'A': FETCH_ARG (3, val); - (*info->fprintf_func) (info->stream, "%s", reg_names[val + 010]); + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%s", reg_names[val + 010]); break; case 'R': FETCH_ARG (4, val); - (*info->fprintf_func) (info->stream, "%s", reg_names[val]); + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%s", reg_names[val]); break; case 'r': FETCH_ARG (4, regno); if (regno > 7) - (*info->fprintf_func) (info->stream, "%s@", reg_names[regno]); + { + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%s", reg_names[regno]); + (*info->fprintf_styled_func) (info->stream, dis_style_text, "@"); + } else - (*info->fprintf_func) (info->stream, "@(%s)", reg_names[regno]); + { + (*info->fprintf_styled_func) (info->stream, dis_style_text, "@("); + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%s", reg_names[regno]); + (*info->fprintf_styled_func) (info->stream, dis_style_text, ")"); + } break; case 'F': FETCH_ARG (3, val); - (*info->fprintf_func) (info->stream, "%%fp%d", val); + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%%fp%d", val); break; case 'O': FETCH_ARG (6, val); if (val & 0x20) - (*info->fprintf_func) (info->stream, "%s", reg_names[val & 7]); + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%s", reg_names[val & 7]); else - (*info->fprintf_func) (info->stream, "%d", val); + (*info->fprintf_styled_func) (info->stream, dis_style_immediate, + "%d", val); break; case '+': FETCH_ARG (3, val); - (*info->fprintf_func) (info->stream, "%s@+", reg_names[val + 8]); + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%s", reg_names[val + 8]); + (*info->fprintf_styled_func) (info->stream, dis_style_text, "@+"); break; case '-': FETCH_ARG (3, val); - (*info->fprintf_func) (info->stream, "%s@-", reg_names[val + 8]); + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%s", reg_names[val + 8]); + (*info->fprintf_styled_func) (info->stream, dis_style_text, "@-"); break; case 'k': if (place == 'k') { FETCH_ARG (3, val); - (*info->fprintf_func) (info->stream, "{%s}", reg_names[val]); + (*info->fprintf_styled_func) (info->stream, dis_style_text, "{"); + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%s", reg_names[val]); + (*info->fprintf_styled_func) (info->stream, dis_style_text, "}"); } else if (place == 'C') { FETCH_ARG (7, val); if (val > 63) /* This is a signed constant. */ val -= 128; - (*info->fprintf_func) (info->stream, "{#%d}", val); + (*info->fprintf_styled_func) (info->stream, dis_style_text, "{"); + (*info->fprintf_styled_func) (info->stream, dis_style_immediate, + "#%d", val); + (*info->fprintf_styled_func) (info->stream, dis_style_text, "}"); } else return PRINT_INSN_ARG_INVALID_OPERAND; @@ -897,7 +960,8 @@ print_insn_arg (const char *d, else return PRINT_INSN_ARG_INVALID_OP_TABLE; - (*info->fprintf_func) (info->stream, "#%d", val); + (*info->fprintf_styled_func) (info->stream, dis_style_immediate, + "#%d", val); break; case 'B': @@ -936,31 +1000,41 @@ print_insn_arg (const char *d, NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR); FETCH_ARG (3, val1); - (*info->fprintf_func) (info->stream, "%s@(%d)", reg_names[val1 + 8], val); + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%s", reg_names[val1 + 8]); + (*info->fprintf_styled_func) (info->stream, dis_style_text, "@("); + (*info->fprintf_styled_func) (info->stream, dis_style_address_offset, + "%d", val); + (*info->fprintf_styled_func) (info->stream, dis_style_text, ")"); break; } case 's': FETCH_ARG (3, val); - (*info->fprintf_func) (info->stream, "%s", fpcr_names[val]); + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%s", fpcr_names[val]); break; case 'e': FETCH_ARG (2, val); - (*info->fprintf_func) (info->stream, "%%acc%d", val); + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%%acc%d", val); break; case 'g': FETCH_ARG (1, val); - (*info->fprintf_func) (info->stream, "%%accext%s", val == 0 ? "01" : "23"); + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%%accext%s", val == 0 ? "01" : "23"); break; case 'i': FETCH_ARG (2, val); if (val == 1) - (*info->fprintf_func) (info->stream, "<<"); + (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic, + "<<"); else if (val == 3) - (*info->fprintf_func) (info->stream, ">>"); + (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic, + ">>"); else return PRINT_INSN_ARG_INVALID_OPERAND; break; @@ -971,7 +1045,8 @@ print_insn_arg (const char *d, if (val < 0) return PRINT_INSN_ARG_MEMORY_ERROR; if (val != 1) /* Unusual coprocessor ID? */ - (*info->fprintf_func) (info->stream, "(cpid=%d) ", val); + (*info->fprintf_styled_func) (info->stream, dis_style_text, + "(cpid=%d) ", val); break; case '4': @@ -1022,28 +1097,41 @@ print_insn_arg (const char *d, switch (val >> 3) { case 0: - (*info->fprintf_func) (info->stream, "%s", reg_names[val]); + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%s", reg_names[val]); break; case 1: - (*info->fprintf_func) (info->stream, "%s", regname); + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%s", regname); break; case 2: - (*info->fprintf_func) (info->stream, "%s@", regname); + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%s", regname); + (*info->fprintf_styled_func) (info->stream, dis_style_text, "@"); break; case 3: - (*info->fprintf_func) (info->stream, "%s@+", regname); + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%s", regname); + (*info->fprintf_styled_func) (info->stream, dis_style_text, "@+"); break; case 4: - (*info->fprintf_func) (info->stream, "%s@-", regname); + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%s", regname); + (*info->fprintf_styled_func) (info->stream, dis_style_text, "@-"); break; case 5: NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR); - (*info->fprintf_func) (info->stream, "%s@(%d)", regname, val); + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%s", regname); + (*info->fprintf_styled_func) (info->stream, dis_style_text, "@("); + (*info->fprintf_styled_func) (info->stream, dis_style_address_offset, + "%d", val); + (*info->fprintf_styled_func) (info->stream, dis_style_text, ")"); break; case 6: @@ -1067,9 +1155,11 @@ print_insn_arg (const char *d, case 2: NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR); - (*info->fprintf_func) (info->stream, "%%pc@("); + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%%pc"); + (*info->fprintf_styled_func) (info->stream, dis_style_text, "@("); (*info->print_address_func) (addr + val, info); - (*info->fprintf_func) (info->stream, ")"); + (*info->fprintf_styled_func) (info->stream, dis_style_text, ")"); break; case 3: @@ -1117,9 +1207,11 @@ print_insn_arg (const char *d, return PRINT_INSN_ARG_INVALID_OPERAND; } if (flt_p) /* Print a float? */ - (*info->fprintf_func) (info->stream, "#0e%g", flval); + (*info->fprintf_styled_func) (info->stream, dis_style_immediate, + "#0e%g", flval); else - (*info->fprintf_func) (info->stream, "#%d", val); + (*info->fprintf_styled_func) (info->stream, dis_style_immediate, + "#%d", val); break; default: @@ -1134,7 +1226,7 @@ print_insn_arg (const char *d, { FETCH_ARG (1, val); if (val) - info->fprintf_func (info->stream, "&"); + info->fprintf_styled_func (info->stream, dis_style_text, "&"); } break; @@ -1150,7 +1242,8 @@ print_insn_arg (const char *d, p = p1 > p ? p1 : p; if (val == 0) { - (*info->fprintf_func) (info->stream, "#0"); + (*info->fprintf_styled_func) (info->stream, dis_style_immediate, + "#0"); break; } if (*d == 'l') @@ -1170,15 +1263,22 @@ print_insn_arg (const char *d, int first_regno; if (doneany) - (*info->fprintf_func) (info->stream, "/"); + (*info->fprintf_styled_func) (info->stream, dis_style_text, + "/"); doneany = 1; - (*info->fprintf_func) (info->stream, "%s", reg_names[regno]); + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%s", reg_names[regno]); first_regno = regno; while (val & (1 << (regno + 1))) ++regno; if (regno > first_regno) - (*info->fprintf_func) (info->stream, "-%s", - reg_names[regno]); + { + (*info->fprintf_styled_func) (info->stream, + dis_style_text, "-"); + (*info->fprintf_styled_func) (info->stream, + dis_style_register, "%s", + reg_names[regno]); + } } } else if (place == '3') @@ -1189,7 +1289,8 @@ print_insn_arg (const char *d, FETCH_ARG (8, val); if (val == 0) { - (*info->fprintf_func) (info->stream, "#0"); + (*info->fprintf_styled_func) (info->stream, dis_style_immediate, + "#0"); break; } if (*d == 'l') @@ -1208,21 +1309,30 @@ print_insn_arg (const char *d, { int first_regno; if (doneany) - (*info->fprintf_func) (info->stream, "/"); + (*info->fprintf_styled_func) (info->stream, dis_style_text, + "/"); doneany = 1; - (*info->fprintf_func) (info->stream, "%%fp%d", regno); + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%%fp%d", regno); first_regno = regno; while (val & (1 << (regno + 1))) ++regno; if (regno > first_regno) - (*info->fprintf_func) (info->stream, "-%%fp%d", regno); + { + (*info->fprintf_styled_func) (info->stream, + dis_style_text, "-"); + (*info->fprintf_styled_func) (info->stream, + dis_style_register, + "%%fp%d", regno); + } } } else if (place == '8') { FETCH_ARG (3, val); /* fmoveml for FP status registers. */ - (*info->fprintf_func) (info->stream, "%s", fpcr_names[val]); + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%s", fpcr_names[val]); } else return PRINT_INSN_ARG_INVALID_OP_TABLE; @@ -1261,16 +1371,18 @@ print_insn_arg (const char *d, { int break_reg = ((buffer[3] >> 2) & 7); - (*info->fprintf_func) - (info->stream, val == 0x1c ? "%%bad%d" : "%%bac%d", - break_reg); + (*info->fprintf_styled_func) + (info->stream, dis_style_register, + val == 0x1c ? "%%bad%d" : "%%bac%d", break_reg); } break; default: - (*info->fprintf_func) (info->stream, "", val); + (*info->fprintf_styled_func) (info->stream, dis_style_text, + "", val); } if (name) - (*info->fprintf_func) (info->stream, "%s", name); + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%s", name); } break; @@ -1280,17 +1392,20 @@ print_insn_arg (const char *d, FETCH_ARG (5, fc); if (fc == 1) - (*info->fprintf_func) (info->stream, "%%dfc"); + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%%dfc"); else if (fc == 0) - (*info->fprintf_func) (info->stream, "%%sfc"); + (*info->fprintf_styled_func) (info->stream, dis_style_register, + "%%sfc"); else /* xgettext:c-format */ - (*info->fprintf_func) (info->stream, _(""), fc); + (*info->fprintf_styled_func) (info->stream, dis_style_text, + _(""), fc); } break; case 'V': - (*info->fprintf_func) (info->stream, "%%val"); + (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%val"); break; case 't': @@ -1298,7 +1413,8 @@ print_insn_arg (const char *d, int level; FETCH_ARG (3, level); - (*info->fprintf_func) (info->stream, "%d", level); + (*info->fprintf_styled_func) (info->stream, dis_style_immediate, + "%d", level); } break; @@ -1313,9 +1429,9 @@ print_insn_arg (const char *d, is_upper = 1; reg &= 0xf; } - (*info->fprintf_func) (info->stream, "%s%s", - reg_half_names[reg], - is_upper ? "u" : "l"); + (*info->fprintf_styled_func) (info->stream, dis_style_register, "%s%s", + reg_half_names[reg], + is_upper ? "u" : "l"); } break; @@ -1342,7 +1458,7 @@ match_insn_m68k (bfd_vma memaddr, struct private *priv = (struct private *) info->private_data; bfd_byte *buffer = priv->the_buffer; - fprintf_ftype save_printer = info->fprintf_func; + fprintf_styled_ftype save_printer = info->fprintf_styled_func; void (* save_print_address) (bfd_vma, struct disassemble_info *) = info->print_address_func; @@ -1423,7 +1539,7 @@ match_insn_m68k (bfd_vma memaddr, save_p = p; info->print_address_func = dummy_print_address; - info->fprintf_func = (fprintf_ftype) dummy_printer; + info->fprintf_styled_func = dummy_printer; /* We scan the operands twice. The first time we don't print anything, but look for errors. */ @@ -1436,7 +1552,7 @@ match_insn_m68k (bfd_vma memaddr, else if (eaten == PRINT_INSN_ARG_INVALID_OPERAND || eaten == PRINT_INSN_ARG_MEMORY_ERROR) { - info->fprintf_func = save_printer; + info->fprintf_styled_func = save_printer; info->print_address_func = save_print_address; return eaten == PRINT_INSN_ARG_MEMORY_ERROR ? -1 : 0; } @@ -1444,26 +1560,26 @@ match_insn_m68k (bfd_vma memaddr, { /* We must restore the print functions before trying to print the error message. */ - info->fprintf_func = save_printer; + info->fprintf_styled_func = save_printer; info->print_address_func = save_print_address; - info->fprintf_func (info->stream, - /* xgettext:c-format */ - _("\n"), - best->name, best->args); + info->fprintf_styled_func (info->stream, dis_style_text, + /* xgettext:c-format */ + _("\n"), + best->name, best->args); return 2; } } p = save_p; - info->fprintf_func = save_printer; + info->fprintf_styled_func = save_printer; info->print_address_func = save_print_address; d = args; - info->fprintf_func (info->stream, "%s", best->name); + info->fprintf_styled_func (info->stream, dis_style_mnemonic, "%s", best->name); if (*d) - info->fprintf_func (info->stream, " "); + info->fprintf_styled_func (info->stream, dis_style_text, " "); while (*d) { @@ -1471,7 +1587,7 @@ match_insn_m68k (bfd_vma memaddr, d += 2; if (*d && *(d - 2) != 'I' && *d != 'k') - info->fprintf_func (info->stream, ","); + info->fprintf_styled_func (info->stream, dis_style_text, ","); } return p - buffer; @@ -1638,8 +1754,14 @@ print_insn_m68k (bfd_vma memaddr, disassemble_info *info) } if (val == 0) - /* Handle undefined instructions. */ - info->fprintf_func (info->stream, ".short 0x%04x", (buffer[0] << 8) + buffer[1]); + { + /* Handle undefined instructions. */ + info->fprintf_styled_func (info->stream, dis_style_assembler_directive, + ".short"); + info->fprintf_styled_func (info->stream, dis_style_text, " "); + info->fprintf_styled_func (info->stream, dis_style_immediate, + "0x%04x", (buffer[0] << 8) + buffer[1]); + } return val ? val : 2; }