From: NIIBE Y. <gn...@m1...> - 2001-12-22 09:15:10
|
Jeremy Siegel wrote: > > We want something like "ext.b" or "ext.w" (of SuperH assembler) here. > > In general, it's not good practice using type coercion to do the > > calculation. > > Not sure I understand... would you prefer explicit asm statements rather > than forcing the ext type using casts? My words were poor. Sorry about the confusion. For the caluculation of sign extention, I think that using type coercion is not looks good, because it is implicit and hard to read. I don't think using asm statement is good, either. (At that time, the term "sign extention" was not in my brain but the instruction "ext.b" and "ext.w" were there.) Something like following (with comment) looks better: /* Use type coersion to get sign extention */ #define SH4_PC_OFFSET_WORD(X) ((((signed short)((X)<<4))>>3) + 4) ... regs->pc += SH4_PC_OFFSET_WORD(instruction); It would be good we could avoid type coersion, but I dont' have good alternative... -- |