devices/cpu/formatIII.c:decode_formatIII contains the following code:
int16_t signed_offset = (instruction & 0x03FF) * 2;
bool negative = signed_offset >> 9;
char value[20];
char mnemonic[100] = {0};
/* String to show hex value of instruction */
char hex_str[100] = {0};
sprintf(hex_str, "%04X", instruction);
if (negative) { /* Sign Extend for Arithmetic Operations */
signed_offset |= 0xF800;
}
The sign on bit 9 is tested after the offset is already multiplied by 2, without adjusting for the shift of one bit to the left, yielding an incorrectly negative value.
Multiplying the offset after the sign test and sign extension (with mask set to 0xFC00 to adjust) seems to work correctly and is more readable.
Jump +778 jumps backwards.
devices/cpu/formatIII.c:decode_formatIII contains the following code:
The sign on bit 9 is tested after the offset is already multiplied by 2, without adjusting for the shift of one bit to the left, yielding an incorrectly negative value.
Multiplying the offset after the sign test and sign extension (with mask set to 0xFC00 to adjust) seems to work correctly and is more readable.