#include "opcode.h"
#include <ctype.h>
#include <string.h>
#define MAX_TOK 0x1000
typedef struct tok token ;
typedef struct ln line ;
typedef struct sym symbol;
typedef struct fix fixup ;
struct tok {
token *next;
uint8_t id;
uint8_t type;
union {
symbol *sym;
char *str;
uint8_t byte ;
uint16_t word ;
uint32_t dword;
uint64_t qword;
};
};
struct ln {
line *next;
token *tok;
uint16_t count;
uint32_t linenum;
uint64_t addr;
uint8_t stab;
uint8_t sspace;
uint8_t etab;
uint8_t espace;
};
struct fix {
fixup *next;
symbol *s;
token *t;
uint64_t adr;
};
struct sym {
symbol *next;
symbol *local;
uint16_t count;
uint64_t val;
uint8_t def;
char *name;
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 symbol *symbols;
extern symbol *last_sym;
extern symbol *locals;
extern symbol *last_loc;
extern fixup *fixups;
extern fixup *last_fix;
extern uint8_t lex_type;
enum dir {
DIR_ORG,
DIR_BYTE,
DIR_WORD,
DIR_DWORD,
DIR_QWORD,
DIR_INCLUDE,
DIR_RES
};
enum token {
TOK_DIR,
TOK_LOCAL,
TOK_LABEL,
TOK_SYM,
TOK_EXPR,
TOK_CSV,
TOK_STRING,
TOK_CHAR,
TOK_IND,
TOK_IMM,
TOK_OPCODE,
TOK_RS,
TOK_OF,
TOK_COMMENT,
TOK_HEX,
TOK_DEC,
TOK_BIN,
TOK_INCLUDE
};
enum pre_token {
PTOK_DOT,
PTOK_AT,
PTOK_COLON,
PTOK_EQU,
PTOK_PLUS,
PTOK_MINUS,
PTOK_GT,
PTOK_LT,
PTOK_LBRACK,
PTOK_RBRACK,
PTOK_COMMA,
PTOK_X,
PTOK_Y,
PTOK_S,
PTOK_P,
PTOK_DQUOTE,
PTOK_SQUOTE,
PTOK_HASH,
PTOK_SCOLON,
PTOK_DOLLAR,
PTOK_PERCENT,
PTOK_NUMBER,
PTOK_ALPHA,
PTOK_OTHER
};
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F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7A},
[TBA] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x6A},
[TSX] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xDA},
[TXA] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xAA},
[TXS] = {0xFA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
[TXY] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xCA},
[TYA] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x8A},
[TYX] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xBA},
[WAI] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x58},
[XAB] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x42},
[XOR] = {0x41, 0x46, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x44, 0xFF, 0xFF}
};
static const char *dir_t[7] = {
[0] = "org",
[1] = "byte",
[2] = "word",
[3] = "dword",
[4] = "qword",
[5] = "include",
[6] = "res"
};
static const char *rs_t[4] = {
[0] = "",
[1] = ".w",
[2] = ".d",
[3] = ".q"
};
static const char *lex_tok[18] = {
[TOK_DIR ] = "TOK_DIR",
[TOK_LOCAL ] = "TOK_LOCAL",
[TOK_LABEL ] = "TOK_LABEL",
[TOK_SYM ] = "TOK_SYM",
[TOK_EXPR ] = "TOK_EXPR",
[TOK_CSV ] = "TOK_CSV",
[TOK_STRING ] = "TOK_STRING",
[TOK_CHAR ] = "TOK_CHAR",
[TOK_IND ] = "TOK_IND",
[TOK_IMM ] = "TOK_IMM",
[TOK_OPCODE ] = "TOK_OPCODE",
[TOK_RS ] = "TOK_RS",
[TOK_OF ] = "TOK_OF",
[TOK_COMMENT] = "TOK_COMMENT",
[TOK_HEX ] = "TOK_HEX",
[TOK_DEC ] = "TOK_DEC",
[TOK_BIN ] = "TOK_BIN",
[TOK_INCLUDE] = "TOK_INCLUDE"
};
static const char *adrmode[10] = {
[IMM ] = "IMM",
[ZM ] = "ZM",
[ZMX ] = "ZMX",
[ZMY ] = "ZMY",
[IND ] = "IND",
[INDX] = "INDX",
[INDY] = "INDY",
[ABS ] = "ABS",
[REL ] = "REL",
[IMPL] = "IMPL"
};
static const char *mne[OPNUM] = {
[AAB] = "AAB",
[ABA] = "ABA",
[ADC] = "ADC",
[AND] = "AND",
[ARB] = "ARB",
[ASR] = "ASR",
[BCC] = "BCC",
[BCS] = "BCS",
[BEQ] = "BEQ",
[BNE] = "BNE",
[BNG] = "BNG",
[BPO] = "BPO",
[BRA] = "BRA",
[BRK] = "BRK",
[BVC] = "BVC",
[BVS] = "BVS",
[CAB] = "CAB",
[CLC] = "CLC",
[CLI] = "CLI",
[CLV] = "CLV",
[CMP] = "CMP",
[CPB] = "CPB",
[CPS] = "CPS",
[CPX] = "CPX",
[CPY] = "CPY",
[DAB] = "DAB",
[DEB] = "DEB",
[DEC] = "DEC",
[DEX] = "DEX",
[DEY] = "DEY",
[DIV] = "DIV",
[INB] = "INB",
[INC] = "INC",
[INX] = "INX",
[INY] = "INY",
[JMP] = "JMP",
[JSR] = "JSR",
[LDA] = "LDA",
[LDB] = "LDB",
[LDX] = "LDX",
[LDY] = "LDY",
[LLB] = "LLB",
[LRB] = "LRB",
[LSL] = "LSL",
[LSR] = "LSR",
[MAB] = "MAB",
[MUL] = "MUL",
[NOP] = "NOP",
[OAB] = "OAB",
[ORA] = "ORA",
[PHA] = "PHA",
[PHB] = "PHB",
[PHP] = "PHP",
[PHX] = "PHX",
[PHY] = "PHY",
[PLA] = "PLA",
[PLB] = "PLB",
[PLP] = "PLP",
[PLX] = "PLX",
[PLY] = "PLY",
[RLB] = "RLB",
[ROL] = "ROL",
[ROR] = "ROR",
[RRB] = "RRB",
[RTI] = "RTI",
[RTS] = "RTS",
[SAB] = "SAB",
[SBC] = "SBC",
[SEC] = "SEC",
[SEI] = "SEI",
[STA] = "STA",
[STB] = "STB",
[STX] = "STX",
[STY] = "STY",
[TAB] = "TAB",
[TAX] = "TAX",
[TAY] = "TAY",
[TBA] = "TBA",
[TSX] = "TSX",
[TXA] = "TXA",
[TXS] = "TXS",
[TXY] = "TXY",
[TYA] = "TYA",
[TYX] = "TYX",
[WAI] = "WAI",
[XAB] = "XAB",
[XOR] = "XOR"
};
static const char *instdesc[OPNUM] = {
[AAB] = "Add Accumulator, with B, carry if needed.",
[ABA] = "Bitwise AND Accumulator, with B.",
[ADC] = "ADd accumulator, with operand, Carry if needed.",
[AND] = "Bitwise AND accumulator, with operand.",
[ARB] = "Arithmetic shift Right accumulator, with B.",
[ASR] = "Arithmetic Shift Right accumulator, with operand.",
[BCC] = "Branch if the Carry flag has been Cleared.",
[BCS] = "Branch if the Carry flag is Set.",
[BEQ] = "Branch if EQual (the zero flag has been set).",
[BNE] = "Branch if Not Equal (the zero flag has been cleared)",
[BNG] = "Branch if NeGative.",
[BPO] = "Branch if POsitive.",
[BRA] = "BRanch Always.",
[BRK] = "BReaKpoint",
[BVC] = "Branch if the oVerflow flag has been Cleared.",
[BVS] = "Branch if the oVerflow flag is Set.",
[CAB] = "Compare Accumulator, with B.",
[CLC] = "CLear the Carry flag.",
[CLI] = "CLear the Interrupt flag.",
[CLV] = "CLear the oVerflow flag.",
[CMP] = "CoMPare acumulator, with operand.",
[CPB] = "ComPare the B register, with operand.",
[CPS] = "Clears the Processor Status register.",
[CPX] = "ComPare the X register, with operand.",
[CPY] = "ComPare the Y register, with operand.",
[DAB] = "Divide Accumulator, with B, and put the remainder into the X register.",
[DEB] = "DEcrement the B register.",
[DEC] = "DECrement accumulator, or memory.",
[DEX] = "DEcrement the X register.",
[DEY] = "DEcrement the Y register.",
[DIV] = "DIVide accumulator, with operand, and put the remainder into the B register.",
[INB] = "INcrement the B register.",
[INC] = "INCrement accumulator, or memory.",
[INX] = "INcrement the X register.",
[INY] = "INcrement the Y register.",
[JMP] = "JuMP to the address specified.",
[JSR] = "Jump to a SubRoutine.",
[LDA] = "LoaD the value from the operand, to the Accumulator.",
[LDB] = "LoaD the value from the operand, to the B register.",
[LDX] = "LoaD the value from the operand, to the X register.",
[LDY] = "LoaD the value from the operand, to the Y register.",
[LLB] = "Logical Shift Left accumulator, with B.",
[LRB] = "Logical Shift Right accumulator, with B.",
[LSL] = "Logical Shift Left accumulator, with operand.",
[LSR] = "Logical Shift Right accumulator, with operand.",
[MAB] = "Multiply Accumulator, with B.",
[MUL] = "MULtiply accumulator, with operand.",
[NOP] = "NO oPeration",
[OAB] = "Bitwise OR Accumulator, with B.",
[ORA] = "Bitwise OR Accumulator, with operand.",
[PHA] = "PusH the number of bytes specified, from the Accumulator to the stack.",
[PHB] = "PusH the number of bytes specified, from the B register to the stack.",
[PHP] = "PusH the number of bytes specified, from the Processor status register to the stack.",
[PHX] = "PusH the number of bytes specified, from the X register to the stack.",
[PHY] = "PusH the number of bytes specified, from the Y register to the stack.",
[PLA] = "PuLl the number of bytes specified, from the stack, to the Accumulator.",
[PLB] = "PuLl the number of bytes specified, from the stack, to the B register.",
[PLP] = "PuLl the number of bytes specified, from the stack, to the Processor status register.",
[PLX] = "PuLl the number of bytes specified, from the stack, to the X register.",
[PLY] = "PuLl the number of bytes specified, from the stack, to the Y register.",
[RLB] = "Rotate Left accumulator, with B.",
[ROL] = "ROtate Left accumulator, with operand.",
[ROR] = "ROtate Right accumulator, with operand.",
[RRB] = "Rotate Right accumulator, with B.",
[RTI] = "ReTurn from an Interrupt.",
[RTS] = "ReTurn from a Subroutine.",
[SAB] = "Subtract Accumulator, with B, carry if needed.",
[SBC] = "SuBtract accumulator, with operand, Carry if needed",
[SEC] = "SEt the Carry flag.",
[SEI] = "SEt the Interrupt flag.",
[STA] = "STore the value from the Accumulator, in memory.",
[STB] = "STore the value from the B register, in memory.",
[STX] = "STore the value from the X register, in memory.",
[STY] = "STore the value from the Y register, in memory.",
[TAB] = "Transfer the value from the Accumulator, to the B register.",
[TAX] = "Transfer the value from the Accumulator, to the X register.",
[TAY] = "Transfer the value from the Accumulator, to the Y register.",
[TBA] = "Transfer the value from the Y register, to the Accumulator.",
[TSX] = "Transfer the value from the Stack pointer, to the X register.",
[TXA] = "Transfer the value from the X register, to the Accumulator.",
[TXS] = "Transfer the value from the X register, to the Stack pointer.",
[TXY] = "Transfer the value from the X register, to the Y register.",
[TYA] = "Transfer the value from the Y register, to the Accumulator.",
[TYX] = "Transfer the value from the Y register, to the X register.",
[WAI] = "WAIt for an interrupt",
[XAB] = "Bitwise XOR Accumulator, with B.",
[XOR] = "Bitwise XOR Accumulator, with operand."
};
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;
extern uint16_t inc_count;
struct bc {
uint64_t progsize;
uint64_t datasize;
};
typedef struct bc bytecount;
extern uint8_t defined;
extern uint8_t isfixup;
extern line *find_line(uint32_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, symbol *sym);
extern void assemble(line *ln, bytecount *bc, uint8_t dbg);
extern void cleanup();