Commit 43ef9eb267fc0daade111c35ae945dc95427e3ef
1 parent
e4cf1adc
use fprintf_func callback to print code
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1435 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
20 additions
and
18 deletions
ppc-dis.c
... | ... | @@ -3067,7 +3067,9 @@ const struct powerpc_macro powerpc_macros[] = { |
3067 | 3067 | const int powerpc_num_macros = |
3068 | 3068 | sizeof (powerpc_macros) / sizeof (powerpc_macros[0]); |
3069 | 3069 | |
3070 | -static int print_insn_powerpc(FILE *, uint32_t insn, unsigned memaddr, int dialect); | |
3070 | +static int | |
3071 | +print_insn_powerpc (disassemble_info *info, uint32_t insn, unsigned memaddr, | |
3072 | + int dialect); | |
3071 | 3073 | |
3072 | 3074 | /* Print a big endian PowerPC instruction. For convenience, also |
3073 | 3075 | disassemble instructions supported by the Motorola PowerPC 601. */ |
... | ... | @@ -3083,14 +3085,14 @@ int print_insn_ppc (bfd_vma pc, disassemble_info *info) |
3083 | 3085 | opc = bfd_getb32(buf); |
3084 | 3086 | else |
3085 | 3087 | opc = bfd_getl32(buf); |
3086 | - return print_insn_powerpc (info->stream, opc, pc, | |
3088 | + return print_insn_powerpc (info, opc, pc, | |
3087 | 3089 | PPC | B32 | M601); |
3088 | 3090 | } |
3089 | 3091 | |
3090 | 3092 | /* Print a PowerPC or POWER instruction. */ |
3091 | 3093 | |
3092 | 3094 | static int |
3093 | -print_insn_powerpc (FILE *out, uint32_t insn, unsigned memaddr, | |
3095 | +print_insn_powerpc (disassemble_info *info, uint32_t insn, unsigned memaddr, | |
3094 | 3096 | int dialect) |
3095 | 3097 | { |
3096 | 3098 | const struct powerpc_opcode *opcode; |
... | ... | @@ -3136,9 +3138,9 @@ print_insn_powerpc (FILE *out, uint32_t insn, unsigned memaddr, |
3136 | 3138 | continue; |
3137 | 3139 | |
3138 | 3140 | /* The instruction is valid. */ |
3139 | - fprintf(out, "%s", opcode->name); | |
3141 | + (*info->fprintf_func)(info->stream, "%s", opcode->name); | |
3140 | 3142 | if (opcode->operands[0] != 0) |
3141 | - fprintf(out, "\t"); | |
3143 | + (*info->fprintf_func)(info->stream, "\t"); | |
3142 | 3144 | |
3143 | 3145 | /* Now extract and print the operands. */ |
3144 | 3146 | need_comma = 0; |
... | ... | @@ -3175,26 +3177,26 @@ print_insn_powerpc (FILE *out, uint32_t insn, unsigned memaddr, |
3175 | 3177 | |
3176 | 3178 | if (need_comma) |
3177 | 3179 | { |
3178 | - fprintf(out, ","); | |
3180 | + (*info->fprintf_func)(info->stream, ","); | |
3179 | 3181 | need_comma = 0; |
3180 | 3182 | } |
3181 | 3183 | |
3182 | 3184 | /* Print the operand as directed by the flags. */ |
3183 | 3185 | if ((operand->flags & PPC_OPERAND_GPR) != 0) |
3184 | - fprintf(out, "r%d", value); | |
3186 | + (*info->fprintf_func)(info->stream, "r%d", value); | |
3185 | 3187 | else if ((operand->flags & PPC_OPERAND_FPR) != 0) |
3186 | - fprintf(out, "f%d", value); | |
3188 | + (*info->fprintf_func)(info->stream, "f%d", value); | |
3187 | 3189 | else if ((operand->flags & PPC_OPERAND_RELATIVE) != 0) |
3188 | - fprintf(out, "%08X", memaddr + value); | |
3190 | + (*info->fprintf_func)(info->stream, "%08X", memaddr + value); | |
3189 | 3191 | else if ((operand->flags & PPC_OPERAND_ABSOLUTE) != 0) |
3190 | - fprintf(out, "%08X", value & 0xffffffff); | |
3192 | + (*info->fprintf_func)(info->stream, "%08X", value & 0xffffffff); | |
3191 | 3193 | else if ((operand->flags & PPC_OPERAND_CR) == 0 |
3192 | 3194 | || (dialect & PPC_OPCODE_PPC) == 0) |
3193 | - fprintf(out, "%d", value); | |
3195 | + (*info->fprintf_func)(info->stream, "%d", value); | |
3194 | 3196 | else |
3195 | 3197 | { |
3196 | 3198 | if (operand->bits == 3) |
3197 | - fprintf(out, "cr%d", value); | |
3199 | + (*info->fprintf_func)(info->stream, "cr%d", value); | |
3198 | 3200 | else |
3199 | 3201 | { |
3200 | 3202 | static const char *cbnames[4] = { "lt", "gt", "eq", "so" }; |
... | ... | @@ -3203,20 +3205,20 @@ print_insn_powerpc (FILE *out, uint32_t insn, unsigned memaddr, |
3203 | 3205 | |
3204 | 3206 | cr = value >> 2; |
3205 | 3207 | if (cr != 0) |
3206 | - fprintf(out, "4*cr%d", cr); | |
3208 | + (*info->fprintf_func)(info->stream, "4*cr%d", cr); | |
3207 | 3209 | cc = value & 3; |
3208 | 3210 | if (cc != 0) |
3209 | 3211 | { |
3210 | 3212 | if (cr != 0) |
3211 | - fprintf(out, "+"); | |
3212 | - fprintf(out, "%s", cbnames[cc]); | |
3213 | + (*info->fprintf_func)(info->stream, "+"); | |
3214 | + (*info->fprintf_func)(info->stream, "%s", cbnames[cc]); | |
3213 | 3215 | } |
3214 | 3216 | } |
3215 | 3217 | } |
3216 | 3218 | |
3217 | 3219 | if (need_paren) |
3218 | 3220 | { |
3219 | - fprintf(out, ")"); | |
3221 | + (*info->fprintf_func)(info->stream, ")"); | |
3220 | 3222 | need_paren = 0; |
3221 | 3223 | } |
3222 | 3224 | |
... | ... | @@ -3224,7 +3226,7 @@ print_insn_powerpc (FILE *out, uint32_t insn, unsigned memaddr, |
3224 | 3226 | need_comma = 1; |
3225 | 3227 | else |
3226 | 3228 | { |
3227 | - fprintf(out, "("); | |
3229 | + (*info->fprintf_func)(info->stream, "("); | |
3228 | 3230 | need_paren = 1; |
3229 | 3231 | } |
3230 | 3232 | } |
... | ... | @@ -3234,7 +3236,7 @@ print_insn_powerpc (FILE *out, uint32_t insn, unsigned memaddr, |
3234 | 3236 | } |
3235 | 3237 | |
3236 | 3238 | /* We could not find a match. */ |
3237 | - fprintf(out, ".long 0x%x", insn); | |
3239 | + (*info->fprintf_func)(info->stream, ".long 0x%x", insn); | |
3238 | 3240 | |
3239 | 3241 | return 4; |
3240 | 3242 | } | ... | ... |