.org $1000
prg_name:
.byte "SuBAsm"
ver_txt:
.byte ", version "
ver_num:
.byte "0.1"
dir:
.byte "org"
.byte "byte"
.byte "word"
.byte "dword"
.byte "qword"
mne:
.byte "CPS"
.byte "ADC"
.byte "AAB"
.byte "PHB"
.byte "PHP"
.byte "PHA"
.byte "PHY"
.byte "TAY"
.byte "PHX"
.byte "TAX"
.byte "TYX"
.byte "JMP"
.byte "SBC"
.byte "SAB"
.byte "PLB"
.byte "PLP"
.byte "PLA"
.byte "PLY"
.byte "TYA"
.byte "PLX"
.byte "TXA"
.byte "TXY"
.byte "JSR"
.byte "AND"
.byte "ABA"
.byte "STT"
.byte "TAB"
.byte "TSX"
.byte "BPO"
.byte "ORA"
.byte "OAB"
.byte "TBA"
.byte "SEI"
.byte "TXS"
.byte "BNG"
.byte "XOR"
.byte "XAB"
.byte "CLI"
.byte "BCS"
.byte "LSL"
.byte "LLB"
.byte "STB"
.byte "SEC"
.byte "STA"
.byte "STY"
.byte "STX"
.byte "BCC"
.byte "LSR"
.byte "LRB"
.byte "LDB"
.byte "CLC"
.byte "LDA"
.byte "LDY"
.byte "LDX"
.byte "BEQ"
.byte "ROL"
.byte "RLB"
.byte "SSP"
.byte "BNE"
.byte "ROR"
.byte "RRB"
.byte "CSP"
.byte "BVS"
.byte "MUL"
.byte "MAB"
.byte "SEV"
.byte "BVC"
.byte "DIV"
.byte "DAB"
.byte "CLV"
.byte "RTS"
.byte "CMP"
.byte "CAB"
.byte "CPY"
.byte "CPX"
.byte "CPB"
.byte "ENT"
.byte "RTI"
.byte "INC"
.byte "IAB"
.byte "INY"
.byte "INX"
.byte "DEC"
.byte "DBA"
.byte "DEY"
.byte "DEX"
.byte "WAI"
.byte "JSL"
.byte "ASR"
.byte "ARB"
.byte "NOP"
.byte "RTL"
.byte "BRK"
scr_row:
.byte $0
scr_col:
.byte $0
a:
.word $0
b:
.word $0
c:
.word $0
d:
.word $0
str_buf:
.org $2000
buf:
.org $2400
ptr1:
.qword $2500
ptr2:
.qword $2900
.org $C000
ctrl_reg:
.org $C001
scr:
.org $C002
kbd:
.org $0
reset:
cps
ldx.w
txs
ldy
jsr clr_buf
ldx.w
ldy
jmp print_title
read:
lda ctrl_reg
beq read
lda
sta ctrl_reg
jmp getchar
rset_x:
ldx
stx.w x
rts
print_title:
lda prg_name, x
beq print_ver
sta
inx
inc x
jmp print_title
print_ver
jsr rset_x
lda ver_txt, x
beq print_num
sta scr
inx
jmp print_ver
print_num:
lda ver_num, x
beq getline
sta scr
inx
jmp print_num
getline:
lda
sta scr
inc scr_row
lda
sta scr_col
inc y
jsr rset_x
jmp read
getchar:
lda kbd
cmp
beq esc
cmp
beq nl
cmp
beq bs
jsr echo
store_char:
sta buf, y
iny
jmp read
esc:
lda ctrl_reg
lda ctrl_reg
beq read
lda kbd
sta c
jsr isup
lda d
cmp
bne esc_end
jsr isdown
lda d
cmp
bne esc_end
lda
jsr isleft
lda d
cmp
bne esc_end
jsr isright
esc_end:
lda
sta d
jmp rset_a
isup:
lda scr_row
beq isup_done
lda c
cmp
beq up
isup_done:
rts
isdown:
lda scr_row
cmp
beq isdown_done
lda c
cmp
beq down
isdown_done:
rts
isright:
lda scr_col
cmp
beq isright_end
lda c
cmp
beq right
isright_end:
rts
isleft:
lda scr_col
beq isleft_done
lda c
cmp
beq left
isleft_done:
rts
up:
dec scr_row
jsr update_pos
lda
sta d
jmp isup_done
down:
inc scr_row
jsr update_pos
lda
sta d
jmp isdown_done
right:
inc scr_col
jsr update_pos
jmp isright_end
left:
dec scr_col
jsr update_pos
lda
sta d
jmp isleft_done
update_pos:
lda
sta scr
lda
sta scr
jsr getrow
jsr getcol
lda
sta scr
rts
getrow:
lda scr_row
div
adc
sta scr
tba
adc
sta scr
rts
getcol:
lda
sta scr
lda scr_col
div
adc
sta scr
tba
adc
sta scr
rts
nl:
sta scr
inc scr_row
lda
sta scr_col
sta buf, y
ldy.w
jsr parse
back:
sta scr
lda
sta buf, y
dey
dec scr_col
jmp read
bs:
cpy
beq read
jmp back
parse:
jsr getdir
jsr
rts
getdir:
iny
lda buf, y
jsr iswhite
bcs getdir
cmp
bne getdir_exit
jsr clr_ptr
getdir_end:
iny
lda buf, y
jsr iswhite
bcs getdir_cmp
ora
sta (ptr1), y
jmp getdir_end
gettok:
ply
iny
gettok2:
lda buf, y
jsr istoken
bcs gettok3
jmp gettok2
gettok3:
cmp
cmp
beq getaddr
getdir_cmp:
phy
ldy.w
tyx
getdir_cpl:
ldb dir, x
stb (ptr2), y
beq getdir_scmp
inx
iny
jmp getdir_cpl
getdir_scmp:
ldy
jsr strcmp
cpx
beq getdir_tok
getdir_exit:
rts
istoken:
cmp
beq istoken_f
cmp
beq istoken_f
cmp
beq istoken_f
cmp
beq istoken_f
cmp
beq istoken_f
sec
rts
istoken_f
clc
rts
iswhite:
cmp
beq iswhite_t
cmp
beq iswhite_t
clc
rts
iswhite_t:
sec
rts
rset_y:
ldy.w
jmp print_buf
print_buf:
lda buf, y
beq fin
sta scr
iny
jmp print_buf
spin:
nop
nop
nop
jmp spin
clr_buf:
lda
cpy.w
beq clr_end
sta buf, y
iny
jmp clr_buf
clr_sbuf:
lda
cpy.w
beq clr_end
sta str_buf, y
iny
jmp clr_sbuf
clr_end:
rts
echo:
tab
ldx scr_col
cpx
bne echo_print
cmp
beq linewrap
linewrap:
inc scr_row
ldx
stx scr_col
jsr update_pos
echo_print:
tba
sta scr
inc scr_col
sta buf, y
iny
rts
clr_ptr:
lda
cpy.w
beq ptr_end
sta (ptr1), y
sta (ptr2), y
iny
jmp clr_ptr
ptr_end:
rts
strcmp:
lda (ptr1), y
cmp (ptr2), y
bne strcmp_l1
tax
beq strcmp_l3
iny
bne strcmp
jmp strcmp
strcmp_l1:
bcs strcmp_l2
ldx
dex
rts
strcmp_l2:
ldx
strcmp_l3:
rts
.org $FFC0
.qword reset
.org $FF50
.qword spin
.qword spin
.qword spin
.qword spin
.qword spin
.qword spin
.qword spin
.org $FFA0
.qword irq_routine
.org $0
v
.org $100
v
.org $200
v
.org $300
v
.org $1000
v
.org $1100
v
.org $1200
v
.org $1300
v
.org $1400
v
q