Added support for the STORE directive.
This commit is contained in:
+3
-1
@@ -9,4 +9,6 @@ something_insance:
|
||||
load r1, unknown_symbol
|
||||
load byte r1, r3
|
||||
load r1, 5
|
||||
load r3, r4
|
||||
load r3, r4
|
||||
store byte r3, r5
|
||||
store r5, r7
|
||||
+32
-1
@@ -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:
|
||||
|
||||
@@ -299,6 +299,14 @@ Token* ParseIdentifier(void) {
|
||||
|
||||
return token;
|
||||
}
|
||||
if (strcmp(lexeme, "store") == 0) {
|
||||
Token* token = CreateToken(Line, DirectiveClass);
|
||||
|
||||
token->Lemexe = lexeme;
|
||||
token->Value.Directive = Store;
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
Token* token = CreateToken(Line, IdentifierClass);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user