qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] BUG: qemu-sh4 - shar does logical not arithmetic right shif


From: Dave Denholm
Subject: [Qemu-devel] BUG: qemu-sh4 - shar does logical not arithmetic right shift
Date: Sun, 13 Jan 2008 14:53:46 +0000
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.4 (gnu/linux)

Thiemo Seufer <address@hidden> writes:

(in May 2007)

> CVSROOT:      /sources/qemu
> Module name:  qemu
> Changes by:   Thiemo Seufer <ths>     07/05/13 16:35:36
>
> Modified files:
>       target-sh4     : op.c 
>
> Log message:
>       Remove unnecessary pointer magic in shift operations, by Magnus Damm.
>
> CVSWeb URLs:
> http://cvs.savannah.gnu.org/viewcvs/qemu/target-sh4/op.c?cvsroot=qemu&r1=1.4&r2=1.5
>

Hi,
   I'm just playing with qemu-sh4, and found that 'shar' seems to be doing
a logical right shift, rather than an arithmetic right shift.

I think that pointer magic was necessary after all.

In the current version of target-sh4/op.c, op_shar_Rn() and op_shlr_Rn() are 
identical,
which is surely wrong.

void OPPROTO op_shar_Rn(void)
{
    cond_t(env->gregs[PARAM1] & 1);
    env->gregs[PARAM1] >>= 1;
    RETURN();
}

void OPPROTO op_shlr_Rn(void)
{
    cond_t(env->gregs[PARAM1] & 1);
    env->gregs[PARAM1] >>= 1;
    RETURN();
}

The behaviour is consistent with  env->gregs[] being an array of unsigned ints,
(I'm not familiar with qemu details...) and so to get an arithmetic shift, some
kind of cast is necessary.

dd
-- 
Dave Denholm              <address@hidden>       http://www.esmertec.com




reply via email to

[Prev in Thread] Current Thread [Next in Thread]