@@ -494,7 +494,10 @@ static void get_with_index_address_mode(m68k_info *info, cs_m68k_op *op,
494494 uint32_t instruction , uint32_t size ,
495495 bool is_pc )
496496{
497+ uint32_t ext_addr = info -> pc ;
497498 uint32_t extension = read_imm_16 (info );
499+ int32_t pc_adjust =
500+ is_pc ? (int32_t )(ext_addr - info -> baseAddress - 2 ) : 0 ;
498501
499502 op -> address_mode = M68K_AM_AREGI_INDEX_BASE_DISP ;
500503
@@ -511,6 +514,7 @@ static void get_with_index_address_mode(m68k_info *info, cs_m68k_op *op,
511514 read_imm_32 (info ) :
512515 (int16_t )read_imm_16 (info )) :
513516 0 ;
517+ op -> mem .in_disp += pc_adjust ;
514518
515519 op -> mem .in_disp_size =
516520 EXT_BASE_DISPLACEMENT_PRESENT (extension ) &&
@@ -590,6 +594,7 @@ static void get_with_index_address_mode(m68k_info *info, cs_m68k_op *op,
590594 }
591595
592596 op -> mem .disp = (int8_t )(extension & 0xff );
597+ op -> mem .disp += pc_adjust ;
593598 op -> mem .disp_size = 0 ;
594599
595600 if (EXT_INDEX_SCALE (extension )) {
@@ -712,12 +717,22 @@ static void get_ea_mode_op(m68k_info *info, cs_m68k_op *op,
712717 op -> imm = read_imm_32 (info );
713718 break ;
714719
715- case 0x3a :
720+ case 0x3a : {
716721 /* program counter with displacement */
722+ /* The printer computes the effective address as
723+ * instruction_start + 2 + disp, assuming the displacement
724+ * extension word immediately follows the opcode word.
725+ * When extra words precede the EA (e.g. an immediate in
726+ * BTST #imm,disp(PC)), the displacement word is further
727+ * along. Adjust disp so the printer still produces the
728+ * correct absolute address. */
729+ uint32_t disp_addr = info -> pc ;
717730 op -> address_mode = M68K_AM_PCI_DISP ;
718731 op -> mem .disp = (int16_t )read_imm_16 (info );
732+ op -> mem .disp += (int16_t )(disp_addr - info -> baseAddress - 2 );
719733 op -> mem .disp_size = 1 ;
720734 break ;
735+ }
721736
722737 case 0x3b :
723738 /* program counter with index */
@@ -1761,31 +1776,33 @@ static void d68010_bkpt(m68k_info *info)
17611776
17621777static void d68020_bfchg (m68k_info * info )
17631778{
1764- LIMIT_CPU_TYPES (info , M68020_PLUS );
1779+ /* Bit field ops are 68020+ only; CPU32 does NOT support them
1780+ * despite sharing TYPE_68020. */
1781+ LIMIT_CPU_TYPES_NOT_CPU32 (info , M68020_PLUS );
17651782 build_bitfield_ins (info , M68K_INS_BFCHG , false);
17661783}
17671784
17681785static void d68020_bfclr (m68k_info * info )
17691786{
1770- LIMIT_CPU_TYPES (info , M68020_PLUS );
1787+ LIMIT_CPU_TYPES_NOT_CPU32 (info , M68020_PLUS );
17711788 build_bitfield_ins (info , M68K_INS_BFCLR , false);
17721789}
17731790
17741791static void d68020_bfexts (m68k_info * info )
17751792{
1776- LIMIT_CPU_TYPES (info , M68020_PLUS );
1793+ LIMIT_CPU_TYPES_NOT_CPU32 (info , M68020_PLUS );
17771794 build_bitfield_ins (info , M68K_INS_BFEXTS , true);
17781795}
17791796
17801797static void d68020_bfextu (m68k_info * info )
17811798{
1782- LIMIT_CPU_TYPES (info , M68020_PLUS );
1799+ LIMIT_CPU_TYPES_NOT_CPU32 (info , M68020_PLUS );
17831800 build_bitfield_ins (info , M68K_INS_BFEXTU , true);
17841801}
17851802
17861803static void d68020_bfffo (m68k_info * info )
17871804{
1788- LIMIT_CPU_TYPES (info , M68020_PLUS );
1805+ LIMIT_CPU_TYPES_NOT_CPU32 (info , M68020_PLUS );
17891806 build_bitfield_ins (info , M68K_INS_BFFFO , true);
17901807}
17911808
@@ -1794,7 +1811,7 @@ static void d68020_bfins(m68k_info *info)
17941811 cs_m68k * ext = & info -> extension ;
17951812 cs_m68k_op temp ;
17961813
1797- LIMIT_CPU_TYPES (info , M68020_PLUS );
1814+ LIMIT_CPU_TYPES_NOT_CPU32 (info , M68020_PLUS );
17981815 build_bitfield_ins (info , M68K_INS_BFINS , true);
17991816
18001817 // a bit hacky but we need to flip the args on only this instruction
@@ -1806,12 +1823,13 @@ static void d68020_bfins(m68k_info *info)
18061823
18071824static void d68020_bfset (m68k_info * info )
18081825{
1809- LIMIT_CPU_TYPES (info , M68020_PLUS );
1826+ LIMIT_CPU_TYPES_NOT_CPU32 (info , M68020_PLUS );
18101827 build_bitfield_ins (info , M68K_INS_BFSET , false);
18111828}
18121829
18131830static void d68020_bftst (m68k_info * info )
18141831{
1832+ LIMIT_CPU_TYPES_NOT_CPU32 (info , M68020_PLUS );
18151833 build_bitfield_ins (info , M68K_INS_BFTST , false);
18161834}
18171835
0 commit comments