; Enums. ; I/O constants. status = $100 ; Keyboard status. scr = $101 ; Character that is to be printed. kbd = $102 ; Character from the Keyboard. step = $110 ; Enables clock stepping, when set. ; Screen constants. maxrow = 23 ; Screen's row count. maxcol = 79 ; Screen's column count. MAX_SYM = $800 ; Max symbol size. OPNUM = 87 ; Instruction count. ; Directives. DIR_ORG = 0 ; Origin. DIR_BYTE = 1 ; Byte = 8 bits. DIR_WORD = 2 ; Word = 16 bits. DIR_DWORD = 3 ; Dword = 32 bits. DIR_QWORD = 4 ; Qword = 64 bits. DIR_INCL = 5 ; Include. DIR_RES = 6 ; Reserved bytes. ; Tokens. TOK_DIR = 0 ; Directive. TOK_LOCAL = 1 ; Local syobol. TOK_LABEL = 2 ; Label. TOK_SYM = 3 ; Symbol. TOK_EXPR = 4 ; Expression. TOK_CSV = 5 ; Comma separated value. TOK_STR = 6 ; String. TOK_CHAR = 7 ; Character. TOK_IND = 8 ; Indirect addressing. TOK_IMM = 9 ; Immediate data. TOK_MNE = 10 ; Opcode/Mnemonic. TOK_RS = 11 ; Register size prefix. TOK_COMM = 12 ; Comment. TOK_HEX = 13 ; Hex value. TOK_DEC = 14 ; Decimal value. TOK_BIN = 15 ; Binary value. TOK_INCL = 16 ; Include file. ; Pre-Tokens. PTOK_DOT = 0 ; . PTOK_AT = 1 ; @ PTOK_COLON = 2 ; : PTOK_EQU = 3 ; = PTOK_PLUS = 4 ; + PTOK_MINUS = 5 ; - PTOK_GT = 6 ; > PTOK_LT = 7 ; < PTOK_LBRAK = 8 ; ( PTOK_RBRAK = 9 ; ) PTOK_COMMA = 10 ; , PTOK_X = 11 ; x PTOK_Y = 12 ; y PTOK_S = 13 ; s PTOK_P = 14 ; p PTOK_DQUOT = 15 ; " PTOK_SQUOT = 16 ; ' PTOK_HASH = 17 ; # PTOK_SCOLN = 18 ; ; PTOK_DOLR = 19 ; $ PTOK_PRCNT = 20 ; % PTOK_NUM = 21 ; 0-9 PTOK_ALPH = 22 ; a-z A-Z PTOK_OTHR = 23 ; Everything else. ; Expressions. EXPR_PLUS = 0 ; Plus. EXPR_MINUS = 1 ; Minus. EXPR_LOW = 2 ; Lower half of address. EXPR_HIGH = 3 ; Upper half of address. EXPR_NONE = 4 ; No expression. ; RAM declarations. ; Linewrap table. .org $30000 bitabl: .res $1000 ; Screen buffer. buffer: .res $2000 ; Command buffer. cmd_buf: .res $400 ; Screen variables. .org 0 scr_row: .res 1 scr_col: .res 1 scr_trow: .res 1 scr_tcol: .res 1 scr_ptr: .res 2 scr_ptr2: .res 2 scr_ptr3: .res 2 ; Pseudo registers. rega: .res 1 regb: .res 1 regc: .res 1 regd: .res 1 rege: .res 1 regf: .res 1 regg: .res 1 ; This pseudo register is always zero. zero: .res 8 ; End of pseudo registers. end: .res 8 bitmask: .res 1 scr_str: .res 1 scr_end: .res 1 wrapped: .res 1 ; Pointers ptr: .res 8 ptr2: .res 8 ptr3: .res 8 ; Token table. .org $20000 tokline: .res $400 ; Program Counter. prg_cnt: .res 8 ; Hex digit string buffer. hex_str: .res 16 ; String buffer. strbuf: .res $80 ; Subroutine pointer. sub_ptr: .res 2 ; Indecies. idx0: .res 8 idx1: .res 8 idx2: .res 8 idx3: .res 8 ; Value buffer used by strtoull. valbuf: .res 8 ; Copy buffer used by delmcpy. cpybuf: .res 8 ; Current token line. ctok: .res 2 ; Last token line. ltok: .res 2 ; Lexeme type. lex_type: .res 1 ; Lexeme string. lexeme: .res $100 ; Symbol table. sym: .res $8000 ; Fixup table. ; Fixups are unresolved symbols. fix: .res $2000 ; ROM data declarations. .org $A000 ; String Literals/Constants. tok: .byte "dab" msg: .byte "oof, you divided a, and b on me.\n" ed_name: .byte "SuBEditor" ed_ver: .byte "1" ed_sver: .byte ".0.0" ver_str: .byte ", version " made: .byte "Created by, " author: .byte "mr b0nk 500" string2: .byte "You typed, " asm_name: .byte "SuBAsm" asm_ver: .byte "0.1" ; Directives. dir: .byte "org" .byte "byte" .byte "word" .byte "dword" .byte "qword" .byte "include" .byte "res" ; Short form Commands. sh_cmds: .byte "vlahirs" ; Commands. cmds: .byte "viewmem" .byte "list" .byte "asm" .byte "help" .byte "inst" .byte "run" .byte "set" ; Linewrap bitmask table. bits: .byte $80, $40, $20, $10, $08, $04, $02, $01 ; Instruction mnemonics, and opcodes. ; Legend. ; mne = Mnemonic. ; imm = Immediate data. ; zm = Zero Matrix. ; zmx = Zero Matrix, indexed with X. ; zmy = Zero Matrix, indexed with Y. ; ind = Indirect. ; idx = Indexed Indirect. ; idy = Indirect Indexed. ; abs = Absolute. ; rel = Relative. ; imp = Implied. mne: ; mne imm, zm, zmx, zmy, ind, idx, idy, abs, rel, imp .byte "ADC", $01, $06, $FF, $FF, $FF, $FF, $FF, $04, $FF, $FF .byte "AAB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $02 .byte "ABA", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $22 .byte "ADC", $01, $06, $FF, $FF, $FF, $FF, $FF, $04, $FF, $FF .byte "AND", $21, $26, $FF, $FF, $FF, $FF, $FF, $24, $FF, $FF .byte "ARB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $F2 .byte "ASR", $F1, $F6, $FF, $FF, $FF, $FF, $FF, $F4, $FF, $FF .byte "BCC", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $80, $FF .byte "BCS", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $70, $FF .byte "BEQ", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $90, $FF .byte "BNE", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $A0, $FF .byte "BNG", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $60, $FF .byte "BPO", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $50, $FF .byte "BRA", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $D0, $FF .byte "BRK", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $68 .byte "BVC", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C0, $FF .byte "BVS", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $B0, $FF .byte "CAB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $B2 .byte "CLC", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $08 .byte "CLI", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $28 .byte "CLV", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $48 .byte "CMP", $B1, $B6, $FF, $FF, $25, $7D, $7C, $B4, $FF, $FF .byte "CPB", $2A, $2D, $FF, $FF, $55, $AD, $AC, $2C, $FF, $FF .byte "CPS", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $00 .byte "CPX", $3A, $4D, $FF, $FF, $FF, $FF, $FF, $3C, $FF, $FF .byte "CPY", $4A, $3D, $FF, $FF, $FF, $FF, $FF, $4C, $FF, $FF .byte "DAB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $A2 .byte "DEB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C2 .byte "DEC", $FF, $0D, $FF, $FF, $FF, $FF, $FF, $0C, $FF, $0A .byte "DEX", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $09 .byte "DEY", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $29 .byte "DIV", $A1, $A6, $FF, $FF, $FF, $FF, $FF, $A4, $FF, $FF .byte "INB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $D2 .byte "INC", $FF, $1D, $FF, $FF, $FF, $FF, $FF, $1C, $FF, $1A .byte "INX", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $19 .byte "INY", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $39 .byte "JMP", $FF, $30, $FF, $FF, $B5, $FF, $FF, $10, $FF, $FF .byte "JSR", $FF, $40, $FF, $FF, $A5, $FF, $FF, $20, $FF, $FF .byte "LDA", $C1, $C6, $B8, $78, $05, $5D, $5C, $C4, $FF, $FF .byte "LDB", $D1, $D6, $D8, $98, $35, $8D, $8C, $D4, $FF, $FF .byte "LDX", $B9, $BD, $FF, $FF, $85, $FF, $FF, $BC, $FF, $FF .byte "LDY", $E1, $E6, $FF, $FF, $65, $FF, $FF, $E4, $FF, $FF .byte "LLB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $52 .byte "LRB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $62 .byte "LSL", $51, $56, $FF, $FF, $FF, $FF, $FF, $54, $FF, $FF .byte "LSR", $61, $66, $FF, $FF, $FF, $FF, $FF, $64, $FF, $FF .byte "MAB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $92 .byte "MUL", $91, $96, $FF, $FF, $FF, $FF, $FF, $94, $FF, $FF .byte "NOP", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $EA .byte "OAB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $32 .byte "ORA", $31, $36, $FF, $FF, $FF, $FF, $FF, $34, $FF, $FF .byte "PHA", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $79 .byte "PHB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $99 .byte "PHP", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $59 .byte "PHX", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $E9 .byte "PHY", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $C9 .byte "PLA", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $89 .byte "PLB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $A9 .byte "PLP", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $69 .byte "PLX", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $F9 .byte "PLY", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $D9 .byte "RLB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $72 .byte "ROL", $71, $76, $FF, $FF, $FF, $FF, $FF, $74, $FF, $FF .byte "ROR", $81, $86, $FF, $FF, $FF, $FF, $FF, $84, $FF, $FF .byte "RRB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $82 .byte "RTI", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $F0 .byte "RTS", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $E0 .byte "SAB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $12 .byte "SBC", $11, $16, $FF, $FF, $FF, $FF, $FF, $14, $FF, $FF .byte "SEC", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $18 .byte "SEI", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $38 .byte "STA", $FF, $CD, $C8, $88, $15, $6D, $6C, $CC, $FF, $FF .byte "STB", $FF, $DD, $E8, $A8, $45, $9D, $9C, $DC, $FF, $FF .byte "STX", $FF, $FD, $FF, $FF, $95, $FF, $FF, $FC, $FF, $FF .byte "STY", $FF, $ED, $FF, $FF, $75, $FF, $FF, $EC, $FF, $FF .byte "TAB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $5A .byte "TAX", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $9A .byte "TAY", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $7A .byte "TBA", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $6A .byte "TSX", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $DA .byte "TXA", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $AA .byte "TXS", $FA, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF .byte "TXY", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $CA .byte "TYA", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $8A .byte "TYX", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $BA .byte "WAI", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $58 .byte "XAB", $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $42 .byte "XOR", $41, $46, $FF, $FF, $FF, $FF, $FF, $44, $FF, $FF ; Command subroutine table. cmd_srt: .word viewmem .word list .word asm .word help .word inst .word run .word set ; Jump table for parsing pre-tokens. swtab: .word ptok_dot ; PTOK_DOT .word ptok_at ; PTOK_AT .word ptok_col ; PTOK_COLON .word ptok_equ ; PTOK_EQU .word ptok_plus ; PTOK_PLUS .word ptok_min ; PTOK_MINUS .word ptok_gt ; PTOK_GT .word ptok_lt ; PTOK_LT .word ptok_lbrk ; PTOK_LBRAK .word ptok_rbrk ; PTOK_RBRAK .word ptok_com ; PTOK_COMMA .word ptok_xr ; PTOK_X .word ptok_yr ; PTOK_Y .word ptok_sp ; PTOK_S .word ptok_pc ; PTOK_P .word ptok_dqu ; PTOK_DQUOT .word ptok_squ ; PTOK_SQUOT .word ptok_hash ; PTOK_HASH .word ptok_scol ; PTOK_SCOLN .word ptok_dolr ; PTOK_DOLR .word ptok_prcn ; PTOK_PRCNT .word ptok_num ; PTOK_NUM .word ptok_alph ; PTOK_ALPH .word ptok_othr ; PTOK_OTHR ; Hex character table. hex_char: .byte "0123456789ABCDEF" ; Compare, and return table for pre-tokens. ptok_tab: .byte ".@:=+-><(),xysp\"\'#;$%" ; Compare, and return table for isdelm. dtab: .byte "\n,\"\' \\" ; Compare, and return table for isdelm2. dtab2: .byte "),.+<>-=;\n"