Skip to content

Commit 2cf71bf

Browse files
committed
correctly print FPU instructions with .p suffix
1 parent e48354c commit 2cf71bf

5 files changed

Lines changed: 18 additions & 6 deletions

File tree

arch/M68K/M68KDisassembler.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2371,12 +2371,17 @@ static void d68020_fpu(m68k_info *info)
23712371
break;
23722372

23732373
case 0x02: // extended real
2374-
case 0x03: // packed decimal
23752374
ext->op_size.type = M68K_SIZE_TYPE_FPU;
23762375
ext->op_size.fpu_size = M68K_FPU_SIZE_EXTENDED;
23772376
get_ea_mode_op(info, op0, info->ir, 12);
23782377
break;
23792378

2379+
case 0x03: // packed decimal
2380+
ext->op_size.type = M68K_SIZE_TYPE_FPU_PACKED;
2381+
ext->op_size.fpu_size = M68K_FPU_SIZE_PACKED;
2382+
get_ea_mode_op(info, op0, info->ir, 12);
2383+
break;
2384+
23802385
default:
23812386
d68000_invalid(info);
23822387
return;

arch/M68K/M68KInstPrinter.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,10 @@ void M68K_printInst(MCInst *MI, SStream *O, void *PrinterInfo)
438438
break;
439439
}
440440
break;
441+
442+
case M68K_SIZE_TYPE_FPU_PACKED:
443+
SStream_concat0(O, ".p");
444+
break;
441445
}
442446

443447
SStream_concat0(O, " ");

include/capstone/m68k.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,22 +203,24 @@ typedef enum m68k_fpu_size {
203203
M68K_FPU_SIZE_SINGLE = 4, ///< 4 byte in size (single float)
204204
M68K_FPU_SIZE_DOUBLE = 8, ///< 8 byte in size (double)
205205
M68K_FPU_SIZE_EXTENDED = 12, ///< 12 byte in size (extended real format)
206+
M68K_FPU_SIZE_PACKED = 12, ///< 12 byte in size (packed decimal real format)
206207
} m68k_fpu_size;
207208

208209
/// Type of size that is being used for the current instruction
209210
typedef enum m68k_size_type {
210211
M68K_SIZE_TYPE_INVALID = 0,
211212

212213
M68K_SIZE_TYPE_CPU,
213-
M68K_SIZE_TYPE_FPU,
214+
M68K_SIZE_TYPE_FPU, ///< FPU instructions with .s, .d, and .x suffixes
215+
M68K_SIZE_TYPE_FPU_PACKED, ///< FPU instructions with .p suffix
214216
} m68k_size_type;
215217

216-
/// Operation size of the current instruction (NOT the actually size of instruction)
218+
/// Operation size of the current instruction (NOT the actual size of instruction)
217219
typedef struct m68k_op_size {
218220
m68k_size_type type;
219221
union {
220-
m68k_cpu_size cpu_size;
221-
m68k_fpu_size fpu_size;
222+
m68k_cpu_size cpu_size; ///< when type is M68K_SIZE_TYPE_CPU
223+
m68k_fpu_size fpu_size; ///< when type is M68K_SIZE_TYPE_FPU or M68K_SIZE_TYPE_FPU_PACKED
222224
};
223225
} m68k_op_size;
224226

suite/cstest/include/test_mapping.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,7 @@ static const cs_enum_id_map cs_enum_map[] = {
923923
{ .str = "M68K_OP_REG_PAIR", .val = M68K_OP_REG_PAIR },
924924
{ .str = "M68K_SIZE_TYPE_CPU", .val = M68K_SIZE_TYPE_CPU },
925925
{ .str = "M68K_SIZE_TYPE_FPU", .val = M68K_SIZE_TYPE_FPU },
926+
{ .str = "M68K_SIZE_TYPE_FPU_PACKED", .val = M68K_SIZE_TYPE_FPU_PACKED },
926927
{ .str = "MIPS_INS_ADDIU", .val = MIPS_INS_ADDIU },
927928
{ .str = "MIPS_INS_ADDIUPC", .val = MIPS_INS_ADDIUPC },
928929
{ .str = "MIPS_INS_ALIAS_B", .val = MIPS_INS_ALIAS_B },

tests/details/m68k.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1291,7 +1291,7 @@ test_cases:
12911291
type: M68K_OP_REG
12921292
reg: fp0
12931293
-
1294-
asm_text: "fmove.x (a0), fp0"
1294+
asm_text: "fmove.p (a0), fp0"
12951295
details:
12961296
regs_read: [ a0 ]
12971297
regs_write: [ fp0 ]

0 commit comments

Comments
 (0)