mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
Fix bug in atoi_hex when uneven number of digits parsed
We fix a bug in atoi_hex when parsing an unneven number of digits by rotating the entire number 4 bits right as would have been done if the number had been preceded by a 0 to make the number of digits even.
This commit is contained in:
+9
-1
@@ -150,6 +150,14 @@ uint8_t atoi_hex(uint8_t idx)
|
||||
h_idx++;
|
||||
}
|
||||
|
||||
if (h_idx & 1) {
|
||||
hexvalue[h_idx >> 1] <<= 4;
|
||||
hexvalue[3] = hexvalue[3] >> 4 | (hexvalue[2] << 4);
|
||||
hexvalue[2] = hexvalue[2] >> 4 | (hexvalue[1] << 4);
|
||||
hexvalue[1] = hexvalue[1] >> 4 | (hexvalue[0] << 4);
|
||||
hexvalue[0] >>= 4;
|
||||
}
|
||||
|
||||
return ((h_idx + 1) >> 1);
|
||||
}
|
||||
|
||||
@@ -707,7 +715,7 @@ void parse_bw(void)
|
||||
goto err;
|
||||
|
||||
port = cmd_buffer[cmd_words_b[2]] - '1';
|
||||
if (port < 0 || port > 9)
|
||||
if (port > 9)
|
||||
goto err;
|
||||
|
||||
port = machine.phys_to_log_port[port];
|
||||
|
||||
Reference in New Issue
Block a user