This feels like a trainwreck but eh. Changed the way the opcodes are managed. Hopefully this is the right direction when I add support for multiple ASM files.
This commit is contained in:
+2
-1
@@ -6,6 +6,7 @@
|
||||
|
||||
#define OPCODECOUNT 13
|
||||
#define REGISTERCOUNT 8
|
||||
//const unsigned char COPYADDRESSMASK = 0x80;
|
||||
|
||||
typedef struct {
|
||||
char* lexeme;
|
||||
@@ -25,6 +26,6 @@ extern Register registers[REGISTERCOUNT];
|
||||
int IsOpcode(const char*, TokenType*);
|
||||
int IsRegister(const char*, TokenType*);
|
||||
const Instruction* GetOpcodeDetails(TokenType);
|
||||
unsigned char GetInstructionMask(TokenType type, TokenClass parameterOneType);
|
||||
unsigned char GetInstructionMask(TokenType type);
|
||||
|
||||
#endif
|
||||
+30
-1
@@ -1,6 +1,7 @@
|
||||
#ifndef PARSER_H
|
||||
#define PARSER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "list.h"
|
||||
@@ -9,6 +10,34 @@
|
||||
|
||||
#define HIGHMEMORY 65535 //64KiB - 1 AKA 0xFFFF
|
||||
|
||||
unsigned char* ParseTokens(List*);
|
||||
typedef struct {
|
||||
Token* token;
|
||||
//unsigned char terminatingByte;
|
||||
int address;
|
||||
int resolved;
|
||||
} Symbol;
|
||||
|
||||
typedef struct {
|
||||
TokenType Mnemonic;
|
||||
TokenClass ParameterOneType;
|
||||
TokenClass ParameterTwoType;
|
||||
|
||||
union {
|
||||
uint16_t Constant;
|
||||
Symbol* Address;
|
||||
} ParameterOne;
|
||||
|
||||
union {
|
||||
uint16_t Constant;
|
||||
Symbol* Address;
|
||||
} ParameterTwo;
|
||||
} IROpcode;
|
||||
|
||||
typedef struct {
|
||||
List* Opcodes;
|
||||
List* SymbolsTable;
|
||||
} IRState;
|
||||
|
||||
IRState* ParseTokens(List*);
|
||||
|
||||
#endif
|
||||
+1
-1
@@ -26,7 +26,7 @@ typedef enum {
|
||||
LineEnd,
|
||||
//Keywords
|
||||
DB, ORG,
|
||||
//Opcodes
|
||||
//Mnemonics
|
||||
COPY, ADD, SUB, JZ, INT, YLD, RET,
|
||||
CMP, NOP, JMP, CALL, IN, OUT,
|
||||
//Registers
|
||||
|
||||
Reference in New Issue
Block a user