Skip to content

Commit

Permalink
Fix bug where data values less than 15 did not have two digits in output
Browse files Browse the repository at this point in the history
  • Loading branch information
tomdeakin committed Dec 2, 2020
1 parent 689c9f0 commit 59cc758
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions hex8asm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,10 @@ int main(int argc, char *argv[]) {
if (output.data == 0) {
hexOutput << "00 ";
std::cout << std::dec << outLineNum << ": DATA 0" << std::endl;
}
else {
} else if (output.data <= 0xF) {
hexOutput << std::hex << std::uppercase << "0" << (output.data & 0xF) << " ";
std::cout << std::dec << outLineNum << ": DATA " << std::hex << std::uppercase << (output.data & 0xFF) << std::endl;
} else {
hexOutput << std::hex << std::uppercase << (output.data & 0xFF) << " ";
std::cout << std::dec << outLineNum << ": DATA " << std::hex << std::uppercase << (output.data & 0xFF) << std::endl;
}
Expand Down

0 comments on commit 59cc758

Please sign in to comment.