#include "opcode.h"
#include <ctype.h>
#include <string.h>
#define MAX_TOK 0x1000
struct line {
uint8_t stab;
uint8_t sspace;
uint8_t dir;
uint8_t mne;
uint8_t rs;
uint8_t opbase;
uint8_t aopbase;
uint8_t am;
uint8_t cm;
uint8_t etab;
uint8_t espace;
uint8_t islabel;
uint8_t issym;
uint16_t sym;
uint16_t com;
uint16_t str;
uint16_t incl;
uint16_t linenum;
uint64_t op;
uint64_t aop;
uint64_t addr;
};
struct tok {
struct tok *next;
uint8_t id;
uint8_t type;
union {
char *str;
uint8_t byte ;
uint16_t word ;
uint32_t dword;
uint64_t qword;
};
};
struct ln {
struct ln *next;
struct tok *tok;
uint16_t count;
uint16_t linenum;
uint64_t addr;
uint8_t stab;
uint8_t sspace;
uint8_t etab;
uint8_t espace;
};
typedef struct tok token;
typedef struct ln line;
struct fixup {
struct symbol *s;
token *t;
uint64_t adr;
};
struct symbol {
uint64_t val;
uint8_t def;
char name[128];
uint16_t id;
};
extern char lexeme[];
extern char *string[];
extern char *comment[];
extern uint16_t incl[];
extern line *lines;
extern line *last_line;
extern token *tokens;
extern token *last_tok;
extern struct line tokline[];
extern struct line tln[];
extern struct symbol *symbols[];
extern struct fixup *fixups[];
extern uint8_t lex_type;
enum dir {
DIR_ORG,
DIR_BYTE,
DIR_WORD,
DIR_DWORD,
DIR_QWORD,
DIR_INCLUDE
};
enum token {
TOK_DIR,
TOK_LABEL,
TOK_SYM,
TOK_EXPR,
TOK_COMMA,
TOK_STRING,
TOK_CHAR,
TOK_IMM,
TOK_OPCODE,
TOK_RS,
TOK_COMMENT,
TOK_HEX,
TOK_DEC,
TOK_BIN,
TOK_INCLUDE
};
enum expr {
EXPR_PLUS,
EXPR_MINUS,
EXPR_LOW,
EXPR_HIGH,
EXPR_NONE
};
static const uint8_t opcodes[OPNUM][9] = {
[ 0] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00},
[ 1] = {0x01, 0x06, 0xFF, 0xF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 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE}
};
static const char *dir_t[6] = {
[0] = "org",
[1] = "byte",
[2] = "word",
[3] = "dword",
[4] = "qword",
[5] = "include"
};
static const char *rs_t[4] = {
[0] = "",
[1] = ".w",
[2] = ".d",
[3] = ".q"
};
static const char *lex_tok[15] = {
[0x0] = "TOK_DIR",
[0x1] = "TOK_LABEL",
[0x2] = "TOK_SYM",
[0x3] = "TOK_EXPR",
[0x4] = "TOK_COMMA",
[0x5] = "TOK_STRING",
[0x6] = "TOK_CHAR",
[0x7] = "TOK_IMM",
[0x8] = "TOK_OPCODE",
[0x9] = "TOK_RS",
[0xA] = "TOK_COMMENT",
[0xB] = "TOK_HEX",
[0xC] = "TOK_DEC",
[0xD] = "TOK_BIN",
[0xE] = "TOK_INCLUDE"
};
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 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."
};
static const uint8_t bitsize[4] = {
[0] = 0x07,
[1] = 0x0F,
[2] = 0x1F,
[3] = 0x3F
};
static const uint8_t amp[8] = {
[0] = 0x00,
[1] = 0x00,
[2] = 0x07,
[4] = 0x07,
[5] = 0x0B,
[6] = 0x0B,
[3] = 0x0F,
[7] = 0x0F
};
extern uint16_t linenum;
extern uint16_t lineidx;
extern uint16_t stridx;
extern uint16_t comidx;
extern uint16_t inc_file;
struct bc {
uint64_t progsize;
uint64_t datasize;
};
typedef struct bc bytecount;
extern uint8_t defined;
extern uint8_t isfixup;
extern void init_symbol();
extern uint16_t mksymbol(const char *name, uint64_t val, uint8_t def, uint8_t useid, uint16_t id, uint8_t dbg);
extern uint64_t use_symbol(const char *name, uint16_t id, uint64_t val, uint8_t useid, uint8_t dbg);
extern uint8_t set_symval(const char *name, uint16_t id, uint64_t val, uint8_t useid, uint8_t dbg);
extern char *get_symname(uint16_t id, uint8_t dbg);
extern uint16_t get_symid(const char *name, uint64_t val, token *t, uint8_t dbg);
extern uint16_t get_comment(const char *cmnt, uint8_t dbg);
extern uint16_t reslv_fixups(uint8_t dbg);
extern line *find_line(uint16_t ln, uint8_t dbg);
extern uint64_t lex(char *str, uint64_t address, uint8_t dbg);
extern uint64_t parse_tokens(token *tm, bytecount *bc, uint8_t isasm, uint64_t address, uint8_t dbg);
extern token *make_token(uint8_t id, uint8_t type, uint64_t value, char *str);
extern void assemble(line *ln, bytecount *bc, uint8_t dbg);
extern void free_tokens(token *t, uint16_t count);
extern void free_lines();