-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathdirective
384 lines (314 loc) · 5.26 KB
/
directive
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
.PAGE 'DIRECTIVE'
; EQUATE AND ORG PROCESSING ****
H102 LDA #$FF ;-1
STA JORG
JSR LD6CE ;IF REST FIELD BLANK
BCC H103A
CMP #'='
BNE H103A
H121 INC ICOLP
LDX ICOLP
JSR LD670
H8804 JSR NFNDNB
BCS H104 ;NON-BLANK FOUND
LDA #7
JMP LTS2
H103A JMP H99
H104 JSR EVAL ;EVAL OPERAND FIELD
LDA #$13
DEY
BMI H105
BNE LD208
LDA #$11
LD208 JMP LD67A
H105 LDA JORG ;EQU OR ORG
BEQ H9
LDA IFLAGS+1
ROR A
BCC H150
LDA #$21
LDY #$FF
JSR LTINS2
LDX #0
TXA
BEQ LD227
H150 JSR LTINS
LDA IEXP ;IPC = IEXP
LDX IEXP+1
LD227 STA IPC+1
STX IPC
JMP ENDLN
; IS EQUATE****
H9 PLA ;RESTORE LABEL PORTION
STX ICSL ;RESTORE LENGTH
LDX #5
H8846 PLA
STA ISYM,X
DEX
BPL H8846
JSR NFIND
BCC H106
LDA KNVAL ;SEE IF VALUE IS THE SAME
CMP IEXP
BNE MR01
LDA KNVAL+1
CMP IEXP+1
BEQ H106A ;OK
MR01 LDA #2
JMP LTS2
H106 LDA IEXP
LDY IEXP+1
JSR NSERT
H106A JMP LD68A
; ASSEMBLER DIRECTIVES *****
; FIND WHAT DIRECTIVE TO PROCESS
H5 LDA #$14 ;ASM ERROR CODE
STA IERR
LDX ICSB ;START OF DIRECTIVE
INX ;SKIP PERIOD
JSR LD774 ;BUILD DIRECTIVE
H8847 CPX IMAXCL
BCS H8849
H8848 LDA ICRD,X
CMP #$20
BEQ H8849
INX
JMP H8847
H8849 STX ICOLP ;PNTR TO CHAR AFTER DIRECT
LDA #0 ;INIT COLUMN TO ZERO
STA J
BCS LD27C
LD279 JMP H9933 ;ERROR--BAD SYMBOL
.PAGE
; SEARCH TABLE FOR MATCH
;
; COMPARE DONE BACK-FRONT
; MATCH-IND JMP MADE TO PROCESS
; MISMATCH-POINTER POINTS TO NEXT
; VALID DIRECTIVE IN TABLE.
; NUMASM IS # DIRECT TO SEARCH.
; (TBLPTR) IS CURR DIRECTIVE
LD27C LDA #<ASMDIR
LDY #>ASMDIR
LDX #NUMSAV-1
LD282 JSR LD9EA
BCC LD279
; A MATCH-X USED TO LOC ADDR
TXA
ASL A ;*2 FOR ADDR TABLE INDEX
TAX
LDA ASMJMP,X ;LOW BYTE ADDR
STA TBLPTR
LDA ASMJMP+1,X ;HIGH BYTE ADDR
STA TBLPTR+1
LDA IFLAGS ;.OPT FLGS
JMP (TBLPTR) ;=>DIRECTIVE PROVESS
; BYTE, WORD, DBYTE PROCESSING ***
H111 LDA #1 ;*** .BYTE ***
BNE XXXL
H506 LDA #3 ;*** DOUBLE BYTE ***
BNE XXXL
H113 LDA #2 ;*** .WORD ***
XXXL STA JBYWOR
TAY
CPY #3 ;DBYTE ?
BNE H8809 ;NO
DEY
H8809 JSR NFNDNB ;NEXT NON-BLANK
BCS H18X ;NON-BLANK FOUND
JMP LD391
H18X STY CHAR
H18 LDX ICSB
JSR EVAL
DEY
BMI LD2DF ;RETURN =0
BEQ H8836 ;RETURN =1
JMP H29 ;RETURN =2
H8836 LDA #1 ;UNDEF'D SYM
STA IERR
XXXO CMP #1
BNE XXXM
LDY JBYWOR
STY CHAR
XXXM LDA IERR
LDY CHAR
JSR LTINS2
LDY CHAR
CPY #3
BNE H15
DEC CHAR
BNE H15
LD2DF JSR LDBF8
H14 LDA #4 ;GOOD RETURN
STA IERR
LDX JBYWOR
CPX #3
BNE H8812
LDA IEXP
JSR OBJOUT
LDA #1
JSR LDBFA
H8812 LDA IEXP+1
JSR OBJOUT
CPX #3
BNE LD303
LDA #2
BNE LD305
LD303 LDA #1
LD305 JSR LDBFA
CPX #2
BNE H8820
LDA IEXP
JSR OBJOUT ;IEXP IN MEMORY MAP
H8820 LDA IFLAGS+1
AND #$09
BNE XXXO
CPX #1
BNE XXXP
LDA IEXP
BNE XXXO
XXXP LDA #0
LDY CHAR
LD323 JSR LTINS2
H15 JSR LD722
BCS H8814
JMP ENDLN
H8814 CMP #','
BEQ LD336
INC ICOLP
BNE H15 ;MIGHT BE A PAREN
LD336 JSR LD66F
STX ICOLP
JSR NFNDNB
BCC H8844
JMP H18
H8844 JMP H99
; EXPRESSION HANDLER BOMBED
H29 LDA ICRD,X
LDY JBYWOR
CMP #$27 ;MIGHT BE ASCII (APPOSTROPHI)
BEQ H31 ;YES
H30 LDA #$13 ;BAD EXPRESSION
BNE LD323
; LOOKS LIKE ASCII
H31 CPX ICSB ;FIRST IN STRING
BNE H30
CPY #2
BCS H30
STX ICOLP ;COUNT BYTES GENERATED
LDA #0
STA J
H33 JSR LDBFA
INC ICOLP
LDX ICOLP
CPX IMAXCL ;OFF END OF CARD?
BCS H473 ;OFF CARD
H8815 LDA ICRD,X
CMP #$27 ;A QUOTE?
BNE H32 ;NO
INC ICOLP ;IMBEDDED QUOTE
LDX ICOLP
CPX IMAXCL
BCS H34 ;RAN OFF END OF CARD
H8821 LDA ICRD,X
CMP #$27 ;A QUOTE?
BNE H34 ;NO
H32 JSR OBJOUT
INC J ;COUNT OF ASCII CHARS
LDA J
JMP H33
H34 LDY J
LDA #0
BEQ LD323
H473 LDY J ;*** RAN OFF END OF CARD ***
LD391 LDA #7
JMP LTS1
LD396 CMP #',' ;A COMMA?
BNE LD3D1
INX
STX ICOLP
H301 JSR NFNDNB ;NEXT NON-BLANK
BCC LD3D1
JSR LD774 ;NEXT NONBLANK
BCS H8807
JMP H9933
H8807 LDA #<OPTDIR
H600 LDY #>OPTDIR
LDX #$14
JMP LD282
; END ***
; GENERATE ASCII STRINGS
H323 AND #127 ;CLEAR NOGEN BIT
BPL LD3CA
; DON'T GENERATE ASCII STRINGS
H302 ORA #128 ;SET NOGEN BIT
BNE LD3CA
; GENERATE ERROR FILE
H307 ORA #16 ;SET ERROR GEN BIT
BNE LD3CA
; DON'T GENERATE ERROR FILE
H308 AND #239 ;CLEAR ERROR GEN
JMP LD3CA
; GENERATE INTERFACE FILE
H309 ORA #8 ;SET INTERFACE FILE
BNE LD3CA
; DON'T GEN INTERFACE FILE
H310 AND #247 ;NO GEN INT FILE
LD3CA STA IFLAGS ;ALL DONE WITH THIS PARM
LD3CC JSR LD722
BCS LD396
LD3D1 JMP LD68A
; SKIP ***
H26 JSR NFNDNB
LDA #$CC
LTS2 LDY #$00
JMP LTS1
H10 JSR LTINS
LDA L23
BEQ LD3FC
LDX #MSG3-MSGS
JSR LDFE1
LDA LERCT+1
LDX LERCT
JSR WRAX
JSR OUTPUT
INC L23
JSR LDC4E
JMP COMIN
LD3FC INC L23
LDX #MSG5-MSGS
JSR LDFE1
JSR OUTPUT
LDA INFLG
CMP #$55
BEQ LD433
CMP #$4D
BNE LD417
LD411 JMP LD0C3
LD414 JSR TOGTA1
LD417 JSR REDOUT
CMP #$31
BEQ LD414
CMP #$32
BNE LD428
JSR TOGTA2
JMP LD417
LD428 CMP #$20
BNE LD417
LDA INFLG
CMP #$54
BNE LD411
LD433 JSR NFNDNB
BCC LD43E
JSR LDFA8
JMP LD0C3
LD43E LDY #0
LD440 LDA LA7,Y
STA HISTM,Y
JSR OUTDP1
INY
CPY #$05
BNE LD440
JSR LDFCC
JMP LD0C3
.END