Added support for the STORE directive.

This commit is contained in:
2023-03-29 12:57:07 -05:00
parent ee60d14570
commit 2e888913be
3 changed files with 43 additions and 2 deletions
+32 -1
View File
@@ -167,7 +167,38 @@ void HandleAssemblerDirective() {
break;
case Store:
{
AdvanceParser();
Token* next = PeekToken();
if (next->Class != DirectiveClass) {
//If the token after the current one is invalid then the expect function ahead will exit, so we can
//go ahead and change the STORE directive into a proper opcode here.
directive->Value.Mnemonic = STOW;
directive->Class = MnemonicClass;
directive->Lemexe = "STOW";
}
else {
if (next->Value.Directive != Byte) {
fprintf(stderr, "[Line %d] Syntax error, expected keyword 'byte'.\n", next->LineNumber);
exit(10);
}
RemoveCurrentToken(); //Remove byte modifier token.
AdvanceParser();
directive->Value.Mnemonic = STOB;
directive->Class = MnemonicClass;
directive->Lemexe = "STOB";
}
ExpectRegister();
ExpectPuncuation(Comma, ForwardParser);
ExpectRegister();
ExpectLineEndOrFileEnd(ForwardParser);
}
break;
default: