From patchwork Thu Jul 14 04:10:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Rolnik X-Patchwork-Id: 9228949 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B7085607D0 for ; Thu, 14 Jul 2016 04:12:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6A7A27FB6 for ; Thu, 14 Jul 2016 04:12:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B7762808C; Thu, 14 Jul 2016 04:12:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2E24227FB6 for ; Thu, 14 Jul 2016 04:12:26 +0000 (UTC) Received: from localhost ([::1]:51328 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNY0f-0002fk-9V for patchwork-qemu-devel@patchwork.kernel.org; Thu, 14 Jul 2016 00:12:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59283) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNY04-0002cY-09 for qemu-devel@nongnu.org; Thu, 14 Jul 2016 00:11:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bNY01-0002zb-Ar for qemu-devel@nongnu.org; Thu, 14 Jul 2016 00:11:47 -0400 Received: from mail-pa0-x244.google.com ([2607:f8b0:400e:c03::244]:32953) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNY00-0002zV-SA for qemu-devel@nongnu.org; Thu, 14 Jul 2016 00:11:45 -0400 Received: by mail-pa0-x244.google.com with SMTP id q2so3994343pap.0 for ; Wed, 13 Jul 2016 21:11:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=29WpJ7ypFVfobEd/obQNfq1SQYV4Vde7r7/l3UkHdL0=; b=qptFQgDmF/0zB3uen2Hc7Hb7cErl/rVGn4r6XIgvu0KaU8hA0GHTpnsxod+WFYxGW/ Qqw3IZF73AsCgPTbPMrIQ4thuTTYBOuN0/QdCWgtjTEcEx1Uagh3QBtnAg9dH+jbEUyZ /99Ce3b5fKKboMIzjGL7f3SpB1DgK7XiCYEFEr3oU+liOPiPUlcXVatJ3nllTeBZorss xFaYztlTR7RVvqm1rRAgaGwpJUzkh+69YXj7Z+B48eD/2ZMGpQHuGpF4EcA1IcNNWBm/ bxxXKXfZtLjeEaZrmZs7WR7DfxiyI1oRYIHyQjYbeJ09cM2DraOgQ0XDwI6sWqKSobm2 70QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=29WpJ7ypFVfobEd/obQNfq1SQYV4Vde7r7/l3UkHdL0=; b=AbZEwJno79Uvjxum+h62WvwMEJESqtGhOD9t+drgEXyTa6qlGmeKRlcWGR8eUTDdxD nJBHtFiSnuV/rqM8BgLA7Qi1Ixcrqln0nTqCPhP/MG2+FnbM+Nz32w87H4Oxdh4+2YXe ug9/Clqnvh8Ks995kaRthZ/7QYBDfxKOO8rPi/kkQQYz/pZ7dBUufTDbS2dpGPI/U+Pf Dv1LQmxJyXdEA/qEEzPpsRnWKR/ywoFRPK7rZhIQvfNknceP3+ZeAoUeuLsBm4Lc6oIQ N56m1mpQSodETFV699JH227OXUb/zbAOgZwEBlP0th8zB9kopPu4d68OqKSK311Pq1dn pqXA== X-Gm-Message-State: ALyK8tIKJlAryuyFdN/0vR5rH5jSbnggUTDwgi4zY0hap9weuS0Rk7V9Q7joX+CE33Kiwg== X-Received: by 10.66.7.199 with SMTP id l7mr19279786paa.136.1468469503948; Wed, 13 Jul 2016 21:11:43 -0700 (PDT) Received: from a0999b0126e1.ant.amazon.com (h194.236.133.40.static.ip.windstream.net. [40.133.236.194]) by smtp.gmail.com with ESMTPSA id e14sm6304557pfb.89.2016.07.13.21.11.41 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 13 Jul 2016 21:11:43 -0700 (PDT) From: Michael Rolnik To: qemu-devel@nongnu.org Date: Wed, 13 Jul 2016 21:10:56 -0700 Message-Id: <1468469461-18661-5-git-send-email-mrolnik@gmail.com> X-Mailer: git-send-email 2.4.9 (Apple Git-60) In-Reply-To: <1468469461-18661-1-git-send-email-mrolnik@gmail.com> References: <1468469461-18661-1-git-send-email-mrolnik@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c03::244 Subject: [Qemu-devel] [PATCH v11 4/9] target-avr: adding instructions encodings 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: peter.maydell@linaro.org, Michael Rolnik , rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Michael Rolnik --- target-avr/translate-inst.h | 805 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 805 insertions(+) create mode 100644 target-avr/translate-inst.h diff --git a/target-avr/translate-inst.h b/target-avr/translate-inst.h new file mode 100644 index 0000000..7114d83 --- /dev/null +++ b/target-avr/translate-inst.h @@ -0,0 +1,805 @@ +/* + * QEMU AVR CPU + * + * Copyright (c) 2016 Michael Rolnik + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + * + */ + +#ifndef AVR_TRANSLATE_INST_H_ +#define AVR_TRANSLATE_INST_H_ + +typedef struct DisasContext DisasContext; + +int avr_translate_NOP(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); + +int avr_translate_MOVW(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t MOVW_Rr(uint32_t opcode) +{ + return extract32(opcode, 0, 4); +} + +static inline uint32_t MOVW_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 4); +} + +int avr_translate_MULS(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t MULS_Rr(uint32_t opcode) +{ + return extract32(opcode, 0, 4); +} + +static inline uint32_t MULS_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 4); +} + +int avr_translate_MULSU(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t MULSU_Rr(uint32_t opcode) +{ + return extract32(opcode, 0, 3); +} + +static inline uint32_t MULSU_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 3); +} + +int avr_translate_FMUL(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t FMUL_Rr(uint32_t opcode) +{ + return extract32(opcode, 0, 3); +} + +static inline uint32_t FMUL_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 3); +} + +int avr_translate_FMULS(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t FMULS_Rr(uint32_t opcode) +{ + return extract32(opcode, 0, 3); +} + +static inline uint32_t FMULS_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 3); +} + +int avr_translate_FMULSU(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t FMULSU_Rr(uint32_t opcode) +{ + return extract32(opcode, 0, 3); +} + +static inline uint32_t FMULSU_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 3); +} + +int avr_translate_CPC(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t CPC_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +static inline uint32_t CPC_Rr(uint32_t opcode) +{ + return (extract32(opcode, 9, 1) << 4) | + (extract32(opcode, 0, 4)); +} + +int avr_translate_SBC(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t SBC_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +static inline uint32_t SBC_Rr(uint32_t opcode) +{ + return (extract32(opcode, 9, 1) << 4) | + (extract32(opcode, 0, 4)); +} + +int avr_translate_ADD(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t ADD_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +static inline uint32_t ADD_Rr(uint32_t opcode) +{ + return (extract32(opcode, 9, 1) << 4) | + (extract32(opcode, 0, 4)); +} + +int avr_translate_AND(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t AND_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +static inline uint32_t AND_Rr(uint32_t opcode) +{ + return (extract32(opcode, 9, 1) << 4) | + (extract32(opcode, 0, 4)); +} + +int avr_translate_EOR(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t EOR_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +static inline uint32_t EOR_Rr(uint32_t opcode) +{ + return (extract32(opcode, 9, 1) << 4) | + (extract32(opcode, 0, 4)); +} + +int avr_translate_OR(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t OR_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +static inline uint32_t OR_Rr(uint32_t opcode) +{ + return (extract32(opcode, 9, 1) << 4) | + (extract32(opcode, 0, 4)); +} + +int avr_translate_MOV(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t MOV_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +static inline uint32_t MOV_Rr(uint32_t opcode) +{ + return (extract32(opcode, 9, 1) << 4) | + (extract32(opcode, 0, 4)); +} + +int avr_translate_CPSE(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t CPSE_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +static inline uint32_t CPSE_Rr(uint32_t opcode) +{ + return (extract32(opcode, 9, 1) << 4) | + (extract32(opcode, 0, 4)); +} + +int avr_translate_CP(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t CP_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +static inline uint32_t CP_Rr(uint32_t opcode) +{ + return (extract32(opcode, 9, 1) << 4) | + (extract32(opcode, 0, 4)); +} + +int avr_translate_SUB(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t SUB_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +static inline uint32_t SUB_Rr(uint32_t opcode) +{ + return (extract32(opcode, 9, 1) << 4) | + (extract32(opcode, 0, 4)); +} + +int avr_translate_ADC(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t ADC_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +static inline uint32_t ADC_Rr(uint32_t opcode) +{ + return (extract32(opcode, 9, 1) << 4) | + (extract32(opcode, 0, 4)); +} + +int avr_translate_CPI(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t CPI_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 4); +} + +static inline uint32_t CPI_Imm(uint32_t opcode) +{ + return (extract32(opcode, 8, 4) << 4) | + (extract32(opcode, 0, 4)); +} + +int avr_translate_SBCI(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t SBCI_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 4); +} + +static inline uint32_t SBCI_Imm(uint32_t opcode) +{ + return (extract32(opcode, 8, 4) << 4) | + (extract32(opcode, 0, 4)); +} + +int avr_translate_ORI(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t ORI_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 4); +} + +static inline uint32_t ORI_Imm(uint32_t opcode) +{ + return (extract32(opcode, 8, 4) << 4) | + (extract32(opcode, 0, 4)); +} + +int avr_translate_SUBI(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t SUBI_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 4); +} + +static inline uint32_t SUBI_Imm(uint32_t opcode) +{ + return (extract32(opcode, 8, 4) << 4) | + (extract32(opcode, 0, 4)); +} + +int avr_translate_ANDI(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t ANDI_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 4); +} + +static inline uint32_t ANDI_Imm(uint32_t opcode) +{ + return (extract32(opcode, 8, 4) << 4) | + (extract32(opcode, 0, 4)); +} + +int avr_translate_LDDZ(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t LDDZ_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +static inline uint32_t LDDZ_Imm(uint32_t opcode) +{ + return (extract32(opcode, 13, 1) << 5) | + (extract32(opcode, 10, 2) << 3) | + (extract32(opcode, 0, 3)); +} + +int avr_translate_LDDY(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t LDDY_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +static inline uint32_t LDDY_Imm(uint32_t opcode) +{ + return (extract32(opcode, 13, 1) << 5) | + (extract32(opcode, 10, 2) << 3) | + (extract32(opcode, 0, 3)); +} + +int avr_translate_STDZ(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t STDZ_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +static inline uint32_t STDZ_Imm(uint32_t opcode) +{ + return (extract32(opcode, 13, 1) << 5) | + (extract32(opcode, 10, 2) << 3) | + (extract32(opcode, 0, 3)); +} + +int avr_translate_STDY(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t STDY_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +static inline uint32_t STDY_Imm(uint32_t opcode) +{ + return (extract32(opcode, 13, 1) << 5) | + (extract32(opcode, 10, 2) << 3) | + (extract32(opcode, 0, 3)); +} + +int avr_translate_LDS(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t LDS_Imm(uint32_t opcode) +{ + return extract32(opcode, 0, 16); +} + +static inline uint32_t LDS_Rd(uint32_t opcode) +{ + return extract32(opcode, 20, 5); +} + +int avr_translate_LDZ2(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t LDZ2_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_LDZ3(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t LDZ3_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_LPM2(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t LPM2_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_LPMX(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t LPMX_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_ELPM2(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t ELPM2_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_ELPMX(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t ELPMX_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_LDY2(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t LDY2_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_LDY3(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t LDY3_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_LDX1(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t LDX1_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_LDX2(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t LDX2_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_LDX3(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t LDX3_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_POP(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t POP_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_STS(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t STS_Imm(uint32_t opcode) +{ + return extract32(opcode, 0, 16); +} + +static inline uint32_t STS_Rd(uint32_t opcode) +{ + return extract32(opcode, 20, 5); +} + +int avr_translate_STZ2(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t STZ2_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_STZ3(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t STZ3_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_XCH(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t XCH_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_LAS(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t LAS_Rr(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_LAC(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t LAC_Rr(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_LAT(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t LAT_Rr(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_STY2(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t STY2_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_STY3(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t STY3_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_STX1(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t STX1_Rr(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_STX2(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t STX2_Rr(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_STX3(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t STX3_Rr(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_PUSH(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t PUSH_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_COM(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t COM_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_NEG(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t NEG_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_SWAP(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t SWAP_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_INC(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t INC_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_ASR(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t ASR_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_LSR(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t LSR_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_ROR(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t ROR_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_BSET(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t BSET_Bit(uint32_t opcode) +{ + return extract32(opcode, 4, 3); +} + +int avr_translate_IJMP(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); + +int avr_translate_EIJMP(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); + +int avr_translate_BCLR(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t BCLR_Bit(uint32_t opcode) +{ + return extract32(opcode, 4, 3); +} + +int avr_translate_RET(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); + +int avr_translate_RETI(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); + +int avr_translate_ICALL(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); + +int avr_translate_EICALL(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); + +int avr_translate_SLEEP(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); + +int avr_translate_BREAK(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); + +int avr_translate_WDR(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); + +int avr_translate_LPM1(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); + +int avr_translate_ELPM1(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); + +int avr_translate_SPM(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); + +int avr_translate_SPMX(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); + +int avr_translate_DEC(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t DEC_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_DES(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t DES_Imm(uint32_t opcode) +{ + return extract32(opcode, 4, 4); +} + +int avr_translate_JMP(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t JMP_Imm(uint32_t opcode) +{ + return (extract32(opcode, 20, 5) << 17) | + (extract32(opcode, 0, 17)); +} + +int avr_translate_CALL(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t CALL_Imm(uint32_t opcode) +{ + return (extract32(opcode, 20, 5) << 17) | + (extract32(opcode, 0, 17)); +} + +int avr_translate_ADIW(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t ADIW_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 2); +} + +static inline uint32_t ADIW_Imm(uint32_t opcode) +{ + return (extract32(opcode, 6, 2) << 4) | + (extract32(opcode, 0, 4)); +} + +int avr_translate_SBIW(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t SBIW_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 2); +} + +static inline uint32_t SBIW_Imm(uint32_t opcode) +{ + return (extract32(opcode, 6, 2) << 4) | + (extract32(opcode, 0, 4)); +} + +int avr_translate_CBI(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t CBI_Bit(uint32_t opcode) +{ + return extract32(opcode, 0, 3); +} + +static inline uint32_t CBI_Imm(uint32_t opcode) +{ + return extract32(opcode, 3, 5); +} + +int avr_translate_SBIC(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t SBIC_Bit(uint32_t opcode) +{ + return extract32(opcode, 0, 3); +} + +static inline uint32_t SBIC_Imm(uint32_t opcode) +{ + return extract32(opcode, 3, 5); +} + +int avr_translate_SBI(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t SBI_Bit(uint32_t opcode) +{ + return extract32(opcode, 0, 3); +} + +static inline uint32_t SBI_Imm(uint32_t opcode) +{ + return extract32(opcode, 3, 5); +} + +int avr_translate_SBIS(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t SBIS_Bit(uint32_t opcode) +{ + return extract32(opcode, 0, 3); +} + +static inline uint32_t SBIS_Imm(uint32_t opcode) +{ + return extract32(opcode, 3, 5); +} + +int avr_translate_MUL(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t MUL_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +static inline uint32_t MUL_Rr(uint32_t opcode) +{ + return (extract32(opcode, 9, 1) << 4) | + (extract32(opcode, 0, 4)); +} + +int avr_translate_IN(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t IN_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +static inline uint32_t IN_Imm(uint32_t opcode) +{ + return (extract32(opcode, 9, 2) << 4) | + (extract32(opcode, 0, 4)); +} + +int avr_translate_OUT(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t OUT_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +static inline uint32_t OUT_Imm(uint32_t opcode) +{ + return (extract32(opcode, 9, 2) << 4) | + (extract32(opcode, 0, 4)); +} + +int avr_translate_RJMP(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t RJMP_Imm(uint32_t opcode) +{ + return extract32(opcode, 0, 12); +} + +int avr_translate_LDI(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t LDI_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 4); +} + +static inline uint32_t LDI_Imm(uint32_t opcode) +{ + return (extract32(opcode, 8, 4) << 4) | + (extract32(opcode, 0, 4)); +} + +int avr_translate_RCALL(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t RCALL_Imm(uint32_t opcode) +{ + return extract32(opcode, 0, 12); +} + +int avr_translate_BRBS(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t BRBS_Bit(uint32_t opcode) +{ + return extract32(opcode, 0, 3); +} + +static inline uint32_t BRBS_Imm(uint32_t opcode) +{ + return extract32(opcode, 3, 7); +} + +int avr_translate_BRBC(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t BRBC_Bit(uint32_t opcode) +{ + return extract32(opcode, 0, 3); +} + +static inline uint32_t BRBC_Imm(uint32_t opcode) +{ + return extract32(opcode, 3, 7); +} + +int avr_translate_BLD(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t BLD_Bit(uint32_t opcode) +{ + return extract32(opcode, 0, 3); +} + +static inline uint32_t BLD_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_BST(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t BST_Bit(uint32_t opcode) +{ + return extract32(opcode, 0, 3); +} + +static inline uint32_t BST_Rd(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_SBRC(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t SBRC_Bit(uint32_t opcode) +{ + return extract32(opcode, 0, 3); +} + +static inline uint32_t SBRC_Rr(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +int avr_translate_SBRS(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); +static inline uint32_t SBRS_Bit(uint32_t opcode) +{ + return extract32(opcode, 0, 3); +} + +static inline uint32_t SBRS_Rr(uint32_t opcode) +{ + return extract32(opcode, 4, 5); +} + +#endif +