summaryrefslogtreecommitdiff
path: root/asmmon.h
diff options
context:
space:
mode:
Diffstat (limited to 'asmmon.h')
-rw-r--r--asmmon.h166
1 files changed, 131 insertions, 35 deletions
diff --git a/asmmon.h b/asmmon.h
index 6f4e5f5..7ed879b 100644
--- a/asmmon.h
+++ b/asmmon.h
@@ -4,17 +4,18 @@
#define MAX_TOK 0x1000
-typedef struct tok token ;
-typedef struct ln line ;
-typedef struct sym symbol ;
-typedef struct fix fixup ;
-typedef struct inst instruction;
+typedef struct tok token ;
+typedef struct ln line ;
+typedef struct sym symbol ;
+typedef struct fix fixup ;
+typedef struct inst instruction ;
struct tok {
- token *next; /* Pointer to the next token. */
- uint8_t id; /* Token ID. */
- uint8_t type; /* Token type ID. */
+ token *next; /* Pointer to the next token. */
+ uint8_t id; /* Token ID. */
+ uint8_t type; /* Token type ID. */
+ uint8_t subtype; /* Token subtype ID. */
uint8_t tab; /* Number of tabs. */
uint8_t space; /* Number of spaces. */
@@ -118,6 +119,11 @@ enum token {
TOK_BREG,
TOK_OPCODE,
TOK_EXTOP,
+ TOK_ORTHO,
+ TOK_REG,
+ TOK_MEM,
+ TOK_CC,
+ TOK_OS,
TOK_RS,
TOK_OF,
TOK_COMMENT,
@@ -128,7 +134,6 @@ enum token {
TOK_STRUCT,
TOK_UNION,
TOK_MEMBER
-
};
enum pre_token {
@@ -150,6 +155,11 @@ enum pre_token {
PTOK_Y,
PTOK_S,
PTOK_P,
+ PTOK_A,
+ PTOK_C,
+ PTOK_D,
+ PTOK_F,
+ PTOK_R,
PTOK_DQUOTE,
PTOK_SQUOTE,
PTOK_HASH,
@@ -169,6 +179,7 @@ enum expr {
EXPR_OR,
EXPR_LSHFT,
EXPR_RSHFT,
+ EXPR_MUL,
EXPR_NONE
};
@@ -193,6 +204,8 @@ enum addrmode {
AM_AIND = (1 << 17),
AM_AINDY = (1 << 18),
AM_AINDX = (1 << 19),
+ AM_ORTHO = (1 << 20),
+ AM_ORTHO2 = (1 << 21)
};
enum ind {
@@ -231,6 +244,30 @@ enum eind {
CPY_EIND
};
+enum baseext_ortho {
+ OP_LEA,
+ OP_PEA,
+ OP_ADD,
+ OP_SUB,
+ OP_NOT,
+ OP_CLZ,
+ OP_CLO,
+ OP_SWP,
+ OP_PCN
+};
+
+static const uint8_t ext_ortho_ops[9] = {
+ [OP_LEA] = 0x63,
+ [OP_PEA] = 0x0C,
+ [OP_ADD] = 0x03,
+ [OP_SUB] = 0x23,
+ [OP_NOT] = 0x44,
+ [OP_CLZ] = 0xC4,
+ [OP_CLO] = 0xE4,
+ [OP_SWP] = 0x2C,
+ [OP_PCN] = 0x43
+};
+
static const uint8_t ind_ops[20] = {
[CMP_IND] = CMP_IN,
[CMP_IDY] = CMP_IY,
@@ -268,9 +305,9 @@ static const uint8_t eind_base_ops[10] = {
};
static const instruction inst[OPNUM] = {
- [ADC] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG|AM_EIND), 0x01},
- [AND] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG|AM_EIND), 0x41},
- [ASR] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG|AM_EIND), 0x62},
+ [ADC] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG|AM_EIND|AM_ORTHO), 0x01},
+ [AND] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG|AM_EIND|AM_ORTHO), 0x41},
+ [ASR] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG|AM_EIND|AM_ORTHO), 0x62},
[BCC] = {(AM_REL), 0xA0},
[BCS] = {(AM_REL), 0x90},
[BEQ] = {(AM_REL), 0xB0},
@@ -284,18 +321,18 @@ static const instruction inst[OPNUM] = {
[CLC] = {(AM_IMPL), 0x09},
[CLI] = {(AM_IMPL), 0x29},
[CLV] = {(AM_IMPL), 0x49},
- [CMP] = {(AM_IMM|AM_ZM|AM_IND|AM_INDY|AM_ABS|AM_BREG|AM_INDX2|AM_EIND), 0x82},
+ [CMP] = {(AM_IMM|AM_ZM|AM_IND|AM_INDY|AM_ABS|AM_BREG|AM_INDX2|AM_EIND|AM_ORTHO), 0x82},
[CPB] = {(AM_IMM|AM_ZM|AM_IND|AM_INDY|AM_ABS|AM_INDX2|AM_EIND2), 0x04},
[CPS] = {(AM_IMPL), 0x00},
[CPX] = {(AM_IMM|AM_ZM|AM_IND|AM_ABS|AM_EIND2), 0x24},
[CPY] = {(AM_IMM|AM_ZM|AM_IND|AM_ABS|AM_EIND2), 0x44},
[DEB] = {(AM_IMPL), 0x99},
- [DEC] = {(AM_IMPL|AM_ZM|AM_ABS|AM_EIND2), 0x84},
+ [DEC] = {(AM_IMPL|AM_ZM|AM_ABS|AM_EIND2|AM_ORTHO2), 0x84},
[DEX] = {(AM_IMPL), 0xB9},
[DEY] = {(AM_IMPL), 0x79},
- [DIV] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG|AM_EIND), 0x42},
+ [DIV] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG|AM_EIND|AM_ORTHO), 0x42},
[INB] = {(AM_IMPL), 0xA9},
- [INC] = {(AM_IMPL|AM_ZM|AM_ABS|AM_EIND2), 0xA4},
+ [INC] = {(AM_IMPL|AM_ZM|AM_ABS|AM_EIND2|AM_ORTHO2), 0xA4},
[INX] = {(AM_IMPL), 0xC9},
[INY] = {(AM_IMPL), 0x89},
[JMP] = {(AM_ABS|AM_IND|AM_ZM2|AM_EIND), 0x00},
@@ -304,9 +341,9 @@ static const instruction inst[OPNUM] = {
[LDB] = {(AM_IMM|AM_ZM|AM_ZMX|AM_ZMY|AM_IND|AM_INDX|AM_INDY|AM_ABS|AM_EIND), 0xE2},
[LDX] = {(AM_IMM|AM_ZM|AM_IND|AM_ABS|AM_EIND2), 0x64},
[LDY] = {(AM_IMM|AM_ZM|AM_IND|AM_ABS|AM_EIND), 0xA2},
- [LSL] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG|AM_EIND), 0xA1},
- [LSR] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG|AM_EIND), 0xC1},
- [MUL] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG|AM_EIND), 0x22},
+ [LSL] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG|AM_EIND|AM_ORTHO), 0xA1},
+ [LSR] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG|AM_EIND|AM_ORTHO), 0xC1},
+ [MUL] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG|AM_EIND|AM_ORTHO), 0x22},
[NOP] = {(AM_IMPL), 0xEA},
[ORA] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG|AM_EIND), 0x61},
[PHA] = {(AM_IMPL), 0x8E},
@@ -319,11 +356,11 @@ static const instruction inst[OPNUM] = {
[PLP] = {(AM_IMPL), 0x7E},
[PLX] = {(AM_IMPL), 0xFE},
[PLY] = {(AM_IMPL), 0xDE},
- [ROL] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG|AM_EIND), 0xE1},
- [ROR] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG|AM_EIND), 0x02},
+ [ROL] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG|AM_EIND|AM_ORTHO), 0xE1},
+ [ROR] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG|AM_EIND|AM_ORTHO), 0x02},
[RTI] = {(AM_IMPL), 0x60},
[RTS] = {(AM_IMPL), 0x50},
- [SBC] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG|AM_EIND), 0x21},
+ [SBC] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG|AM_EIND|AM_ORTHO), 0x21},
[SEC] = {(AM_IMPL), 0x19},
[SEI] = {(AM_IMPL), 0x39},
[STA] = {(AM_ZM|AM_ZMX|AM_ZMY|AM_IND|AM_INDX|AM_INDY|AM_ABS|AM_EIND2), 0x28},
@@ -341,19 +378,19 @@ static const instruction inst[OPNUM] = {
[TYA] = {(AM_IMPL), 0x3A},
[TYX] = {(AM_IMPL), 0x6A},
[WAI] = {(AM_IMPL), 0x59},
- [XOR] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG|AM_EIND), 0x81}
+ [XOR] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG|AM_EIND|AM_ORTHO), 0x81}
};
static const instruction ext_inst[EXT_OPNUM] = {
- [LEA] = {(AM_ZM|AM_ZMX|AM_ZMY|AM_IND|AM_INDX|AM_INDY|AM_ABS|AM_ABX|AM_ABY|AM_AIND|AM_AINDX|AM_AINDY), 0x03},
- [PEA] = {(AM_ZM|AM_ZMX|AM_ZMY|AM_IND|AM_INDX|AM_INDY|AM_ABS|AM_ABX|AM_ABY|AM_AIND|AM_AINDX|AM_AINDY), 0x23},
- [ADD] = {(AM_IMM|AM_ZM|AM_ABS|AM_EIND), 0x06},
- [SUB] = {(AM_IMM|AM_ZM|AM_ABS|AM_EIND), 0x26},
+ [LEA] = {(AM_ZM|AM_ZMX|AM_ZMY|AM_IND|AM_INDX|AM_INDY|AM_ABS|AM_ABX|AM_ABY|AM_AIND|AM_AINDX|AM_AINDY|AM_ORTHO), 0x03},
+ [PEA] = {(AM_ZM|AM_ZMX|AM_ZMY|AM_IND|AM_INDX|AM_INDY|AM_ABS|AM_ABX|AM_ABY|AM_AIND|AM_AINDX|AM_AINDY|AM_ORTHO2), 0x23},
+ [ADD] = {(AM_IMM|AM_ZM|AM_ABS|AM_EIND|AM_ORTHO), 0x06},
+ [SUB] = {(AM_IMM|AM_ZM|AM_ABS|AM_EIND|AM_ORTHO), 0x26},
[ADE] = {(AM_IMM|AM_ZM|AM_ABS), 0x46},
[SBE] = {(AM_IMM|AM_ZM|AM_ABS), 0x66},
[ADS] = {(AM_IMM|AM_ZM|AM_ABS|AM_EIND), 0x86},
[SBS] = {(AM_IMM|AM_ZM|AM_ABS|AM_EIND), 0xA6},
- [NOT] = {(AM_IMPL|AM_ZM|AM_ABS|AM_EIND), 0xC6},
+ [NOT] = {(AM_IMPL|AM_ZM|AM_ABS|AM_EIND|AM_ORTHO2), 0xC6},
[LLM] = {(AM_ZM|AM_ABS|AM_EIND), 0x48},
[LRM] = {(AM_ZM|AM_ABS|AM_EIND), 0x68},
[RLM] = {(AM_ZM|AM_ABS|AM_EIND), 0x88},
@@ -373,12 +410,12 @@ static const instruction ext_inst[EXT_OPNUM] = {
[STZ] = {(AM_ZM|AM_ABS|AM_EIND), 0xE0},
[SCO] = {(AM_IMM|AM_ZM|AM_ABS|AM_EIND), 0x60},
[ECO] = {(AM_ZM|AM_ABS|AM_EIND), 0x80},
- [CLZ] = {(AM_ZM|AM_ABS|AM_EIND), 0x05},
- [CLO] = {(AM_ZM|AM_ABS|AM_EIND), 0x25},
+ [CLZ] = {(AM_ZM|AM_ABS|AM_EIND|AM_ORTHO2), 0x05},
+ [CLO] = {(AM_ZM|AM_ABS|AM_EIND|AM_ORTHO2), 0x25},
[BIT] = {(AM_ZM|AM_ABS|AM_EIND), 0x45},
[MMV] = {(AM_IMPL), 0xCB},
- [SWP] = {(AM_IMPL|AM_ZM|AM_ABS|AM_EIND), 0xE6},
- [PCN] = {(AM_ZM|AM_ABS|AM_EIND), 0xE8},
+ [SWP] = {(AM_IMPL|AM_ZM|AM_ABS|AM_EIND|AM_ORTHO2), 0xE6},
+ [PCN] = {(AM_ZM|AM_ABS|AM_EIND|AM_ORTHO), 0xE8},
[REP] = {(AM_REL), 0xBD},
[REQ] = {(AM_REL), 0xCD},
[RNE] = {(AM_REL), 0xDD},
@@ -396,6 +433,25 @@ static const instruction ext_inst[EXT_OPNUM] = {
[SNE] = {(AM_EIND2), 0xBD}
};
+static const instruction ortho_inst[ORTHO_OPNUM] = {
+ [MNG] = {(AM_ORTHO), 0x00},
+ [MPO] = {(AM_ORTHO), 0x20},
+ [MCS] = {(AM_ORTHO), 0x40},
+ [MCC] = {(AM_ORTHO), 0x60},
+ [MEQ] = {(AM_ORTHO), 0x80},
+ [MNE] = {(AM_ORTHO), 0xA0},
+ [MVS] = {(AM_ORTHO), 0xC0},
+ [MVC] = {(AM_ORTHO), 0xE0},
+ [OR ] = {(AM_ORTHO), 0x61},
+ [MOV] = {(AM_ORTHO), 0xA2},
+ [IML] = {(AM_ORTHO), 0xC2},
+ [IDV] = {(AM_ORTHO), 0xE2},
+ [PSH] = {(AM_ORTHO2), 0x04},
+ [PUL] = {(AM_ORTHO2), 0x24},
+ [NEG] = {(AM_ORTHO2), 0x64},
+ [SET] = {(AM_ORTHO2), 0x05}
+};
+
static const char *dir_t[11] = {
[ 0] = "org",
[ 1] = "byte",
@@ -417,7 +473,7 @@ static const char *rs_t[4] = {
[3] = ".q"
};
-static const char *lex_tok[23] = {
+static const char *lex_tok[] = {
[TOK_DIR ] = "TOK_DIR",
[TOK_LOCAL ] = "TOK_LOCAL",
[TOK_LABEL ] = "TOK_LABEL",
@@ -431,6 +487,11 @@ static const char *lex_tok[23] = {
[TOK_BREG ] = "TOK_BREG",
[TOK_OPCODE ] = "TOK_OPCODE",
[TOK_EXTOP ] = "TOK_EXTOP",
+ [TOK_ORTHO ] = "TOK_ORTHO",
+ [TOK_REG ] = "TOK_REG",
+ [TOK_MEM ] = "TOK_MEM",
+ [TOK_CC ] = "TOK_CC",
+ [TOK_OS ] = "TOK_OS",
[TOK_RS ] = "TOK_RS",
[TOK_OF ] = "TOK_OF",
[TOK_COMMENT] = "TOK_COMMENT",
@@ -461,6 +522,11 @@ static const char *adrmode[] = {
[AINDX] = "AINDX",
[AINDY] = "AINDY",
[EIND ] = "EIND"
+/* [ZMR ] = "ZMR",
+ [ZINDR] = "ZINDR",
+ [ZRIND] = "ZRIND",
+ [AINDR] = "AINDR",
+ [AINDY] = "ARIND",*/
};
static const char *mne[OPNUM] = {
@@ -592,6 +658,36 @@ static const char *ext_mne[EXT_OPNUM] = {
[SNE] = "SNE"
};
+static const char *ortho_mne[ORTHO_OPNUM] = {
+ [MNG] = "MNG",
+ [MPO] = "MPO",
+ [MCS] = "MCS",
+ [MCC] = "MCC",
+ [MEQ] = "MEQ",
+ [MNE] = "MNE",
+ [MVS] = "MVS",
+ [MVC] = "MVC",
+ [OR ] = "OR",
+ [MOV] = "MOV",
+ [IML] = "IML",
+ [IDV] = "IDV",
+ [PSH] = "PSH",
+ [PUL] = "PUL",
+ [NEG] = "NEG",
+ [SET] = "SET"
+};
+
+static const char *set_cc[8] = {
+ "NG",
+ "PO",
+ "CS",
+ "CC",
+ "EQ",
+ "NE",
+ "VS",
+ "VC"
+};
+
static const char *instdesc[OPNUM] = {
[ADC] = "ADd accumulator, with operand, Carry if needed.",
[AND] = "Bitwise AND accumulator, with operand.",
@@ -708,8 +804,8 @@ extern uint8_t isfixup;
extern line *find_line(uint32_t ln, uint8_t dbg);
extern uint64_t lex(char *str, uint64_t address, uint16_t bline, uint8_t dbg);
-extern uint64_t get_val(token *t, uint64_t addr, uint8_t size, uint8_t dbg);
-extern token *skip_expr(token *t, uint8_t dbg);
+extern uint64_t get_val(token *t, uint64_t addr, uint8_t size, uint8_t end_expr, uint8_t stop_comma, uint8_t dbg);
+extern token *skip_expr(token *t, uint8_t end_expr, uint8_t stop_comma, uint8_t dbg);
extern uint64_t parse_tokens(token *tm, line **l, bytecount *bc, uint8_t isasm, uint64_t address, uint8_t dbg);
extern token *make_token(uint8_t id, uint8_t type, uint8_t space, uint8_t tab, uint64_t value, char *str, symbol *s);
extern void assemble(line *ln, bytecount *bc, uint8_t dbg);