Updated the parser to handle processing a simple load byte instruction. Added the LODB opcode to the opcode enum listing and updated the Scanner to look for 'byte' and mark it as a directive.

This commit is contained in:
2023-03-24 23:24:24 -05:00
parent f96e1c6380
commit 95ed2143ea
7 changed files with 131 additions and 24 deletions
+20 -8
View File
@@ -8,22 +8,38 @@
#include "../includes/scanner.h"
#include "../includes/parser.h"
List* LIST;
void print(void);
int main(int argc, char* args[]) {
if (argc == 1) {
printf("Usage: assm <file1.asm>\n");
return EX_USAGE;
}
atexit(print);
char* source_code;
size_t bytes_read;
if (!ReadAllString(args[1], &source_code, &bytes_read)) return EX_IOERR;
List* list = GenerateTokenList(source_code);
char mnemonic[12];
LIST = GenerateTokenList(source_code);
ParseTokens(LIST);
for(int i = 0; i < list->size; i++) {
Token* t = (Token*) list->content[i];
free(source_code);
}
void print(void) {
char mnemonic[12];
printf("printing tokens...\n");
for(int i = 0; i < LIST->size; i++) {
Token* t = (Token*) LIST->content[i];
if (t->EndOfFile) {
printf("EOF\n");
@@ -75,8 +91,4 @@ int main(int argc, char* args[]) {
printf("[C]'%s'", t->Lemexe);
}
}
ParseTokens(list);
free(source_code);
}