Added .reserve to allocate static registers in scratch space without specifying hardcoded values (set to none or 0)
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
3f40ce34a9
commit
8a8ddfec22
|
@ -230,12 +230,29 @@ void Parser::parse() {
|
|||
}
|
||||
|
||||
if (!currentDeclaration.tokens.empty()) {
|
||||
if (currentDeclaration.tokens.size() >= 3 &&
|
||||
currentDeclaration.tokens.at(0).getType() == Token::Type::Directive) {
|
||||
|
||||
if (currentDeclaration.tokens.size() >= 2 && currentDeclaration.tokens.at(0).getType() == Token::Type::Directive && currentDeclaration.tokens.at(0).getTextValue() == ".reserve") {
|
||||
if (currentDeclaration.tokens.at(0).getTextValue() == ".reserve") {
|
||||
if(reservations.find(currentDeclaration.tokens.at(2).getNumericValue()) == reservations.end()){
|
||||
uint32_t addr = currentDeclaration.tokens.at(2).getNumericValue();
|
||||
uint32_t addr;
|
||||
bool foundValue = false;
|
||||
|
||||
if(currentDeclaration.tokens.size() == 2 || currentDeclaration.tokens.at(2).getNumericValue() == 0){
|
||||
uint32_t scratchSize = (uint32_t) MgmtRegisters::BSM_SCRATCH_END - (uint32_t) MgmtRegisters::BSM_SCRATCH_START;
|
||||
addr = 0;
|
||||
for(; addr <= scratchSize; ++addr){
|
||||
if(reservations.find(addr) == reservations.end()){
|
||||
//Found value!
|
||||
foundValue = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
addr = currentDeclaration.tokens.at(2).getNumericValue();
|
||||
foundValue = true;
|
||||
}
|
||||
|
||||
if(!foundValue){
|
||||
throw std::runtime_error("Could not find reservation " + currentDeclaration.tokens.at(1).getTextValue() + " for value " + std::to_string(addr));
|
||||
}else if(reservations.find(addr) == reservations.end()){
|
||||
reservations[addr] = currentDeclaration.tokens.at(1).getTextValue();
|
||||
variables[currentDeclaration.tokens.at(1).getTextValue()] = {Token(Token::Type::RegisterLocation, std::to_string((uint32_t) MgmtRegisters::BSM_SCRATCH_START + addr), (uint32_t) MgmtRegisters::BSM_SCRATCH_START + addr)};
|
||||
}else{
|
||||
|
@ -244,6 +261,9 @@ void Parser::parse() {
|
|||
}
|
||||
}
|
||||
|
||||
currentDeclaration = Declaration();
|
||||
currentStateIndex = 0;
|
||||
}else if (currentDeclaration.tokens.size() >= 3 && currentDeclaration.tokens.at(0).getType() == Token::Type::Directive) {
|
||||
if (currentDeclaration.tokens.at(0).getTextValue() == ".constant") {
|
||||
std::vector<Token> tokens;
|
||||
for (auto it = currentDeclaration.tokens.begin() + 2;
|
||||
|
|
Loading…
Reference in a new issue