From c5150ee31f07208422f1435de9b35a0d0168cbb5 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Thu, 9 Apr 2020 02:06:50 -0400 Subject: Completely changed the assembler. It now has a lexer/tokenizer, along with a parser. I have also made the emulator even smaller. --- opcode.h | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'opcode.h') 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] = { -- cgit v1.2.3-13-gbd6f