From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34876) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c2Otb-00055r-Mb for qemu-devel@nongnu.org; Thu, 03 Nov 2016 16:46:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c2OtX-0003KB-AD for qemu-devel@nongnu.org; Thu, 03 Nov 2016 16:45:59 -0400 Received: from mail-oi0-x243.google.com ([2607:f8b0:4003:c06::243]:34357) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c2OtX-0003Jl-1F for qemu-devel@nongnu.org; Thu, 03 Nov 2016 16:45:55 -0400 Received: by mail-oi0-x243.google.com with SMTP id 62so8772443oif.1 for ; Thu, 03 Nov 2016 13:45:54 -0700 (PDT) Sender: Richard Henderson References: <1478121319-31986-1-git-send-email-laurent@vivier.eu> <1478121319-31986-3-git-send-email-laurent@vivier.eu> <3a298435-672c-47ec-26d0-8b1cb78500dc@twiddle.net> From: Richard Henderson Message-ID: <0bfd0d51-3fe9-88bc-5a7d-df9fa7413c99@twiddle.net> Date: Thu, 3 Nov 2016 14:45:41 -0600 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH v2 2/3] target-m68k: implement 680x0 movem List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laurent Vivier , qemu-devel@nongnu.org Cc: schwab@linux-m68k.org, agraf@suse.de, gerg@uclinux.org 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~