Skip to contentSkip to conversation

qemu/target-sh4 op.c

Qemu-devel Thiemo Seufer 2 participants 2 messages May 13, 2007 – Jan 13, 2008

lore
Share & tools
lore
#1 lore raw

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

Thiemo Seufer <[email protected]> writes:

(in May 2007)

Quoted 4 lines

CVSROOT: /sources/qemu
Module name: qemu
Changes by: Thiemo Seufer <ths> 07/05/13 16:35:36

Quoted 9 lines

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

Signature · 1 line
Dave Denholm              <[email protected]>       http://www.esmertec.com