qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2 14/22] target-mips: add Addressing and PC-rel


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH v2 14/22] target-mips: add Addressing and PC-relative instructions
Date: Tue, 24 Jun 2014 11:00:28 +0100

On 24 June 2014 10:50, Leon Alrae <address@hidden> wrote:
> On 20/06/2014 21:50, Aurelien Jarno wrote:
>> I do wonder if we shouldn't use sextract32() instead of open coding that
>> now that it is available:
>>
>>                offset = sextract32(ctx->opcode, 0, 19) << 3;
>
> This looks better, thanks for the suggestion (but since the offset's
> size is 18, third argument will be 18, not 19).

This is undefined behaviour in C because of the shift into
the sign bit. Better to shift first and then signextend:

    offset = sextract32(ctx->opcode << 3, 0, 21);

thanks
-- PMM



reply via email to

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