summaryrefslogtreecommitdiff
path: root/programs/subasm-2.s
blob: f77116bf13fd565e1d0c6f37342c8e6b3fae0bbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
; SuBAsm
; The Sux Bootstrapped Assembler.
;
; by mr b0nk 500 <b0nk@b0nk.xyz>


.org $A000
; String Constants.
prg_name:
	.byte "SuBAsm"
ver_txt:
	.byte ", version "
ver_num:
	.byte "0.1"

; Directives.
dir:
	.byte "org"
	.byte "byte"
	.byte "word"
	.byte "dword"
	.byte "qword"
tok:
	.byte '.'
	.byte '#'
	.byte '$'
	.byte '%'
	.byte '('
	.byte ')'
	.byte ','

mne:
	.byte "AAB"
	.byte "ABA"
	.byte "ADC"
	.byte "AND"
	.byte "ARB"
	.byte "ASR"
	.byte "BCC"
	.byte "BCS"
	.byte "BEQ"
	.byte "BNE"
	.byte "BNG"
	.byte "BPO"
	.byte "BRK"
	.byte "BVC"
	.byte "BVS"
	.byte "CAB"
	.byte "CLC"
	.byte "CLI"
	.byte "CLV"
	.byte "CMP"
	.byte "CPB"
	.byte "CPS"
	.byte "CPX"
	.byte "CPY"
	.byte "DAB"
	.byte "DEB"
	.byte "DEC"
	.byte "DEX"
	.byte "DEY"
	.byte "DIV"
	.byte "ENT"
	.byte "INB"
	.byte "INC"
	.byte "INX"
	.byte "INY"
	.byte "JMP"
	.byte "JSL"
	.byte "JSR"
	.byte "LDA"
	.byte "LDB"
	.byte "LDX"
	.byte "LDY"
	.byte "LLB"
	.byte "LRB"
	.byte "LSL"
	.byte "LSR"
	.byte "MAB"
	.byte "MUL"
	.byte "NOP"
	.byte "OAB"
	.byte "ORA"
	.byte "PHA"
	.byte "PHB"
	.byte "PHP"
	.byte "PHX"
	.byte "PHY"
	.byte "PLA"
	.byte "PLB"
	.byte "PLP"
	.byte "PLX"
	.byte "PLY"
	.byte "RLB"
	.byte "ROL"
	.byte "ROR"
	.byte "RRB"
	.byte "RTI"
	.byte "RTL"
	.byte "RTS"
	.byte "SAB"
	.byte "SBC"
	.byte "SEC"
	.byte "SEI"
	.byte "STA"
	.byte "STB"
	.byte "STT"
	.byte "STX"
	.byte "STY"
	.byte "TAB"
	.byte "TAX"
	.byte "TAY"
	.byte "TBA"
	.byte "TSX"
	.byte "TXA"
	.byte "TXS"
	.byte "TXY"
	.byte "TYA"
	.byte "TYX"
	.byte "WAI"
	.byte "XAB"
	.byte "XOR"

; Start of program code.
.org $8600
subasm:
	ldb #0
	lda.w #tok
	sta.q ptr2
	tba
	jsl chk_tok

	jsl chk_mne
chk_tok:
	phy #2
	txy
	lda (ptr6), y
	cmp (ptr2), y
	ply #2
	cpx #7
	beq tok_false
tok_true:
	inb
tok_false:
	stb f
tok_end:
	ldb #0
	rtl

chk_mne:
	ply #2