Received: from eggs.gnu.org ([2001:4830:134:3::10]:39381) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzNX4-0007Lt-RH for qemu-devel@nongnu.org; Tue, 24 Jun 2014 06:01:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WzNWz-0007M2-OK for qemu-devel@nongnu.org; Tue, 24 Jun 2014 06:00:54 -0400 Received: from mail-lb0-f181.google.com ([209.85.217.181]:52510) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzNWz-0007Lw-He for qemu-devel@nongnu.org; Tue, 24 Jun 2014 06:00:49 -0400 Received: by mail-lb0-f181.google.com with SMTP id p9so66760lbv.40 for ; Tue, 24 Jun 2014 03:00:48 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <53A949D5.3040805@imgtec.com> References: <1402499992-64851-1-git-send-email-leon.alrae@imgtec.com> <1402499992-64851-15-git-send-email-leon.alrae@imgtec.com> <20140620205028.GB13921@ohm.rr44.fr> <53A949D5.3040805@imgtec.com> From: Peter Maydell Date: Tue, 24 Jun 2014 11:00:28 +0100 Message-ID: Content-Type: text/plain; charset=UTF-8 Subject: Re: [Qemu-devel] [PATCH v2 14/22] target-mips: add Addressing and PC-relative instructions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Leon Alrae Cc: yongbok.kim@imgtec.com, cristian.cuna@imgtec.com, QEMU Developers , Aurelien Jarno , Richard Henderson On 24 June 2014 10:50, Leon Alrae 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