From: Laurent Vivier <laurent@vivier.eu>
To: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>, qemu-devel@nongnu.org
Cc: dovgaluk@ispras.ru
Subject: Re: [Qemu-devel] [PATCH] m68k: implement movep instruction
Date: Tue, 6 Feb 2018 12:19:34 +0100 [thread overview]
Message-ID: <edbe6648-476d-73fb-2a54-c7f55c7b4a21@vivier.eu> (raw)
In-Reply-To: <20180206095603.26500.5959.stgit@pasha-VirtualBox>
Le 06/02/2018 à 10:56, Pavel Dovgalyuk a écrit :
> 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 <pavel.dovgaluk@ispras.ru>
> Signed-off-by: Mihail Abakumov <mikhail.abakumov@ispras.ru>
> ---
> target/m68k/translate.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 53 insertions(+)
>
> diff --git a/target/m68k/translate.c b/target/m68k/translate.c
> index f0e86a7..a849c74 100644
> --- a/target/m68k/translate.c
> +++ b/target/m68k/translate.c
> @@ -2071,6 +2071,55 @@ DISAS_INSN(movem)
> tcg_temp_free(addr);
> }
>
> +DISAS_INSN(movep)
> +{
> + uint8_t i;
> + uint8_t op;
> + uint16_t displ;
> + TCGv reg;
> + TCGv addr;
> + TCGv abuf;
> + TCGv dbuf;
> +
> + op = (insn >> 6) & 7;
> + displ = read_im16(env, s);
I think displacement can be negative (see gen_lea_indexed()):
uint32_t displ = (int16_t)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 (op & 1) {
insn & 0x40
perhaps we don't need "op"?
> + i = 4;
> + } else {
> + i = 2;
> + }
> +
> + if (op & 2) {
insn & 0x80
> + for ( ; i > 0 ; i--) {> + tcg_gen_shri_i32(dbuf, reg, (i - 1) * 8);
> + gen_store(s, OS_BYTE, abuf, dbuf);
You can use directly tcg_gen_qemu_st8()
> + if (i > 1) {
> + tcg_gen_addi_i32(abuf, abuf, 2);
> + }
> + }
> + } else {
> + tcg_gen_movi_i32(reg, 0);
I don't think we should clear the part we don't update.
> + for ( ; i > 0 ; i--) {
> + dbuf = gen_load(s, OS_BYTE, abuf, 1);
You can use directly tcg_gen_qemu_ld8u()
> + tcg_gen_or_i32(reg, reg, dbuf);
you can use tcg_gen_deposit_i32().
> + if (i > 1) {
> + tcg_gen_shli_i32(reg, reg, 8);
useless with deposit.
> + tcg_gen_addi_i32(abuf, abuf, 2);
> + }
> + }
> + }
> + tcg_temp_free(abuf);
> + tcg_temp_free(dbuf);
> +}
> +
> DISAS_INSN(bitop_im)
> {
> int opsize;
> @@ -5579,9 +5628,13 @@ void register_m68k_insns (CPUM68KState *env)
> INSN(chk2, 00c0, f9c0, CHK2);
> INSN(bitrev, 00c0, fff8, CF_ISA_APLUSC);
> BASE(bitop_reg, 0100, f1c0);
> + BASE(movep, 0108, f1f8);
> BASE(bitop_reg, 0140, f1c0);
> + BASE(movep, 0148, f1f8);
> BASE(bitop_reg, 0180, f1c0);
> + BASE(movep, 0188, f1f8);
> BASE(bitop_reg, 01c0, f1c0);
> + BASE(movep, 01c8, f1f8);
> INSN(arith_im, 0280, fff8, CF_ISA_A);
> INSN(arith_im, 0200, ff00, M68000);
> INSN(undef, 02c0, ffc0, M68000);
>
You should try only one (movep, 0108, f138) after the last bitop_reg.
And as Thomas said, you need a new feature.
Thanks,
Laurent
prev parent reply other threads:[~2018-02-06 11:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-06 9:56 [Qemu-devel] [PATCH] m68k: implement movep instruction Pavel Dovgalyuk
2018-02-06 10:06 ` no-reply
2018-02-06 10:20 ` Laurent Vivier
2018-02-06 10:14 ` Thomas Huth
2018-02-06 10:23 ` no-reply
2018-02-06 11:19 ` Laurent Vivier [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=edbe6648-476d-73fb-2a54-c7f55c7b4a21@vivier.eu \
--to=laurent@vivier.eu \
--cc=Pavel.Dovgaluk@ispras.ru \
--cc=dovgaluk@ispras.ru \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).