Skip to content

Commit

Permalink
fix instruction length parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
bbrk24 committed Sep 29, 2024
1 parent 5c1bf57 commit bf6eb51
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/assembly_scanner.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "assembly_scanner.hh"
#include <cinttypes>
#include <cstring>
#include <iostream>
#include <set>

Expand Down Expand Up @@ -112,6 +113,10 @@ NONNULL_PTR(const std::vector<NONNULL_PTR(std::vector<instruction>)>) assembly_s
cerr << "Instruction too short: " << curr_line << endl;
exit(EXIT_FAILURE);
}
if (curr_line.size() > 3 && !strchr(WHITESPACE, curr_line[3])) {
cerr << "Instruction too long: " << curr_line << endl;
exit(EXIT_FAILURE);
}

string instruction_name = curr_line.substr(0, 3);
instruction::operation opcode = assembly_scanner::opcode_for_name(instruction_name);
Expand Down

0 comments on commit bf6eb51

Please sign in to comment.