mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
cmd_parser: Improve atoi_byte() and atoi_short().
Because no memory type is specified to the reference location, sdcc is using a helper function to access the location. But sdcc is using a register to tell the helper function which memory-type is used. This registers must also be preseved until all access to that location is done.
This commit is contained in:
+11
-8
@@ -169,30 +169,33 @@ uint8_t atoi_hex(uint8_t idx)
|
||||
}
|
||||
|
||||
|
||||
uint8_t atoi_byte(register uint8_t *out, register uint8_t idx)
|
||||
uint8_t atoi_byte(uint8_t __xdata *out, uint8_t idx)
|
||||
{
|
||||
__xdata uint8_t err = 1;
|
||||
*out = 0;
|
||||
uint8_t err = 1;
|
||||
uint8_t num = 0;
|
||||
|
||||
while (isnumber(cmd_buffer[idx])) {
|
||||
err = 0;
|
||||
*out = (*out * 10) + cmd_buffer[idx] - '0';
|
||||
num = (num * 10) + cmd_buffer[idx] - '0';
|
||||
idx++;
|
||||
}
|
||||
|
||||
*out = num;
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
uint8_t atoi_short(register uint16_t *vlan, register uint8_t idx)
|
||||
uint8_t atoi_short(uint16_t __xdata *vlan, uint8_t idx)
|
||||
{
|
||||
__xdata uint8_t err = 1;
|
||||
*vlan = 0;
|
||||
uint8_t err = 1;
|
||||
|
||||
while (isnumber(cmd_buffer[idx])) {
|
||||
err = 0;
|
||||
*vlan = (*vlan * 10) + cmd_buffer[idx] - '0';
|
||||
uint8_t val = cmd_buffer[idx] - '0';
|
||||
*vlan = (*vlan * 10) + val;
|
||||
idx++;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user