Bug: Cast to i16 was failing, casted unsigned char to sbyte before promoting
This commit is contained in:
parent
f4d6835694
commit
2a92f04836
5
decode.c
5
decode.c
@ -96,7 +96,8 @@ static inline char *reg_name(Register reg, char wide)
|
||||
|
||||
static inline i16 get_data(unsigned char* buf, char wide)
|
||||
{
|
||||
return wide == 1 ? (i16)buf[1] << 8 | buf[0] : buf[0];
|
||||
// Cast buf[0] to sbyte if not the conversion to i16 won't detect signedness
|
||||
return wide == 1 ? (i16)buf[1] << 8 | buf[0] : (sbyte)buf[0];
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
@ -153,7 +154,7 @@ int main(int argc, char** argv)
|
||||
if (bytes_to_read > 0)
|
||||
{
|
||||
i16 disp = get_data(buf, bytes_to_read - 1);
|
||||
if (disp > 0) sprintf(disp_buf, " %s %d", disp >= 0 ? "+" : "-", abs(disp));
|
||||
sprintf(disp_buf, " %s %hd", disp >= 0 ? "+" : "-", abs(disp));
|
||||
}
|
||||
Register reg = registers[reg_idx];
|
||||
if (d) printf("mov %s, [%s%s] ;1", reg_name(reg, w), eac_name, disp_buf);
|
||||
|
Loading…
x
Reference in New Issue
Block a user