qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: Laurent Vivier <laurent@vivier.eu>, qemu-devel@nongnu.org
Cc: schwab@linux-m68k.org, agraf@suse.de, gerg@uclinux.org
Subject: Re: [Qemu-devel] [PATCH v2 2/3] target-m68k: implement 680x0 movem
Date: Thu, 3 Nov 2016 14:45:41 -0600	[thread overview]
Message-ID: <0bfd0d51-3fe9-88bc-5a7d-df9fa7413c99@twiddle.net> (raw)
In-Reply-To: <ac208048-7bb7-9804-e755-578cd5612737@vivier.eu>

On 11/03/2016 02:11 PM, Laurent Vivier wrote:
> Le 03/11/2016 à 20:47, Richard Henderson a écrit :
>> On 11/02/2016 03:15 PM, Laurent Vivier wrote:
>>> +                    if ((insn & 7) + 8 == i &&
>>> +                        m68k_feature(s->env, M68K_FEATURE_EXT_FULL)) {
>>> +                        /* M68020+: if the addressing register is the
>>> +                         * register moved to memory, the value written
>>> +                         * is the initial value decremented by the
>>> size of
>>> +                         * the operation
>>> +                         * M68000/M68010: the value is the initial value
>>> +                         */
>>> +                        TCGv tmp = tcg_temp_new();
>>> +                        tcg_gen_sub_i32(tmp, mreg(i), incr);
>>> +                        gen_store(s, opsize, addr, tmp);
>>> +                        tcg_temp_free(tmp);
>>
>> This doesn't look right.  Is the value stored the intermediate value of
>> the decremented register, or the final value?  What you're storing is
>> reg-4, which is neither of these things.
>>
>> I could see, maybe, that reg-4 might well turn out to be the right value
>> for
>>
>>     movem    {a0-a7}, (sp)-
>>
>> since sp == a7, and therefore stored first.  But I question that's the
>> correct result for
>>
>>     movem    {a0-a7}, (a1)-
>>
>> If it's the incremental value, then you can just store "addr" and you
>> don't need a temp.  If it's the final value, then you can compute
>>
>>     tcg_gen_subi_i32(tmp, AREG(insn, 0), ctpop32(mask) * 4);
>>
>
> As it was not clear for me, I have written a test to see what was the
> good value.
>
> my test program is:
>
> top:
>         .space 64,0
> stack:
>         .text
>         .globl _start
> _start:
>         lea stack,%a4
>         lea 1,%a0
>         lea 2,%a1
>         lea 3,%a2
>         lea 4,%a3
>         lea 5,%a5
>         lea 6,%a6
>         moveq.l #8, %d0
>         moveq.l #9, %d1
>         moveq.l #10, %d2
>         moveq.l #11, %d3
>         moveq.l #12, %d4
>         moveq.l #13, %d5
>         moveq.l #14, %d6
>         moveq.l #15, %d7
>         movem.l %a0-%a7/%d0-%d7,-(%a4)
>
> on a real 68040:
>
> initial value of A4 is 0x800020ec
> final value of A4 is   0x800020ac
>
> (gdb) x/15x 0x800020ac
> 0x800020ac: 0x00000008	0x00000009	0x0000000a	0x0000000b
> 0x800020bc: 0x0000000c	0x0000000d	0x0000000e	0x0000000f
> 0x800020cc: 0x00000001	0x00000002	0x00000003	0x00000004
> 0x800020dc: 0x800020e8	0x00000005	0x00000006
>
> Stored value is thus 0x800020e8 so this is initial value - 4.
> [I have tried the same test with a1, for the same result]

Weird.  But, ok.


r~

  reply	other threads:[~2016-11-03 20:46 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-02 21:15 [Qemu-devel] [PATCH v2 0/3] target-m68k: add movem, BCD and CAS instructions Laurent Vivier
2016-11-02 21:15 ` [Qemu-devel] [PATCH v2 1/3] target-m68k: add abcd/sbcd/nbcd Laurent Vivier
2016-11-03 16:16   ` Richard Henderson
2016-11-02 21:15 ` [Qemu-devel] [PATCH v2 2/3] target-m68k: implement 680x0 movem Laurent Vivier
2016-11-03 16:17   ` Richard Henderson
2016-11-03 19:47   ` Richard Henderson
2016-11-03 20:11     ` Laurent Vivier
2016-11-03 20:45       ` Richard Henderson [this message]
2016-11-03 20:47   ` Richard Henderson
2016-11-04  7:59     ` Laurent Vivier
2016-11-04 12:27       ` Richard Henderson
2016-11-02 21:15 ` [Qemu-devel] [PATCH v2 3/3] target-m68k: add cas/cas2 ops Laurent Vivier
2016-11-03 16:36   ` Richard Henderson
2016-11-03 18:03     ` Laurent Vivier
2016-11-03 19:20       ` Richard Henderson

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=0bfd0d51-3fe9-88bc-5a7d-df9fa7413c99@twiddle.net \
    --to=rth@twiddle.net \
    --cc=agraf@suse.de \
    --cc=gerg@uclinux.org \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    --cc=schwab@linux-m68k.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).