3067 |
const int powerpc_num_macros = |
const int powerpc_num_macros = |
3068 |
sizeof (powerpc_macros) / sizeof (powerpc_macros[0]); |
sizeof (powerpc_macros) / sizeof (powerpc_macros[0]); |
3069 |
|
|
3070 |
static int print_insn_powerpc(FILE *, uint32_t insn, unsigned memaddr, int dialect); |
static int |
3071 |
|
print_insn_powerpc (disassemble_info *info, uint32_t insn, unsigned memaddr, |
3072 |
|
int dialect); |
3073 |
|
|
3074 |
/* Print a big endian PowerPC instruction. For convenience, also |
/* Print a big endian PowerPC instruction. For convenience, also |
3075 |
disassemble instructions supported by the Motorola PowerPC 601. */ |
disassemble instructions supported by the Motorola PowerPC 601. */ |
3085 |
opc = bfd_getb32(buf); |
opc = bfd_getb32(buf); |
3086 |
else |
else |
3087 |
opc = bfd_getl32(buf); |
opc = bfd_getl32(buf); |
3088 |
return print_insn_powerpc (info->stream, opc, pc, |
return print_insn_powerpc (info, opc, pc, |
3089 |
PPC | B32 | M601); |
PPC | B32 | M601); |
3090 |
} |
} |
3091 |
|
|
3092 |
/* Print a PowerPC or POWER instruction. */ |
/* Print a PowerPC or POWER instruction. */ |
3093 |
|
|
3094 |
static int |
static int |
3095 |
print_insn_powerpc (FILE *out, uint32_t insn, unsigned memaddr, |
print_insn_powerpc (disassemble_info *info, uint32_t insn, unsigned memaddr, |
3096 |
int dialect) |
int dialect) |
3097 |
{ |
{ |
3098 |
const struct powerpc_opcode *opcode; |
const struct powerpc_opcode *opcode; |
3138 |
continue; |
continue; |
3139 |
|
|
3140 |
/* The instruction is valid. */ |
/* The instruction is valid. */ |
3141 |
fprintf(out, "%s", opcode->name); |
(*info->fprintf_func)(info->stream, "%s", opcode->name); |
3142 |
if (opcode->operands[0] != 0) |
if (opcode->operands[0] != 0) |
3143 |
fprintf(out, "\t"); |
(*info->fprintf_func)(info->stream, "\t"); |
3144 |
|
|
3145 |
/* Now extract and print the operands. */ |
/* Now extract and print the operands. */ |
3146 |
need_comma = 0; |
need_comma = 0; |
3177 |
|
|
3178 |
if (need_comma) |
if (need_comma) |
3179 |
{ |
{ |
3180 |
fprintf(out, ","); |
(*info->fprintf_func)(info->stream, ","); |
3181 |
need_comma = 0; |
need_comma = 0; |
3182 |
} |
} |
3183 |
|
|
3184 |
/* Print the operand as directed by the flags. */ |
/* Print the operand as directed by the flags. */ |
3185 |
if ((operand->flags & PPC_OPERAND_GPR) != 0) |
if ((operand->flags & PPC_OPERAND_GPR) != 0) |
3186 |
fprintf(out, "r%d", value); |
(*info->fprintf_func)(info->stream, "r%d", value); |
3187 |
else if ((operand->flags & PPC_OPERAND_FPR) != 0) |
else if ((operand->flags & PPC_OPERAND_FPR) != 0) |
3188 |
fprintf(out, "f%d", value); |
(*info->fprintf_func)(info->stream, "f%d", value); |
3189 |
else if ((operand->flags & PPC_OPERAND_RELATIVE) != 0) |
else if ((operand->flags & PPC_OPERAND_RELATIVE) != 0) |
3190 |
fprintf(out, "%08X", memaddr + value); |
(*info->fprintf_func)(info->stream, "%08X", memaddr + value); |
3191 |
else if ((operand->flags & PPC_OPERAND_ABSOLUTE) != 0) |
else if ((operand->flags & PPC_OPERAND_ABSOLUTE) != 0) |
3192 |
fprintf(out, "%08X", value & 0xffffffff); |
(*info->fprintf_func)(info->stream, "%08X", value & 0xffffffff); |
3193 |
else if ((operand->flags & PPC_OPERAND_CR) == 0 |
else if ((operand->flags & PPC_OPERAND_CR) == 0 |
3194 |
|| (dialect & PPC_OPCODE_PPC) == 0) |
|| (dialect & PPC_OPCODE_PPC) == 0) |
3195 |
fprintf(out, "%d", value); |
(*info->fprintf_func)(info->stream, "%d", value); |
3196 |
else |
else |
3197 |
{ |
{ |
3198 |
if (operand->bits == 3) |
if (operand->bits == 3) |
3199 |
fprintf(out, "cr%d", value); |
(*info->fprintf_func)(info->stream, "cr%d", value); |
3200 |
else |
else |
3201 |
{ |
{ |
3202 |
static const char *cbnames[4] = { "lt", "gt", "eq", "so" }; |
static const char *cbnames[4] = { "lt", "gt", "eq", "so" }; |
3205 |
|
|
3206 |
cr = value >> 2; |
cr = value >> 2; |
3207 |
if (cr != 0) |
if (cr != 0) |
3208 |
fprintf(out, "4*cr%d", cr); |
(*info->fprintf_func)(info->stream, "4*cr%d", cr); |
3209 |
cc = value & 3; |
cc = value & 3; |
3210 |
if (cc != 0) |
if (cc != 0) |
3211 |
{ |
{ |
3212 |
if (cr != 0) |
if (cr != 0) |
3213 |
fprintf(out, "+"); |
(*info->fprintf_func)(info->stream, "+"); |
3214 |
fprintf(out, "%s", cbnames[cc]); |
(*info->fprintf_func)(info->stream, "%s", cbnames[cc]); |
3215 |
} |
} |
3216 |
} |
} |
3217 |
} |
} |
3218 |
|
|
3219 |
if (need_paren) |
if (need_paren) |
3220 |
{ |
{ |
3221 |
fprintf(out, ")"); |
(*info->fprintf_func)(info->stream, ")"); |
3222 |
need_paren = 0; |
need_paren = 0; |
3223 |
} |
} |
3224 |
|
|
3226 |
need_comma = 1; |
need_comma = 1; |
3227 |
else |
else |
3228 |
{ |
{ |
3229 |
fprintf(out, "("); |
(*info->fprintf_func)(info->stream, "("); |
3230 |
need_paren = 1; |
need_paren = 1; |
3231 |
} |
} |
3232 |
} |
} |
3236 |
} |
} |
3237 |
|
|
3238 |
/* We could not find a match. */ |
/* We could not find a match. */ |
3239 |
fprintf(out, ".long 0x%x", insn); |
(*info->fprintf_func)(info->stream, ".long 0x%x", insn); |
3240 |
|
|
3241 |
return 4; |
return 4; |
3242 |
} |
} |