On 24 June 2014 10:50, Leon Alrae <leon.al...@imgtec.com> 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