From d5c8460e83dcfee92226b8f1280971d51306a5f6 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Thu, 10 Jun 2021 21:37:02 -0600 Subject: [PATCH] Support labels + offset in translation --- src/6502-c++.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/6502-c++.cpp b/src/6502-c++.cpp index 9834af6..90059c6 100644 --- a/src/6502-c++.cpp +++ b/src/6502-c++.cpp @@ -1137,6 +1137,18 @@ std::vector run(const Personality &personality, std::istream &input, co } } + if (const auto plus = i.operand1.value.find('+'); plus != std::string::npos) + { + const auto str = i.operand1.value.substr(0, plus); + const auto itr1 = new_labels.find(str); + if (itr1 != new_labels.end()) { i.operand1.value.replace(0, plus, itr1->second); } + } + if (const auto plus = i.operand2.value.find('+'); plus != std::string::npos) { + const auto str = i.operand2.value.substr(0, plus); + const auto itr1 = new_labels.find(str); + if (itr1 != new_labels.end()) { i.operand2.value.replace(0, plus, itr1->second); } + } + const auto itr1 = new_labels.find(i.operand1.value); if (itr1 != new_labels.end()) { i.operand1.value = itr1->second; }