summaryrefslogtreecommitdiff
path: root/opcode.h
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2020-04-09 02:06:50 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2020-04-09 02:06:50 -0400
commitc5150ee31f07208422f1435de9b35a0d0168cbb5 (patch)
tree78150bf0339cf81401c00973f96c94a3c231015e /opcode.h
parent59dc46ca8fe1eb6f98abb98fe8579aeaedd2ff15 (diff)
Completely changed the assembler.
It now has a lexer/tokenizer, along with a parser. I have also made the emulator even smaller.
Diffstat (limited to 'opcode.h')
-rw-r--r--opcode.h50
1 files changed, 25 insertions, 25 deletions
diff --git a/opcode.h b/opcode.h
index 47fe125..c92ee67 100644
--- a/opcode.h
+++ b/opcode.h
@@ -213,22 +213,7 @@ struct sux {
uint8_t crt; /* Current running threads. */
};
-typedef struct {
- char mnemonic[4];
- uint8_t imm;
- uint8_t abs;
- uint8_t zm;
- uint8_t zmy;
- uint8_t zmx;
- uint8_t ind;
- uint8_t inx;
- uint8_t iny;
- uint8_t impl;
-} opent;
-
-opent opcodes[OPNUM];
-
-enum {IMPL, IMM, ZM, ZMX, ZMY, ABS, IND, INDX, INDY};
+enum {IMM, ZM, ZMX, ZMY, IND, INDX, INDY, ABS, IMPL};
enum {
DIR_ORG,
DIR_BYTE,
@@ -241,8 +226,11 @@ enum {
TOK_DIR,
TOK_LABEL,
TOK_SYM,
+ TOK_PLUS,
+ TOK_MINUS,
TOK_STRING,
TOK_CHAR,
+ TOK_IMM,
TOK_OPCODE,
TOK_RS,
TOK_COMMENT,
@@ -257,16 +245,28 @@ enum {
BASE_BIN
};
+
+static const uint8_t adrsize[8] = {
+ [0] = 0,
+ [1] = 2,
+ [2] = 5,
+ [3] = 3,
+ [4] = 1,
+ [5] = 4,
+ [6] = 6,
+ [7] = 7
+};
+
static const char *adrmode[9] = {
- [0] = "IMPL",
- [1] = "IMM",
- [2] = "ZM",
- [3] = "ZMX",
- [4] = "ZMY",
- [5] = "ABS",
- [6] = "IND",
- [7] = "INDX",
- [8] = "INDY"
+ [IMM ] = "IMM",
+ [ZM ] = "ZM",
+ [ZMX ] = "ZMX",
+ [ZMY ] = "ZMY",
+ [IND ] = "IND",
+ [INDX] = "INDX",
+ [INDY] = "INDY",
+ [ABS ] = "ABS",
+ [IMPL] = "IMPL"
};
static const uint8_t optype[0x100] = {