summaryrefslogtreecommitdiff
path: root/opcode.h
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2020-04-27 00:22:27 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2020-04-27 14:00:00 -0400
commited88644ded82008577804c590bec7188ef0da011 (patch)
tree9bb534b0019c61a4c300493b382135ff3793103b /opcode.h
parente093aba79dd1ed88cb490b7cd69c81f0b14bea11 (diff)
Added support for including source files to the
emulator's assembler. And removed three pointers, and the linewrap table from zero page, in SuBEditor. I moved the linewrap table to address $1000. And because of finally adding include support to the assembler, I can now start work on SuBAsm!
Diffstat (limited to 'opcode.h')
-rw-r--r--opcode.h249
1 files changed, 8 insertions, 241 deletions
diff --git a/opcode.h b/opcode.h
index 71cae60..67ba5f5 100644
--- a/opcode.h
+++ b/opcode.h
@@ -4,7 +4,12 @@
#include <stdlib.h>
#include <unistd.h>
-#define OPNAME(opcode) [opcode] = #opcode /* Get name of Opcode, for disassembly. */
+#define bench 0
+#define debug 0
+#define IO 1
+#define getclk 0
+#define keypoll 0
+
#define CPS 0x00 /* Clear Processor Status. */
#define ADC 0x01 /* ADd with Carry. */
#define AAB 0x02 /* Add Accumulator with carry by B register. */
@@ -211,60 +216,6 @@ struct sux {
};
enum {IMM, ZM, ZMX, ZMY, IND, INDX, INDY, ABS, IMPL};
-enum {
- DIR_ORG,
- DIR_BYTE,
- DIR_WORD,
- DIR_DWORD,
- DIR_QWORD
-};
-
-enum {
- TOK_DIR,
- TOK_LABEL,
- TOK_SYM,
- TOK_PLUS,
- TOK_MINUS,
- TOK_STRING,
- TOK_CHAR,
- TOK_IMM,
- TOK_OPCODE,
- TOK_RS,
- TOK_COMMENT,
- TOK_HEX,
- TOK_DEC,
- TOK_BIN
-};
-
-enum {
- BASE_HEX,
- BASE_DEC,
- 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] = {
- [IMM ] = "IMM",
- [ZM ] = "ZM",
- [ZMX ] = "ZMX",
- [ZMY ] = "ZMY",
- [IND ] = "IND",
- [INDX] = "INDX",
- [INDY] = "INDY",
- [ABS ] = "ABS",
- [IMPL] = "IMPL"
-};
static const uint8_t optype[0x100] = {
[0x00] = IMPL,
@@ -454,192 +405,7 @@ static const uint8_t optype[0x100] = {
[0xFE] = IMPL
};
-static const char *mne[OPNUM] = {
- [ 0] = "CPS",
- [ 1] = "ADC",
- [ 2] = "AAB",
- [ 3] = "PHP",
- [ 4] = "CPB",
- [ 5] = "PHB",
- [ 6] = "DEC",
- [ 7] = "JMP",
- [ 8] = "SBC",
- [ 9] = "SAB",
- [10] = "ENT",
- [11] = "CPY",
- [12] = "PLB",
- [13] = "INC",
- [14] = "JSR",
- [15] = "JSL",
- [16] = "AND",
- [17] = "ABA",
- [18] = "PLP",
- [19] = "CPX",
- [20] = "PHY",
- [21] = "BPO",
- [22] = "ORA",
- [23] = "OAB",
- [24] = "STT",
- [25] = "PLY",
- [26] = "BNG",
- [27] = "XOR",
- [28] = "XAB",
- [29] = "PHA",
- [30] = "PHX",
- [31] = "BCS",
- [32] = "LSL",
- [33] = "LLB",
- [34] = "CLC",
- [35] = "PLX",
- [36] = "BCC",
- [37] = "LSR",
- [38] = "LRB",
- [39] = "PLA",
- [40] = "TAB",
- [41] = "BEQ",
- [42] = "ROL",
- [43] = "RLB",
- [44] = "SEC",
- [45] = "TBA",
- [46] = "BNE",
- [47] = "ROR",
- [48] = "RRB",
- [49] = "DEY",
- [50] = "TAY",
- [51] = "BVS",
- [52] = "MUL",
- [53] = "MAB",
- [54] = "CLI",
- [55] = "TYA",
- [56] = "BVC",
- [57] = "DIV",
- [58] = "DAB",
- [59] = "INY",
- [60] = "TAX",
- [61] = "RTS",
- [62] = "RTL",
- [63] = "CMP",
- [64] = "CAB",
- [65] = "SEI",
- [66] = "LDX",
- [67] = "TXA",
- [68] = "RTI",
- [69] = "LDA",
- [70] = "DEX",
- [71] = "CLV",
- [72] = "TYX",
- [73] = "STA",
- [74] = "TSX",
- [75] = "LDB",
- [76] = "INX",
- [77] = "WAI",
- [78] = "TXY",
- [79] = "STB",
- [80] = "TXS",
- [81] = "LDY",
- [82] = "BRK",
- [83] = "NOP",
- [84] = "STY",
- [85] = "DEB",
- [86] = "ASR",
- [87] = "ARB",
- [88] = "STX",
- [89] = "INB"
-};
-
-static const char *instdesc[OPNUM] = {
- [ 0] = "Clears the Processor Status register.",
- [ 1] = "ADd accumulator, with operand, Carry if needed.",
- [ 2] = "Add Accumulator, with B, carry if needed.",
- [ 3] = "PusH the number of bytes specified, from the Processor status register to the stack.",
- [ 4] = "ComPare the B register, with operand.",
- [ 5] = "PusH the number of bytes specified, from the B register to the stack.",
- [ 6] = "DECrement accumulator, or memory.",
- [ 7] = "JuMP to the address specified.",
- [ 8] = "SuBtract accumulator, with operand, Carry if needed",
- [ 9] = "Subtract Accumulator, with B, carry if needed.",
- [10] = "ENd a Thread.",
- [11] = "ComPare the Y register, with operand.",
- [12] = "PuLl the number of bytes specified, from the stack, to the B register.",
- [13] = "INCrement accumulator, or memory.",
- [14] = "Jump to a SubRoutine.",
- [15] = "Jump to a Subroutine, Long address.",
- [16] = "Bitwise AND accumulator, with operand.",
- [17] = "Bitwise AND Accumulator, with B.",
- [18] = "PuLl the number of bytes specified, from the stack, to the Processor status register.",
- [19] = "ComPare the X register, with operand.",
- [20] = "PusH the number of bytes specified, from the Y register to the stack.",
- [21] = "Branch if POsitive.",
- [22] = "Bitwise OR Accumulator, with operand.",
- [23] = "Bitwise OR Accumulator, with B.",
- [24] = "STart a Thread.",
- [25] = "PuLl the number of bytes specified, from the stack, to the Y register.",
- [26] = "Branch if NeGative.",
- [27] = "Bitwise XOR Accumulator, with operand.",
- [28] = "Bitwise XOR Accumulator, with B.",
- [29] = "PusH the number of bytes specified, from the Accumulator to the stack.",
- [30] = "PusH the number of bytes specified, from the X register to the stack.",
- [31] = "Branch if the Carry flag is Set.",
- [32] = "Logical Shift Left accumulator, with operand.",
- [33] = "Logical Shift Left accumulator, with B.",
- [34] = "CLear the Carry flag.",
- [35] = "PuLl the number of bytes specified, from the stack, to the X register.",
- [36] = "Branch if the Carry flag has been Cleared.",
- [37] = "Logical Shift Right accumulator, with operand.",
- [38] = "Logical Shift Right accumulator, with B.",
- [39] = "PuLl the number of bytes specified, from the stack, to the Accumulator.",
- [40] = "Transfer the value from the Accumulator, to the B register.",
- [41] = "Branch if EQual (the zero flag has been set).",
- [42] = "ROtate Left accumulator, with operand.",
- [43] = "Rotate Left accumulator, with B.",
- [44] = "SEt the Carry flag.",
- [45] = "Transfer the value from the Y register, to the Accumulator.",
- [46] = "Branch if Not Equal (the zero flag has been cleared)",
- [47] = "ROtate Right accumulator, with operand.",
- [48] = "Rotate Right accumulator, with B.",
- [49] = "DEcrement the Y register.",
- [50] = "Transfer the value from the Accumulator, to the Y register.",
- [51] = "Branch if the oVerflow flag is Set.",
- [52] = "MULtiply accumulator, with operand.",
- [53] = "Multiply Accumulator, with B.",
- [54] = "CLear the Interrupt flag.",
- [55] = "Transfer the value from the Y register, to the Accumulator.",
- [56] = "Branch if the oVerflow flag has been Cleared.",
- [57] = "DIVide accumulator, with operand, and put the remainder into the B register.",
- [58] = "Divide Accumulator, with B, and put the remainder into the X register.",
- [59] = "INcrement the Y register.",
- [60] = "Transfer the value from the Accumulator, to the X register.",
- [61] = "ReTurn from a Subroutine.",
- [62] = "ReTurn from subroutine, Long address.",
- [63] = "CoMPare acumulator, with operand.",
- [64] = "Compare Accumulator, with B.",
- [65] = "SEt the Interrupt flag.",
- [66] = "LoaD the value from the operand, to the X register.",
- [67] = "Transfer the value from the X register, to the Accumulator.",
- [68] = "ReTurn from an Interrupt.",
- [69] = "LoaD the value from the operand, to the Accumulator.",
- [70] = "DEcrement the X register.",
- [71] = "CLear the oVerflow flag.",
- [72] = "Transfer the value from the Y register, to the X register.",
- [73] = "STore the value from the Accumulator, in memory.",
- [74] = "Transfer the value from the Stack pointer, to the X register.",
- [75] = "LoaD the value from the operand, to the B register.",
- [76] = "INcrement the X register.",
- [77] = "WAIt for an interrupt",
- [78] = "Transfer the value from the X register, to the Y register.",
- [79] = "STore the value from the B register, in memory.",
- [80] = "Transfer the value from the X register, to the Stack pointer.",
- [81] = "LoaD the value from the operand, to the Y register.",
- [82] = "BReaKpoint",
- [83] = "NO oPeration",
- [84] = "STore the value from the Y register, in memory.",
- [85] = "DEcrement the B register.",
- [86] = "Arithmetic Shift Right accumulator, with operand.",
- [87] = "Arithmetic shift Right accumulator, with B.",
- [88] = "STore the value from the X register, in memory.",
- [89] = "INcrement the B register."
-};
-
+#if debug
static const char *opname[0x100] = {
[0x00] = "CPS",
[0x01] = "ADC #",
@@ -827,5 +593,6 @@ static const char *opname[0x100] = {
[0xFD] = "STX zm",
[0xFE] = "INB"
};
+#endif
extern int asmmon();