From patchwork Wed Feb 14 10:39:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 873306 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zhGBJ08NLz9t3B for ; Wed, 14 Feb 2018 21:39:50 +1100 (AEDT) Received: from localhost ([::1]:33941 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eluTc-0002Qo-8d for incoming@patchwork.ozlabs.org; Wed, 14 Feb 2018 05:39:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34218) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eluT6-0002ME-Jk for qemu-devel@nongnu.org; Wed, 14 Feb 2018 05:39:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eluT2-0003Gy-Jm for qemu-devel@nongnu.org; Wed, 14 Feb 2018 05:39:16 -0500 Received: from mout.kundenserver.de ([217.72.192.73]:52309) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eluT2-0003Fx-9U for qemu-devel@nongnu.org; Wed, 14 Feb 2018 05:39:12 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.183]) with ESMTPSA (Nemesis) id 0MgNZW-1f7Prc0llu-00NflK; Wed, 14 Feb 2018 11:39:10 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Wed, 14 Feb 2018 11:39:06 +0100 Message-Id: <20180214103906.3704-2-laurent@vivier.eu> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180214103906.3704-1-laurent@vivier.eu> References: <20180214103906.3704-1-laurent@vivier.eu> X-Provags-ID: V03:K0:wsOlg0aIBM8tPNUQ/G3nWeCKAArstgv7o/MT+T+5XAQdYYd0cgv yD2AsAy0xtuGkTA6G4qIr8aOTEKZwN5n6O7ZnzYgUjOwuQiLWTLR3Ef2M8XvefUtWvnralR bMBnkd5/xydsmwf3QL5FEQWr7HozKeSV+BNVVmRX7l++0Vb8/OJqBqgdr+QdNo+UJWGp3vP dL+yGUJRoGlX6vxNMdyzQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:l8Myu129cv4=:8BC1zqB25rixEIgrBVsTsQ RKcZDFhdC/67Re6p27zukEJiyitXZ6wKG7y/wh0fF53hHHm9WBKN2wJ2y0RBw5g4mNud8N3YB lINbdCUx8UKn0CpQliR7/BaFTDBIEbNLPHaFKo26YoMJf1mds5T5KnWH8jSzHKiXbmI8msqj7 pRTL6nRXwM8Lbq9SYOKvxev0eZe6sGU/kh63g8IT3zK1ZFKGyolRrlbi5n0+Ht5krfavBvk+f UvPL9IDX3oh64QWuXSVikS/UoiCTQkWjreMfXbYy11U/fzo/a/E7BEa4o6aeyandea9kVbRER wKjv5jM+4Ffq6FV9B1XaSy71K5yTXCd31n4rd76PMx3+o7UDQY9MY7RMYSALu8oa5lNZvn7HV wiTRtYKsLGQaaDVbG2arhpzD26x7OTzi1ClnX7IxTZoGcAqx5nDwyn06vAPxCf6D8WbIFk7My iI7atQDh4G7bidB4P7RFnBc4Rs42OjZbPe/32k5vMOzSUMU9CtivPMtUj8S3Ds8aL1z3W2dhj Tq1nM9hbUdepFjmbmXsNwJumtiE1p3FsT6P04FTTCmt8xcr/5uCFXz5Eq0VN9OjoYCc0c+4zs GJyvgSi2rCCa6toGkU1zlfNxKD/YjNOgOvXaJAZMCrEJxsZ7nMZak7OGRn15SWyukay9ouRXY oY9U+Ao30wgg5H/s8/3SbzBFSWPqO7cPyVPe9v+VpOFqKOsJq1RH1r+AmNMTPqbENVCBMOoR1 ueq9PT9tgUH0KRtdMwo12ZZxf0vV57d3qa5WBw== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 217.72.192.73 Subject: [Qemu-devel] [PULL 1/1] m68k: implement movep instruction X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mihail Abakumov , Pavel Dovgalyuk , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Pavel Dovgalyuk 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. Signed-off-by: Pavel Dovgalyuk Signed-off-by: Mihail Abakumov Tested-by: Laurent Vivier Reviewed-by: Laurent Vivier Message-Id: <20180206124431.31433.91946.stgit@pasha-VirtualBox> Signed-off-by: Laurent Vivier --- target/m68k/cpu.c | 2 ++ target/m68k/cpu.h | 1 + target/m68k/translate.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index 6a80be009b..3026714471 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -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 diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h index 627fb787b6..1d79885222 100644 --- a/target/m68k/cpu.h +++ b/target/m68k/cpu.h @@ -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) diff --git a/target/m68k/translate.c b/target/m68k/translate.c index 34db97b8a0..70c7583621 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -2078,6 +2078,51 @@ DISAS_INSN(movem) tcg_temp_free(addr); } +DISAS_INSN(movep) +{ + uint8_t i; + int16_t displ; + TCGv reg; + TCGv addr; + TCGv abuf; + TCGv dbuf; + + displ = read_im16(env, s); + + addr = AREG(insn, 0); + reg = DREG(insn, 9); + + abuf = tcg_temp_new(); + tcg_gen_addi_i32(abuf, addr, displ); + dbuf = tcg_temp_new(); + + if (insn & 0x40) { + i = 4; + } else { + i = 2; + } + + if (insn & 0x80) { + for ( ; i > 0 ; i--) { + 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 - 1) * 8, 8); + if (i > 1) { + tcg_gen_addi_i32(abuf, abuf, 2); + } + } + } + tcg_temp_free(abuf); + tcg_temp_free(dbuf); +} + DISAS_INSN(bitop_im) { int opsize; @@ -5678,6 +5723,7 @@ void register_m68k_insns (CPUM68KState *env) BASE(bitop_reg, 0140, f1c0); BASE(bitop_reg, 0180, f1c0); BASE(bitop_reg, 01c0, f1c0); + INSN(movep, 0108, f138, MOVEP); INSN(arith_im, 0280, fff8, CF_ISA_A); INSN(arith_im, 0200, ff00, M68000); INSN(undef, 02c0, ffc0, M68000);