Add shift offset support via <
Some checks reported errors
continuous-integration/drone/push Build was killed
Some checks reported errors
continuous-integration/drone/push Build was killed
This commit is contained in:
parent
525eb6d799
commit
38ba3ceb45
|
@ -155,7 +155,17 @@ void Parser::parse() {
|
|||
if (isOffset(currentValue) && !currentDeclaration.tokens.empty()) {
|
||||
auto& prevValue = currentDeclaration.tokens.at(currentDeclaration.tokens.size() - 1);
|
||||
if(prevValue.getType() == Token::Type::Immediate || prevValue.getType() == Token::Type::CodeLabel || prevValue.getType() == Token::Type::CodeLocation || prevValue.getType() == Token::Type::RegisterLocation){
|
||||
prevValue.valueImmediate += std::stoi(currentValue, nullptr, 0);
|
||||
auto s = currentValue.at(0);
|
||||
if(s == '+'){
|
||||
prevValue.valueImmediate += std::stoi(currentValue.substr(1), nullptr, 0);
|
||||
}else if(s == '-'){
|
||||
prevValue.valueImmediate -= std::stoi(currentValue.substr(1), nullptr, 0);
|
||||
}else if(s == '<'){
|
||||
prevValue.valueImmediate <<= std::stoi(currentValue.substr(1), nullptr, 0);
|
||||
}else {
|
||||
prevValue.valueImmediate += std::stoi(currentValue, nullptr, 0);
|
||||
}
|
||||
|
||||
}else{
|
||||
throw std::runtime_error("Cannot apply Offset to value not numeric");
|
||||
}
|
||||
|
@ -329,7 +339,7 @@ bool Parser::isLabel(const std::string &v) {
|
|||
}
|
||||
|
||||
bool Parser::isOffset(const std::string &v) {
|
||||
return v.size() >= 2 && (v.at(0) == '+' || v.at(0) == '-') && isIteratorAllowedValues(v.begin() + 1, v.end(), getNumericValues());
|
||||
return v.size() >= 2 && (v.at(0) == '+' || v.at(0) == '-' || v.at(0) == '<') && isIteratorAllowedValues(v.begin() + 1, v.end(), getNumericValues());
|
||||
}
|
||||
|
||||
bool Parser::isDirective(const std::string &v) {
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
|
||||
Immediate, // {32-bit unsigned integer} , example: 0, 1234, 0x1234
|
||||
|
||||
Offset, // {+-}{32-bit unsigned integer}, will apply to previous value
|
||||
Offset, // {+-<}{32-bit unsigned integer}, will apply to previous value
|
||||
|
||||
AsValue, // &
|
||||
AsIndirect, // *
|
||||
|
|
Loading…
Reference in a new issue