Skip to content

Commit

Permalink
Adjust Intel HEX parsing to be more forgiving
Browse files Browse the repository at this point in the history
  • Loading branch information
tiberiusbrown committed Jan 8, 2024
1 parent d7e4877 commit b767bd5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/absim_load_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,17 @@ static std::string load_hex(arduboy_t& a, std::istream& f)
a.breakpoints_wr.reset();

uint32_t addr_upper = 0;
uint32_t num_records = 0;

while(!f.eof())
{
while(f.get() != ':')
if(f.eof())
return "HEX: unexpected EOF";
while(!f.eof() && f.get() != ':')
;
if(f.eof())
break;
uint8_t checksum = 0;
int count = get_hex_byte(f);
++num_records;
if(count < 0)
return "HEX bad byte count";
checksum += (uint8_t)count;
Expand Down Expand Up @@ -264,6 +267,9 @@ static std::string load_hex(arduboy_t& a, std::istream& f)
return "HEX: bad checksum";
}

if(num_records == 0)
return "HEX: no records found";

cpu.decode();

find_stack_check(cpu);
Expand Down

0 comments on commit b767bd5

Please sign in to comment.