; 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_PIPE = 8 ; | PTOK_LBRAK = 9 ; ( PTOK_RBRAK = 10 ; ) PTOK_COMMA = 11 ; , PTOK_X = 12 ; x PTOK_Y = 13 ; y PTOK_S = 14 ; s PTOK_P = 15 ; p PTOK_DQUOT = 16 ; " PTOK_SQUOT = 17 ; ' PTOK_HASH = 18 ; # PTOK_SCOLN = 19 ; ; PTOK_DOLR = 20 ; $ PTOK_PRCNT = 21 ; % PTOK_NUM = 22 ; 0-9 PTOK_ALPH = 23 ; a-z A-Z PTOK_OTHR = 24 ; 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. ; Addressing modes. IMM = 1 << 0 ; Immediate Data. ZM = 1 << 1 ; Zero Matrix. ZMX = 1 << 2 ; Zero Matrix, indexed with X. ZMY = 1 << 3 ; Zero Matrix, indexed with Y. IND = 1 << 4 ; Indirect. INDX = 1 << 5 ; Indexed Indirect. INDY = 1 << 6 ; Indirect Indexed. ABS = 1 << 7 ; Absolute. REL = 1 << 8 ; Relative. BREG = 1 << 9 ; B Register. IMPL = 1 << 10 ; Implied. INDX2 = 1 << 11 ; Special case of INDX that uses the indirect table. ZM2 = 1 << 12 ; Special case of Zero Matrix used by JMP, and JSR. ; 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. ; Format. ; ; String : Mnemonic. ; 2 bytes: Addressing mode bits. ; 1 byte : Base value, used to generate the actual opcode. mne: .byte "ADC" .word IMM|ZM|ABS|BREG .byte $01 .byte "AND" .word IMM|ZM|ABS|BREG .byte $41 .byte "ASR" .word IMM|ZM|ABS|BREG .byte $62 .byte "BCC" .word REL .byte $A0 .byte "BCS" .word REL .byte $90 .byte "BEQ" .word REL .byte $B0 .byte "BNE" .word REL .byte $C0 .byte "BNG" .word REL .byte $80 .byte "BPO" .word REL .byte $70 .byte "BRA" .word REL .byte $F0 .byte "BRK" .word IMPL .byte $69 .byte "BVC" .word REL .byte $E0 .byte "BVS" .word REL .byte $D0 .byte "CLC" .word IMPL .byte $09 .byte "CLI" .word IMPL .byte $29 .byte "CLV" .word IMPL .byte $49 .byte "CMP" .word IMM|ZM|IND|INDY|ABS|BREG|INDX2 .byte $82 .byte "CPB" .word IMM|ZM|IND|INDY|ABS|INDX2 .byte $04 .byte "CPS" .word IMPL .byte $00 .byte "CPX" .word IMM|ZM|IND|ABS .byte $24 .byte "CPY" .word IMM|ZM|IND|ABS .byte $44 .byte "DEB" .word IMPL .byte $99 .byte "DEC" .word IMPL|ZM|ABS .byte $84 .byte "DEX" .word IMPL .byte $B9 .byte "DEY" .word IMPL .byte $79 .byte "DIV" .word IMM|ZM|ABS|BREG .byte $42 .byte "INB" .word IMPL .byte $A9 .byte "INC" .word IMPL|ZM|ABS .byte $A4 .byte "INX" .word IMPL .byte $C9 .byte "INY" .word IMPL .byte $89 .byte "JMP" .word ABS|IND|ZM2 .byte $00 .byte "JSR" .word ABS|IND|ZM2 .byte $20 .byte "LDA" .word IMM|ZM|ZMX|ZMY|IND|INDX|INDY|ABS .byte $C2 .byte "LDB" .word IMM|ZM|ZMX|ZMY|IND|INDX|INDY|ABS .byte $E2 .byte "LDX" .word IMM|ZM|IND|ABS .byte $64 .byte "LDY" .word IMM|ZM|IND|ABS .byte $A2 .byte "LSL" .word IMM|ZM|ABS|BREG .byte $A1 .byte "LSR" .word IMM|ZM|ABS|BREG .byte $C1 .byte "MUL" .word IMM|ZM|ABS|BREG .byte $22 .byte "NOP" .word IMPL .byte $EA .byte "ORA" .word IMM|ZM|ABS|BREG .byte $61 .byte "PHA" .word IMPL .byte $8E .byte "PHB" .word IMPL .byte $AE .byte "PHP" .word IMPL .byte $6E .byte "PHX" .word IMPL .byte $EE .byte "PHY" .word IMPL .byte $CE .byte "PLA" .word IMPL .byte $9E .byte "PLB" .word IMPL .byte $BE .byte "PLP" .word IMPL .byte $7E .byte "PLX" .word IMPL .byte $FE .byte "PLY" .word IMPL .byte $DE .byte "ROL" .word IMM|ZM|ABS|BREG .byte $E1 .byte "ROR" .word IMM|ZM|ABS|BREG .byte $02 .byte "RTI" .word IMPL .byte $60 .byte "RTS" .word IMPL .byte $50 .byte "SBC" .word IMM|ZM|ABS|BREG .byte $21 .byte "SEC" .word IMPL .byte $19 .byte "SEI" .word IMPL .byte $39 .byte "STA" .word ZM|ZMX|ZMY|IND|INDX|INDY|ABS .byte $28 .byte "STB" .word ZM|ZMX|ZMY|IND|INDX|INDY|ABS .byte $48 .byte "STX" .word ZM|IND|ABS .byte $68 .byte "STY" .word ZM|IND|ABS .byte $08 .byte "TAB" .word IMPL .byte $0A .byte "TAX" .word IMPL .byte $4A .byte "TAY" .word IMPL .byte $2A .byte "TBA" .word IMPL .byte $1A .byte "TSX" .word IMPL .byte $8A .byte "TXA" .word IMPL .byte $5A .byte "TXS" .word IMPL|IMM .byte $9A .byte "TXY" .word IMPL .byte $7A .byte "TYA" .word IMPL .byte $3A .byte "TYX" .word IMPL .byte $6A .byte "WAI" .word IMPL .byte $59 .byte "XOR" .word IMM|ZM|ABS|BREG .byte $81 ; 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_pipe ; PTOK_PIPE .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"