mirror of
https://github.com/RevCurtisP/C02.git
synced 2024-11-22 01:31:33 +00:00
102 lines
3.5 KiB
C
102 lines
3.5 KiB
C
/* Definitions for A02 Assembler */
|
|
|
|
#define MAXSTR 128 //Maximum String Length
|
|
#define MAXLBL 8 //Maximum Symbol Length
|
|
#define MAXSYM 1024 //Maximum Number of Global Labels
|
|
|
|
#define FALSE 0
|
|
#define TRUE -1
|
|
|
|
/* Address Mode Bit Masks */
|
|
#define ACMLT 0x0001 //Accumulator [$xA]
|
|
#define IMMDT 0x0002 //*Immediate [w/Acc]
|
|
#define ZPAGE 0x0004 //Zero Page
|
|
#define ZPAGX 0x0008 //*Zero Page,X
|
|
//#define ZPAGY 0x0010 //*Zero Page,Y [By OpCodes]
|
|
#define ABSLT 0x0020 //Absolute
|
|
#define ABSLX 0x0040 //*Absolute,X [fixops()]
|
|
#define ABSLY 0x0080 //Absolute,Y
|
|
#define IMPLD 0x0100 //*Implied [x0001]
|
|
#define INDCT 0x0200 //(Indirect)
|
|
#define INDCX 0x0400 //(Indirect,X)
|
|
#define INDCY 0x0800 //(Indirect),Y
|
|
#define RELTV 0x1000 //Relative
|
|
|
|
struct amd {int amode; char desc[12];};
|
|
struct amd amdesc[] = {
|
|
{ACMLT, "Accumulator"},
|
|
{IMMDT, "Immediate"},
|
|
{ZPAGE, "Zero Page"},
|
|
{ZPAGX, "Zero Page,X"},
|
|
{ABSLT, "Absolute"},
|
|
{ABSLX, "Absolute,X"},
|
|
{ABSLY, "Absolute,Y"},
|
|
{IMPLD, "Implied"},
|
|
{INDCT, "(Indirect)"},
|
|
{INDCX, "(Indirect,X)"},
|
|
{INDCY, "(Indirect),Y"},
|
|
{RELTV, "Relative"},
|
|
{0, ""}
|
|
};
|
|
|
|
struct opc {char name[5], token; int amode;};
|
|
struct opc psolst[] = {
|
|
{"BYTE", 'B', 0}, {"HEX", 'H'}, {"WORD", 'W', 0}, {"EQU", '=', 0}, {"FILL", 'F', 0},
|
|
{"INCL", 'I', 0}, {"SUBR", 'S', 0}, {"DC", 'B', 0}, {"DS", 'F', 0}, {"ALIG", 'A', 0},
|
|
{"ORG", '*', 0}, {"PROC", 'P', 0}, {"END", 'E', 0}, {"", 0, 0}
|
|
};
|
|
|
|
struct opc opclst[] = {
|
|
{"BRK", 0x00, 0x0100}, {"NOP", 0xEA, 0x0100}, {"STP", 0xDB, 0x0100}, {"WAI", 0xCB, 0x0100},
|
|
{"DEX", 0xCA, 0x0100}, {"DEY", 0x88, 0x0100}, {"INX", 0xE8, 0x0100}, {"INY", 0xC8, 0x0100},
|
|
{"PHA", 0x48, 0x0100}, {"PHP", 0x08, 0x0100}, {"PHX", 0xDA, 0x0100}, {"PHY", 0x5A, 0x0100},
|
|
{"PLA", 0x68, 0x0100}, {"PLP", 0x28, 0x0100}, {"PLX", 0xFA, 0x0100}, {"PLY", 0x7A, 0x0100},
|
|
{"CLC", 0x18, 0x0100}, {"CLD", 0xD8, 0x0100}, {"CLI", 0x58, 0x0100}, {"CLV", 0xB8, 0x0100},
|
|
{"SEC", 0x38, 0x0100}, {"SED", 0xF8, 0x0100}, {"SEI", 0x78, 0x0100},
|
|
{"TAX", 0xAA, 0x0100}, {"TAY", 0xA8, 0x0100}, {"TSX", 0xBA, 0x0100},
|
|
{"TXA", 0x8A, 0x0100}, {"TYA", 0x98, 0x0100}, {"TXS", 0x9A, 0x0100},
|
|
{"RTI", 0x40, 0x0100}, {"RTS", 0x60, 0x0100},
|
|
|
|
{"BCS", 0xB0, 0x1000}, {"BEQ", 0xF0, 0x1000}, {"BMI", 0x30, 0x1000}, {"BVS", 0x70, 0x1000},
|
|
{"BCC", 0x90, 0x1000}, {"BNE", 0xD0, 0x1000}, {"BPL", 0x10, 0x1000}, {"BVC", 0x50, 0x1000},
|
|
{"BRA", 0x80, 0x1000},
|
|
|
|
{"LDA", 0xA1, 0x0EFE}, {"ADC", 0x61, 0x0EFE}, {"AND", 0x21, 0x0EFE}, {"CMP", 0xC1, 0x0EFE},
|
|
{"STA", 0x81, 0x0EFE}, {"SBC", 0xE1, 0x0EFE}, {"ORA", 0x01, 0x0EFE}, {"EOR", 0x41, 0x0EFE},
|
|
|
|
{"ASL", 0x02, 0x007D}, {"ROL", 0x22, 0x007D}, {"INC", 0xE2, 0x007D}, {"LSR", 0x42, 0x007D},
|
|
{"ROR", 0x62, 0x007D}, {"DEC", 0xC2, 0x007D},
|
|
|
|
{"TRB", 0x10, 0x0024}, {"TSB", 0x00, 0x0024},
|
|
{"CPX", 0xE0, 0x0026}, {"CPY", 0xC0, 0x0026},
|
|
{"LDX", 0xA2, 0x00A6}, {"STX", 0x82, 0x00A6},
|
|
{"BIT", 0x20, 0x006E},
|
|
{"STZ", 0x60, 0x006C},
|
|
{"JMP", 0x4C, 0x0620},
|
|
{"JSR", 0x14, 0x0020},
|
|
{"LDY", 0xA0, 0x006E},
|
|
{"STY", 0x80, 0x002C},
|
|
{"", 0, 0}
|
|
};
|
|
|
|
struct opf {unsigned char token, opmod, opcode;};
|
|
|
|
struct opf opfix[] = {
|
|
{0x20, 0x08, 0x89},
|
|
{0xE0, 0x08, 0xE0},
|
|
{0xC0, 0x08, 0xC0},
|
|
{0xA0, 0x08, 0xA0},
|
|
{0xA2, 0x08, 0xA2},
|
|
{0xC2, 0x08, 0x3A},
|
|
{0xE2, 0x08, 0x1A},
|
|
{0x60, 0x0C, 0x9C},
|
|
{0x60, 0x1C, 0x9E},
|
|
{0xA2, 0x18, 0xBE},
|
|
{0x82, 0x18, 0xBC},
|
|
{0x4C, 0x0C, 0x4C},
|
|
{0x4C, 0x11, 0x6C},
|
|
{0x4C, 0x00, 0x7C},
|
|
{0,0,0}
|
|
};
|
|
|