qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v12 09/14] target-mips: Add ASE DSP bit/manipula


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH v12 09/14] target-mips: Add ASE DSP bit/manipulation instructions
Date: Tue, 30 Oct 2012 15:44:16 +0100

On 30 October 2012 15:34, Jia Liu <address@hidden> wrote:
> On Mon, Oct 29, 2012 at 9:40 PM, Jovanovic, Petar <address@hidden> wrote:
>>> imm = (int16_t)(imm << 6) >> 6;
>>
>> result of a bitwise shift of a signed type and a negative vlaue is
>> implementation-defined, so you can not rely on that.
>>
>
> I think it will take a 10bits signed value sign extend into 16bits
> signed value, and I've tested it with negative values, it working
> well.

You cannot rely on the behaviour of a specific compiler implementation
as evidence that a piece of code is correct. C has a standard which
defines what is and is not valid.

Having said that, right shift of negative signed integers is one of
those bits of implementation defined behaviour which we allow ourselves
to rely on in QEMU because all the platforms we care about behave
that way. (That integers are 2s complement representation is another.)

-- PMM



reply via email to

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