Skip to contentSkip to conversation

m68k: implement movep instruction

PATCH Superseded Pavel Dovgalyuk 2 participants 2 messages Feb 6, 2018

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 m68k: implement movep instruction

This patch implements movep instruction. It moves data between a data register and alternate bytes within the address space starting at the location specified and incrementing by two.

It was designed for the original 68000 and used in firmwares for interfacing the 8-bit peripherals through the 16-bit data bus. Without this patch opcode for this instruction is recognized as some bitop.

--

v3: - simplified movep function code
- joined movep masks

v2: - disabled movep for Coldfire
- fixed gen_store/load usage

---
 target/m68k/cpu.c       |    2 ++
 target/m68k/cpu.h       |    1 +
 target/m68k/translate.c |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 49 insertions(+)
target/m68k/cpu.c +2 -0
index 98919b3..461db85 100644
@@ -113,6 +113,7 @@ static void m68000_cpu_initfn(Object *obj)
     m68k_set_feature(env, M68K_FEATURE_M68000);
     m68k_set_feature(env, M68K_FEATURE_USP);
     m68k_set_feature(env, M68K_FEATURE_WORD_INDEX);
+    m68k_set_feature(env, M68K_FEATURE_MOVEP);
 }
 
 static void m68020_cpu_initfn(Object *obj)
@@ -135,6 +136,7 @@ static void m68020_cpu_initfn(Object *obj)
     m68k_set_feature(env, M68K_FEATURE_BKPT);
     m68k_set_feature(env, M68K_FEATURE_RTD);
     m68k_set_feature(env, M68K_FEATURE_CHK2);
+    m68k_set_feature(env, M68K_FEATURE_MOVEP);
 }
 #define m68030_cpu_initfn m68020_cpu_initfn
 
target/m68k/cpu.h +1 -0
index 627fb78..1d79885 100644
@@ -492,6 +492,7 @@ enum m68k_features {
     M68K_FEATURE_RTD,
     M68K_FEATURE_CHK2,
     M68K_FEATURE_M68040, /* instructions specific to MC68040 */
+    M68K_FEATURE_MOVEP,
 };
 
 static inline int m68k_feature(CPUM68KState *env, int feature)
target/m68k/translate.c +46 -0

58 lines not on this page · raw message

#1 lore raw

Le 06/02/2018 à 12:43, Pavel Dovgalyuk a écrit :

Quoted 23 lines

This patch implements movep instruction. It moves data between a data register and alternate bytes within the address space starting at the location specified and incrementing by two.

It was designed for the original 68000 and used in firmwares for interfacing the 8-bit peripherals through the 16-bit data bus. Without this patch opcode for this instruction is recognized as some bitop.

--

v3: - simplified movep function code
- joined movep masks

v2: - disabled movep for Coldfire
- fixed gen_store/load usage

---
 target/m68k/cpu.c       |    2 ++
 target/m68k/cpu.h       |    1 +
 target/m68k/translate.c |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 49 insertions(+)

...

Quoted 8 lines
target/m68k/translate.c +8 -0
+    if (insn & 0x40) {
+        i = 4;
+    } else {
+        i = 2;
+    }
+
+    if (insn & 0x80) {
+        for ( ; i > 0 ; i--) {

target/m68k/translate.c DISAS_INSN(movem) · line 2116

Quoted 10 lines
target/m68k/translate.c +10 -0
+            tcg_gen_shri_i32(dbuf, reg, (i - 1) * 8);
+            tcg_gen_qemu_st8(dbuf, abuf, IS_USER(s));
+            if (i > 1) {
+                tcg_gen_addi_i32(abuf, abuf, 2);
+            }
+        }
+    } else {
+        for ( ; i > 0 ; i--) {
+            tcg_gen_qemu_ld8u(dbuf, abuf, IS_USER(s));
+            tcg_gen_deposit_i32(reg, reg, dbuf, i * 8, 8);

it should be (i - 1).

Thanks,
Laurent