Subversion Repositories MB01 Project

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 - 1
  Tue Jul 17 11:00:24 2018                                                                                               Page    1
2
 
3
 
4
 
5
 
6
 
7
 
8
 
9
          2500 A.D. 65816 Macro Assembler #26960 - Version 5.02g
10
          -----------------------------------------------------
11
 
12
                       Input  Filename : src\FF\masmx.asm
13
                       Output Filename : obj\FF\masmx.obj
14
                       Listing Has Been Relocated
15
 
16
 
17
 2585                        	.LIST		on
18
 2586
19
 2587                        	;;	.INCLUDE inc\dirp00.inc
20
 2588  F8FFB1                		.INCLUDE inc\dirp01.inc
21
 2589                        	;----------------------------------------------------------
22
 2590                        	; DIRP02.ASM
23
 2591                        	; PROGETTO: B1601
24
 2592                        	;
25
 2593                        	; Variabili in Direct Page $01
26
 2594                        	;----------------------------------------------------------
27
 2595
28
 2596                        	; sezione COMMON -- questo permette di includere il file in piu' file
29
 2597
30
 2598
31
 2599                        	.LIST on
32
 2600
33
 2601          000060        	KBDBUFLEN	.EQU	96		; dimensione buffer di tastiera
34
 2602
35
 2603                        	DIRP01:	.SECTION page0, ref_only, common	;Direct-Page 01
36
 2604
37
 2605  000000                		.ABSOLUTE		;; inizia sempre da $00
38
 2606  000000                		.ORG		0x00
39
 2607
40
 2608  000000
41
 2609  000000                	KbdBuf		.DS	KBDBUFLEN	; buffer della tastiera
42
 2610  000060  00            	KbdITail	.DB			; coda buffer tastiera
43
 2611  000061  00            	KbdIHead	.DB			; testa buffer tastiera
44
 2612  000062  00            	KbdCnt		.DB			; numero bytes nel buffer
45
 2613  000063  00            	KbdShift	.DB
46
 2614  000064  00            	KbdFlag		.DB
47
 2615  000065  00            	KbdToggle	.DB
48
 2616  000066  00            	KbdSt		.DB			; status tastiera dopo reset
49
 2617  000067  00            	PS2Ctl		.DB			; flag controller PS2 keyboard
50
 2618
51
 2619  000068  00            	LCDFlag		.DB
52
 2620  000069  00            	LCDTmp		.DB
53
 2621  00006A  0000          	LCDVal		.DW
54
 2622
55
 2623  00006C  00            	VBBFlag		.DB		; flag video board
56
 2624  00006D  00            	VBBRam		.DB		; flag video RAM
57
 2625
58
 2626  00006E  00            	ScnLinTmp	.DB
59
 2627  00006F  00            	ScnChBase	.DB		; base video ram VDC
60
 2628  000070  00            	ScnAttBase	.DB		; base ram attributi VDC
61
 2629  000071  00            	ScnCursMode	.DB		; VDC cursore default
62
 2630  000072  00            	ScnSaveAttr	.DB
63
  Tue Jul 17 11:00:24 2018                                                                                               Page    2
64
 
65
 
66
 
67
 
68
 2631  000073  00            	ScnInsert	.DB
69
 2632  000074  00            	ScnAutoIns	.DB		; bit 7 -> autoins - bit 6 -> modo input
70
 2633  000075  00            	ScnScroll	.DB
71
 2634  000076  00            	ScnMaxRow	.DB		; max. righe finestra (-1)
72
 2635  000077  00            	ScnMaxCols	.DB		; max. colonne finestra (-1)
73
 2636
74
 2637  000078                	ScnMapTabs1	.DS	10
75
 2638  000082                	ScnMapTabs2	.DS	4
76
 2639  000086
77
 2640  000086  0000          	ScnPtr		.DW		; puntatore video ram linea corrente
78
 2641  000088  00            			.DB
79
 2642
80
 2643  000089  00            	ScnFiltLen	.DB		; lunghezza set caratteri filtro
81
 2644
82
 2645  00008A  0000          	ScnAtPtr	.DW		; puntatore attributi ram linea corrente
83
 2646  00008C  00            			.DB
84
 2647
85
 2648  00008D  00            	ScnTmpx		.DB		; temporaneo: durante put char
86
 2649  00008E
87
 2650  00008E  00            	ScnTop		.DB		; riga superiore finestra
88
 2651  00008F  00            	ScnLeft		.DB		; colonna sinistra finestra
89
 2652  000090  00            	ScnBottom	.DB		; riga inferiore finestra
90
 2653  000091  00            	ScnRight	.DB		; colonna destra finestra
91
 2654  000092  00            	ScnAttr		.DB		; attributo default
92
 2655  000093  00            	ScnAttr2	.DB		; attributo alternativo
93
 2656  000094  00            	ScnRow		.DB		; riga cursore
94
 2657  000095  00            	ScnCol		.DB		; colonna cursore
95
 2658  000096  00            	ScnRowStart	.DB		; riga di start input
96
 2659  000097  00            	ScnInput	.DB		; riga di fine input
97
 2660  000098  00            	ScnColStart	.DB		; colonna di start input
98
 2661  000099  00            	ScnSaveX	.DB
99
 2662  00009A  00            	ScnSaveY	.DB
100
 2663  00009B  00            	ScnTmpL		.DB
101
 2664  00009C  00            	ScnTmpH		.DB
102
 2665  00009D  00            	ScnSaveRow	.DB
103
 2666  00009E  00            	ScnSaveCol	.DB
104
 2667  00009F  00            	ScnCurChr	.DB
105
 2668  0000A0  00            	ScnLstChr	.DB
106
 2669  0000A1  00            	ScnCR		.DB
107
 2670  0000A2  0000          	ScnPrm		.DW		; puntatore long utilizzato da print imm
108
 2671  0000A4  00            			.DB		; banco puntatore ScnPrm
109
 2672  0000A5  00            	ScnMode		.DB		; flag modo schermo
110
 2673
111
 2674  0000A6                	ScnPtr1		LP
112
 2675
113
 2676  0000A9  00            	ScnDefCol	.DB		; default foreground color
114
 2677
115
 2678  0000AA                	ScnPtr2		LP
116
 2679
117
 2680  0000AD  00            	ScnDefBkgCol	.DB		; default background color
118
 2681  0000AE  00            	ScnInpRow	.DB		; modo input line: riga start input
119
 2682  0000AF  00            	ScnInpCol	.DB		; modo input line: colonna start input
120
 2683  0000B0  00            	ScnLstRow	.DB		; modo input line: riga stop input
121
 2684  0000B1  00            	ScnLstCol	.DB		; modo input line: colonna stop input
122
 2685  0000B2  00            	ScnFlag		.DB		; Bit 7: input line - Bit 6: input riga unica
123
 2686  0000B3  00            	ScnMask		.DB		; flag tasti funzione editor di linea
124
 2687  0000B4  00            	ScnFilt		.DB		; filtro tasti editor di linea
125
  Tue Jul 17 11:00:24 2018                                                                                               Page    3
126
 
127
 
128
 
129
 
130
 2688  0000B5  00            	ScnCntrl	.DB		; flag ASCII/CONTROL
131
 2689                        	;DflTxtIn	.DB		; device di default text input
132
 2690                        	;DflTxtOut	.DB		; device di default text output
133
 2691  0000B6
134
 2692          000047        	SCNCLRLEN	.EQU	($ - ScnLinTmp - 1)
135
 2693
136
 2694                        	;SCNCLRLEN	.EQU	(DflTxtOut - ScnLinTmp)
137
 2695
138
 2696                        	; variabili monitor
139
 2697  0000B6  00            	SMAddrL		.DB	; address low/high
140
 2698  0000B7  00            	SMAddrH		.DB
141
 2699  0000B8  00            	SMAddrK		.DB	; address bank
142
 2700  0000B9  00            	SMFlag32	.DB	; flag parametro 32 bit
143
 2701  0000BA  00            	SMTmpL		.DB	; temp. low/high
144
 2702  0000BB  00            	SMTmpH		.DB
145
 2703  0000BC  00            	SMTmpK		.DB	; temp. bank
146
 2704  0000BD  00            	SMTmpKK		.DB	; high byte param. 32 bit
147
 2705  0000BE  00            	SMSizeL		.DB	; size low/high
148
 2706  0000BF  00            	SMSizeH		.DB
149
 2707  0000C0  00            	SMSizeK		.DB	; size bank
150
 2708  0000C1  00            	SMXAddrL	.DB	; address low/high XM
151
 2709  0000C2  00            	SMXAddrH	.DB
152
 2710  0000C3  00            	SMXAddrK	.DB	; address bank XM
153
 2711  0000C4  00            	SMbndx		.DB	; indice input buffer
154
 2712  0000C5  00            	SMnprm		.DB	; numero parametri riga di comando
155
 2713  0000C6  00            	SMdumb		.DB
156
 2714  0000C7  00            	SMkr		.DB
157
 2715  0000C8  0000          	SMpc		.DW
158
 2716  0000CA  00            	SMsr		.DB
159
 2717  0000CB  00            	SMbr		.DB
160
 2718  0000CC  0000          	SMdp		.DW
161
 2719  0000CE  0000          	SMac		.DW
162
 2720  0000D0  0000          	SMxr		.DW
163
 2721  0000D2  0000          	SMyr		.DW
164
 2722  0000D4  0000          	SMsp		.DW
165
 2723
166
 2724  0000D6  00            	SMAuxL		.DB
167
 2725  0000D7  00            	SMAuxH		.DB
168
 2726
169
 2727  0000D8  00            	asmlong		.DB	; flag for CPU in 16 mode
170
 2728                        				; <7> -> A/M in 16 bit mode
171
 2729                        				; <6> -> X/Y in 16 bit mode
172
 2730  0000D9  00            	asmcpu		.DB	; <7> -> 8 bit family
173
 2731                        				; <6> -> 65C02 cmos version
174
 2732
175
 2733  0000DA  00            	SMctx		.DB	; context (if = $00 no quit command)
176
 2734  0000DB                	SMrsm		LP	; long pointer to resume caller context
177
 2735
178
 2736  0000DE  00            	rtcadr		.DB	; rtc internal ram address
179
 2737  0000DF  00            	rtcbnk		.DB	; RTC internal bank ram
180
 2738  0000E0  00            	cmdlin		.DB	;
181
 2739  0000E1  00            	SMesc		.DB
182
 2740
183
 2741  0000E2                	SMXTmp:		.DS	26	; 26 bytes tmp
184
 2742
185
 2743          0000E2        	SMTmp2		.EQU	SMXTmp
186
 2744          0000E4        	SMTmp3		.EQU	SMXTmp+2
187
  Tue Jul 17 11:00:24 2018                                                                                               Page    4
188
 
189
 
190
 
191
 
192
 2745          0000E6        	SMdwTmp1	.EQU	SMXTmp+4
193
 2746          0000EA        	SMdwTmp2	.EQU	SMXTmp+8
194
 2747          0000EE        	SMFsrc		.EQU	SMXTmp+12	; source bank for flash update
195
 2748          0000EF        	SMFflag		.EQU	SMXTmp+13	; flag file for flash update
196
 2749          0000F0        	SMXPos2		.EQU	SMXTmp+14
197
 2750          0000F1        	SMYPos2		.EQU	SMXTmp+15
198
 2751          0000F2        	SMXPos3		.EQU	SMXTmp+16
199
 2752          0000F3        	SMYPos3		.EQU	SMXTmp+17
200
 2753                        	;SMAuxL		.EQU	SMXTmp+18
201
 2754                        	;SMAuxH		.EQU	SMXTmp+19
202
 2755          0000F6        	SMXPos		.EQU	SMXTmp+20
203
 2756          0000F7        	SMYPos		.EQU	SMXTmp+21
204
 2757          0000F8        	SMdwTmp3	.EQU	SMXTmp+22
205
 2758
206
 2759          0000E2        	atcmd		.EQU	SMXTmp		; save @ command
207
 2760          0000E3        	atnum		.EQU	SMXTmp+1	; @ command index
208
 2761          0000E4        	atflag		.EQU	SMXTmp+2	; @ L,S,V,R,W start address flag
209
 2762          0000E5        	atbnk		.EQU	SMXTmp+3	; @ L,S,V,R,W bank
210
 2763          0000E6        	atstr		.EQU	SMXTmp+4	; @ command string start (word)
211
 2764          0000E8        	atstart		.EQU	SMXTmp+6	; @ L,S,V,R,W start address (word)
212
 2765          0000EA        	atend		.EQU	SMXTmp+8	; @ S,W end address (word)
213
 2766          0000EC        	atbuf		.EQU	SMXTmp+10	; @ local buffer pointer (word)
214
 2767          0000EE        	atipb		.EQU	SMXTmp+12	; @ bank of input buffer
215
 2768          0000EF        	atdir		.EQU	SMXTmp+13	; @ load dir flag
216
 2769          0000F0        	atptr		.EQU	SMXTmp+14	; @ load dir pointer (word)
217
 2770          0000F2        	atsiz		.EQU	SMXTmp+16	; @ buffer size (word)
218
 2771          0000F5        	atlp		.EQU	SMXTmp+19	; @ long pointer
219
 2772          0000F8        	atsa		.EQU	SMXTmp+22	; @ sa
220
 2773
221
 2774          0000E2        	btmpx		.EQU	SMXTmp		; asc2bin conversion
222
 2775          0000E3        	brtcsec		.EQU	SMXTmp+1
223
 2776          0000E4        	brtcmin		.EQU	SMXTmp+2
224
 2777          0000E5        	brtchour	.EQU	SMXTmp+3
225
 2778          0000E6        	brtcday		.EQU	SMXTmp+4
226
 2779          0000E7        	brtcmonth	.EQU	SMXTmp+5
227
 2780          0000E8        	brtcyear	.EQU	SMXTmp+6
228
 2781          0000E9        	brtcct		.EQU	SMXTmp+7
229
 2782
230
 2783
231
 2784  0000FC                		.RELATIVE
232
 2785
233
 2786                        		.ENDS
234
 2787
235
 2791                        		.LIST on
236
 2792
237
 2793                        	; encoded addressing mode for 65C816
238
 2794          000000        	AIMPL		.EQU	$00	; implied/accumulator
239
 2795          000001        	AIMM		.EQU	$01	; # immediate
240
 2796          000002        	ADP		.EQU	$02	; DP direct page
241
 2797          000003        	AABS		.EQU	$03	; absolute
242
 2798          000004        	ALONG		.EQU	$04	; absolute long
243
 2799          000005        	ALONGX		.EQU	$05	; absolute long, X
244
 2800          000006        	AXIND		.EQU	$06	; (DP,X)
245
 2801          000007        	AYIND		.EQU	$07	; (DP),Y
246
 2802          000008        	ADPX		.EQU	$08	; DP,X
247
 2803          000009        	AABSX		.EQU	$09	; absolute, X
248
 2804          00000A        	AABSY		.EQU	$0A	; absolute, Y
249
  Tue Jul 17 11:00:24 2018                                                                                               Page    5
250
 
251
 
252
 
253
 
254
 2805          00000B        	ABIND		.EQU	$0B	; absolute indirect (abs)
255
 2806          00000C        	ADPY		.EQU	$0C	; DP,Y
256
 2807          00000D        	AREL		.EQU	$0D	; relative short
257
 2808          00000E        	ABXI		.EQU	$0E	; absolute indirect, X (abs,X)
258
 2809          00000F        	AIND		.EQU	$0F	; (DP)
259
 2810          000010        	ASTK		.EQU	$10	; stack relative, S
260
 2811          000011        	ALIND		.EQU	$11	; indirect long [DP]
261
 2812          000012        	AYLIND		.EQU	$12	; [DP],Y
262
 2813          000013        	AYSTK		.EQU	$13	; (rel,S),Y
263
 2814          000014        	AMOV		.EQU	$14	; move
264
 2815          000015        	A16R		.EQU	$15	; relative 16 bit
265
 2816          000016        	AJML		.EQU	$16	; jml [absolute]
266
 2817          000017        	A16IMM		.EQU	$17	; # immediate 16 bit
267
 2818
268
 2819                        	; modified encoding for immediate addressing 8/16 bit
269
 2820          000041        	AXIMM		.EQU	($40 + AIMM)	; X/Y immediate
270
 2821          000081        	AMIMM		.EQU	($80 + AIMM)	; A/M immediate
271
 2822
272
 2823                        	; equates from page 0 -- local temporary variables from SMXTmp area
273
 2824          0000E2        	asmpr		.EQU	SMXTmp		; word:	printing mask
274
 2825          0000E4        	asmmode		.EQU	SMXTmp+2	; byte: addessing mode
275
 2826          0000E2        	TSTR		.EQU	SMXTmp		; byte: 3 bytes for store mnemonic
276
 2827          0000E2        	XBUF		.EQU	SMXTmp		; byte: 18 bytes for store command
277
 2828          0000E5        	asmnb		.EQU	SMXTmp+3	; byte: number of bytes of instruction
278
 2829          0000E6        	tmpl		.EQU	SMXTmp+4	; byte: temp
279
 2830          0000E7        	tmph		.EQU	SMXTmp+5	; byte: temp
280
 2831          0000E8        	asmmov		.EQU	SMXTmp+6	; byte: flag move
281
 2832          0000E8        	asmbit		.EQU	SMXTmp+6	; byte: flag rmb/smb/bbr/bbs
282
 2833          0000E9        	asmrel		.EQU	SMXTmp+7	; byte: <7> -> relative, <6> -> rel 16
283
 2834          0000E9        	asmxop		.EQU	SMXTmp+7	; byte: bit number in RMB/SMB/BBR/BBS
284
 2835          0000EA        	asmstf		.EQU	SMXTmp+8	; byte: rep/sep flag
285
 2836          0000EB        	asmcnt		.EQU	SMXTmp+9	; byte: temp. counter
286
 2837          0000EC        	asmtmpL		.EQU	SMXTmp+10	; byte: used for 65C02
287
 2838          0000ED        	asmtmpH		.EQU	SMXTmp+11	; byte: used for 65C02
288
 2839          0000EE        	P0TMP		.EQU	SMXTmp+12	; byte: 14 bytes for assempling mask
289
 2840
290
 2841                        		.CODEFF
291
 2842                        		.LONGA off
292
 2843                        		.LONGI off
293
 2844
294
 2845                        		.EXTERN PrintAddr, PrintByte, PrintWord, PrintHex, PrintHex1, GetCurCh
295
 2846                        		.EXTERN TmpToAddr, GetParm, CkStop, ErrCls2, DecTmpPtrA, SubTmpAddr
296
 2847                        		.EXTERN FF_Byte2Hex
297
 2848
298
 2849                        		.GLOBAL Cmd_d, Cmd_a
299
 2850
300
 2851  FF1CD8                	test:
301
 2852  FF1CD8  EA            		nop
302
 2853  FF1CD9  EA            		nop
303
 2854                        		;CPU08
304
 2855  FF1CDA  A9 FF         	?02:	lda	#$FF
305
 2856  FF1CDC  AA            		tax
306
 2857  FF1CDD  A8            		tay
307
 2858  FF1CDE  62 F9 FF      		per	-($+3-?02)
308
 2859  FF1CE1  62 10 00      		per	-($+3-?04)
309
 2860  FF1CE4  62 E5 1C      		per	?04
310
 2861  FF1CE7  AA            	?00:	tax
311
  Tue Jul 17 11:00:24 2018                                                                                               Page    6
312
 
313
 
314
 
315
 
316
 2862  FF1CE8  A8            		tay
317
 2863  FF1CE9  9A            		txs
318
 2864  FF1CEA  82 ED FF      		brl	?02
319
 2865  FF1CED  82 04 00      		brl	?04
320
 2866  FF1CF0  EA            		nop
321
 2867  FF1CF1  EA            		nop
322
 2868  FF1CF2  EA            		nop
323
 2869  FF1CF3  EA            		nop
324
 2870  FF1CF4  AA            	?04:	tax
325
 2871  FF1CF5  48            		pha
326
 2872  FF1CF6  68            		pla
327
 2873
328
 2874                        	;---------------------------------------------------------------------------
329
 2875                        	; disassembler
330
 2876                        	;---------------------------------------------------------------------------
331
 2877  FF1CF7
332
 2878  FF1CF7                	Cmd_d:
333
 2879  FF1CF7  B0 08         		bcs	?01
334
 2880  FF1CF9  20 92 18      		jsr	TmpToAddr
335
 2881  FF1CFC  20 5A 01      		jsr	GetParm
336
 2882  FF1CFF  90 06         		bcc	?02
337
 2883  FF1D01  A9 14         	?01:	lda	#$14
338
 2884  FF1D03  85 BA         		sta	SMTmpL
339
 2885  FF1D05  D0 05         		bne	?03
340
 2886  FF1D07  20 9F 18      	?02:	jsr	SubTmpAddr
341
 2887  FF1D0A  90 1B         		bcc	?20
342
 2888  FF1D0C                	?03:	TXT_CR
343
 2889  FF1D0C                		TXTPRCHAR
344
 2890                        		.MLIST
345
 2891  FF1D0C  02 08         		cop	$08
346
 2892                        		.MNLIST
347
 2893  FF1D0E  0D            		.DB	$0D
348
 2894                        		.MNLIST
349
 2895  FF1D0F  20 80 1A      		jsr	CkStop
350
 2896  FF1D12  F0 12         		beq	?10
351
 2897  FF1D14  20 3B 1D      		jsr	disx16
352
 2898  FF1D17  A5 E5         		lda	asmnb
353
 2899  FF1D19  1A            		inc	a
354
 2900  FF1D1A  85 E5         		sta	asmnb
355
 2901  FF1D1C  20 2A 1D      		jsr	IncPtr
356
 2902  FF1D1F  A5 E5         		lda	asmnb
357
 2903  FF1D21  20 B3 18      		jsr	DecTmpPtrA
358
 2904  FF1D24  B0 E6         		bcs	?03
359
 2905  FF1D26  60            	?10:	rts
360
 2906  FF1D27
361
 2907  FF1D27  4C 34 01      	?20:	jmp	ErrCls2
362
 2908
363
 2909  FF1D2A                	IncPtr:
364
 2910  FF1D2A  EB            		xba
365
 2911  FF1D2B  A9 00         		lda	#0
366
 2912  FF1D2D  EB            		xba
367
 2913  FF1D2E                		ACC16CLC
368
 2914  FF1D2E  C2 21         		rep	#(PMFLAG.OR.PCFLAG)
369
 2915                        		.LONGA	on
370
 2916                        		.MNLIST
371
 2917  FF1D30  65 B6         		adc	SMAddrL
372
 2918  FF1D32  85 B6         		sta	SMAddrL
373
  Tue Jul 17 11:00:24 2018                                                                                               Page    7
374
 
375
 
376
 
377
 
378
 2919  FF1D34                		ACC08
379
 2920  FF1D34  E2 20         		sep	#PMFLAG
380
 2921                        		.LONGA	off
381
 2922                        		.MNLIST
382
 2923  FF1D36  90 02         		bcc	?01
383
 2924  FF1D38  E6 B8         		inc	SMAddrK
384
 2925  FF1D3A  60            	?01:	rts
385
 2926
386
 2927                        	; disassemble 65C816 code at address SMAddrL/H/K
387
 2928  FF1D3B                	disx16:
388
 2929  FF1D3B                		TXTPRINT
389
 2930  FF1D3B  02 02         		cop	$02
390
 2931                        		.MNLIST
391
 2932  FF1D3D  2E 20 00      		.DB	'. ', 0
392
 2933
393
 2934                        	; entry point for line assembler
394
 2935  FF1D40                	disx162:
395
 2936  FF1D40  20 37 19      		jsr	PrintAddr	; print address SMAddrL/H/K + blank
396
 2937  FF1D43                		TXTPRCHAR		; one more blank
397
 2938  FF1D43  02 08         		cop	$08
398
 2939                        		.MNLIST
399
 2940  FF1D45  20            		.DB	' '
400
 2941  FF1D46  A9 04         		lda	#$04		; fetch max. 4 bytes for 65C816
401
 2942  FF1D48  24 D9         		bit	asmcpu
402
 2943  FF1D4A  10 02         		bpl	?00
403
 2944  FF1D4C  A9 03         		lda	#$03		; fetch max. 3 bytes for 6502/65C02
404
 2945  FF1D4E  85 EB         	?00:	sta	asmcnt
405
 2946  FF1D50  A7 B6         		lda	[SMAddrL]	; fetch op-code
406
 2947  FF1D52  20 48 1E      		jsr	getindx		; translate op-code
407
 2948  FF1D55  48            		pha			; save
408
 2949  FF1D56  A0 00         		ldy	#0
409
 2950  FF1D58  A6 E5         		ldx	asmnb		; # bytes instruction
410
 2951  FF1D5A  E8            		inx
411
 2952  FF1D5B  CA            	?01:	dex
412
 2953  FF1D5C  10 08         		bpl	?02		; next byte
413
 2954  FF1D5E                		TXTPRINT		; print 3 blank
414
 2955  FF1D5E  02 02         		cop	$02
415
 2956                        		.MNLIST
416
 2957  FF1D60  20 20 20 00   		.DB	'   ', 0
417
 2958  FF1D64  80 05         		bra	?03
418
 2959  FF1D66  B7 B6         	?02:	lda	[SMAddrL],y	; next byte
419
 2960  FF1D68  20 4E 19      		jsr	PrintByte	; print hex + blank
420
 2961  FF1D6B  C8            	?03:	iny
421
 2962  FF1D6C  C4 EB         		cpy	asmcnt 		; max. 4/3 bytes
422
 2963  FF1D6E  90 EB         		bcc	?01
423
 2964  FF1D70  68            		pla			; mnemonic index
424
 2965  FF1D71  20 F7 1F      		jsr	printm		; print mnemonic + blank
425
 2966  FF1D74  24 D9         		bit	asmcpu
426
 2967  FF1D76  10 03         		bpl	?04		; 65C816
427
 2968  FF1D78  4C FF 1D      		jmp	?50		; 6502/65C02
428
 2969  FF1D7B  A2 09         	?04:	ldx	#9		; number of bit to scan
429
 2970  FF1D7D  E0 05         	?05:	cpx	#5
430
 2971  FF1D7F  D0 1E         		bne	?08		; don't print byte
431
 2972  FF1D81  A4 E5         		ldy	asmnb
432
 2973  FF1D83  F0 1A         		beq	?08		; single byte
433
 2974  FF1D85  B7 B6         	?06:	lda	[SMAddrL],y	; fetch next byte
434
 2975  FF1D87  24 E9         		bit	asmrel		; test relative addressing
435
  Tue Jul 17 11:00:24 2018                                                                                               Page    8
436
 
437
 
438
 
439
 
440
 2976  FF1D89  30 43         		bmi	?20		; yes, relative
441
 2977  FF1D8B  20 71 19      		jsr	PrintHex
442
 2978  FF1D8E  24 E8         		bit	asmmov
443
 2979  FF1D90  10 0A         		bpl	?07
444
 2980  FF1D92  C0 02         		cpy	#$02		; mvn/mvp op-code print ',#$' after dest bank
445
 2981  FF1D94  90 06         		bcc	?07
446
 2982  FF1D96                		TXTPRINT
447
 2983  FF1D96  02 02         		cop	$02
448
 2984                        		.MNLIST
449
 2985  FF1D98  2C 23 24 00   		.DB	',#$', 0
450
 2986  FF1D9C  88            	?07:	dey
451
 2987  FF1D9D  D0 E6         		bne	?06
452
 2988  FF1D9F                	?08:	ACC16
453
 2989  FF1D9F  C2 20         		rep	#PMFLAG
454
 2990                        		.LONGA	on
455
 2991                        		.MNLIST
456
 2992  FF1DA1  06 E2         		asl	asmpr
457
 2993  FF1DA3                		ACC08
458
 2994  FF1DA3  E2 20         		sep	#PMFLAG
459
 2995                        		.LONGA	off
460
 2996                        		.MNLIST
461
 2997  FF1DA5  90 0E         		bcc	?10
462
 2998  FF1DA7  BF 7B 24 FF   		lda	>PRTAB1-1,x
463
 2999  FF1DAB                		TXTCHAROUT
464
 3000  FF1DAB  02 06         		cop	$06
465
 3001                        		.MNLIST
466
 3002  FF1DAD  BF 84 24 FF   		lda	>PRTAB2-1,x
467
 3003  FF1DB1  F0 02         		beq	?10
468
 3004  FF1DB3                		TXTCHAROUT
469
 3005  FF1DB3  02 06         		cop	$06
470
 3006                        		.MNLIST
471
 3007  FF1DB5  CA            	?10:	dex
472
 3008  FF1DB6  D0 C5         		bne	?05
473
 3009  FF1DB8  24 EA         		bit	asmstf		; rep/sep op-code ?
474
 3010  FF1DBA  10 11         		bpl	?18		; no -- end
475
 3011  FF1DBC  A0 01         		ldy	#1		; load the byte after op-code
476
 3012  FF1DBE  B7 B6         		lda	[SMAddrL],y
477
 3013  FF1DC0  29 30         		and	#PMFLAG.OR.PXFLAG
478
 3014  FF1DC2  F0 09         		beq	?18		; no 16 bit flags affected
479
 3015  FF1DC4  0A            		asl	a		; bit 7 -> A/M flag
480
 3016  FF1DC5  0A            		asl	a		; bit 6 -> X/Y flag
481
 3017  FF1DC6  70 03         		bvs	?12		; rep op-code
482
 3018  FF1DC8  14 D8         		trb	asmlong		; clear bit 7 and/or bit 6
483
 3019  FF1DCA  60            		rts
484
 3020  FF1DCB  04 D8         	?12:	tsb	asmlong		; set bit 7 and/or bit 6
485
 3021  FF1DCD  60            	?18:	rts
486
 3022  FF1DCE  38            	?20:	sec			; for later adc	(add 1 more to address)
487
 3023  FF1DCF  70 1D         		bvs	?30		; relative 16 bit
488
 3024  FF1DD1  A6 B7         	?21:	ldx	SMAddrH		; relative 8 bit
489
 3025  FF1DD3  A8            		tay			; A = offset 8 bit
490
 3026  FF1DD4  10 01         		bpl	?22
491
 3027  FF1DD6  CA            		dex			; previous page if offset is negative
492
 3028  FF1DD7  65 B6         	?22:	adc	SMAddrL		; add offset + carry
493
 3029  FF1DD9  90 01         		bcc	?24
494
 3030  FF1DDB  E8            		inx
495
 3031  FF1DDC  1A            	?24:	inc	a		; add one more to final address because
496
 3032  FF1DDD  D0 01         		bne	?26		; relative 8 bit is 2 bytes instruction
497
  Tue Jul 17 11:00:24 2018                                                                                               Page    9
498
 
499
 
500
 
501
 
502
 3033  FF1DDF  E8            		inx
503
 3034  FF1DE0  24 D9         	?26:	bit	asmcpu
504
 3035  FF1DE2  10 18         		bpl	?40		; print address
505
 3036  FF1DE4  24 E8         		bit	asmbit
506
 3037  FF1DE6  10 14         		bpl	?40		; print address
507
 3038  FF1DE8  1A            		inc	a		; BBR/BBS are 3 bytes
508
 3039  FF1DE9  D0 11         		bne	?40
509
 3040  FF1DEB  E8            		inx
510
 3041  FF1DEC  80 0E         		bra	?40		; print address
511
 3042  FF1DEE  88            	?30:	dey			; relative 16 bit: here Y = 2 now Y = 1
512
 3043  FF1DEF                		ACC16			; add offset 16 bit to current address
513
 3044  FF1DEF  C2 20         		rep	#PMFLAG
514
 3045                        		.LONGA	on
515
 3046                        		.MNLIST
516
 3047  FF1DF1  A5 B6         		lda	SMAddrL
517
 3048  FF1DF3  77 B6         		adc	[SMAddrL],y
518
 3049  FF1DF5  1A            		inc	a		; add 2 more to final address because
519
 3050  FF1DF6  1A            		inc	a		; relative 16 bit is 3 bytes istruction
520
 3051  FF1DF7                		ACC08
521
 3052  FF1DF7  E2 20         		sep	#PMFLAG
522
 3053                        		.LONGA	off
523
 3054                        		.MNLIST
524
 3055  FF1DF9  EB            		xba
525
 3056  FF1DFA  AA            		tax			; X = high address
526
 3057  FF1DFB  EB            		xba			; A = low  address
527
 3058  FF1DFC  4C 48 19      	?40:	jmp	PrintWord
528
 3059                        	?50:	; 6502/65C02
529
 3060  FF1DFF  24 E8         		bit	asmbit		; test SMB/RMB/BBR/BBS
530
 3061  FF1E01  10 17         		bpl	?54		; no
531
 3062  FF1E03  A5 E9         		lda	asmxop		; #bit
532
 3063  FF1E05  09 30         		ora	#'0'
533
 3064  FF1E07                		TXTCHAROUT
534
 3065  FF1E07  02 06         		cop	$06
535
 3066                        		.MNLIST
536
 3067  FF1E09  A9 2C         		lda	#','
537
 3068  FF1E0B                		TXTCHAROUT
538
 3069  FF1E0B  02 06         		cop	$06
539
 3070                        		.MNLIST
540
 3071  FF1E0D  A5 E2         		lda	asmpr
541
 3072  FF1E0F  C9 9D         		cmp	#$9D		; relative addressing mode ?
542
 3073  FF1E11  D0 07         		bne	?54		; no
543
 3074  FF1E13  A0 01         		ldy	#1		; fetch next byte
544
 3075  FF1E15  B7 B6         		lda	[SMAddrL],y
545
 3076  FF1E17  20 67 19      		jsr	PrintHex1	; stampa '$XX,'
546
 3077  FF1E1A  A2 06         	?54:	ldx	#6
547
 3078  FF1E1C  E0 03         	?55:	cpx	#3
548
 3079  FF1E1E  D0 12         		bne	?58		; no print byte
549
 3080  FF1E20  A4 E5         		ldy	asmnb
550
 3081  FF1E22  F0 0E         		beq	?58		; single byte
551
 3082  FF1E24  A5 E2         	?56:	lda	asmpr
552
 3083  FF1E26  C9 E8         		cmp	#$E8		; relative addressing ?
553
 3084  FF1E28  B7 B6         		lda	[SMAddrL],y
554
 3085  FF1E2A  B0 A5         		bcs	?21		; print address
555
 3086  FF1E2C  20 71 19      		jsr	PrintHex
556
 3087  FF1E2F  88            		dey
557
 3088  FF1E30  D0 F2         		bne	?56
558
 3089  FF1E32  06 E2         	?58:	asl	asmpr
559
  Tue Jul 17 11:00:24 2018                                                                                               Page   10
560
 
561
 
562
 
563
 
564
 3090  FF1E34  90 0E         		bcc	?60
565
 3091  FF1E36  BF C4 25 FF   		lda	PRTAB11-1,x
566
 3092  FF1E3A                		TXTCHAROUT
567
 3093  FF1E3A  02 06         		cop	$06
568
 3094                        		.MNLIST
569
 3095  FF1E3C  BF CA 25 FF   		lda	PRTAB21-1,x
570
 3096  FF1E40  F0 02         		beq	?60
571
 3097  FF1E42                		TXTCHAROUT
572
 3098  FF1E42  02 06         		cop	$06
573
 3099                        		.MNLIST
574
 3100  FF1E44  CA            	?60:	dex
575
 3101  FF1E45  D0 D5         		bne	?55
576
 3102  FF1E47  60            		rts
577
 3103
578
 3104                        	; get index mnemonic and addressing mode for op-code Y (65C816)
579
 3105                        	; return in A the index for access mnemonic table and in asmpr
580
 3106                        	; the printing mode; in asmnb the number of the bytes of the op-code
581
 3107  FF1E48                	getindx:
582
 3108  FF1E48  A8            		tay			; op-code
583
 3109  FF1E49  24 D9         		bit	asmcpu
584
 3110  FF1E4B  10 03         		bpl	?02		; 65C816
585
 3111  FF1E4D  4C 26 1F      		jmp	?100		; 6502/C02
586
 3112  FF1E50  4A            	?02:	lsr	a
587
 3113  FF1E51  90 0E         		bcc	?08		; even op-code (A = 00..7F)
588
 3114  FF1E53  4A            		lsr	a
589
 3115  FF1E54  90 07         		bcc	?04		; op-code with final pattern '01'
590
 3116  FF1E56
591
 3117                        		; final pattern '11' -> op-code = X3, X7, XB, XF
592
 3118                        		; all are op-code for group I instructions except op-code XB
593
 3119                        		; these are op-codes relative to accumulator new addressing
594
 3120                        		; mode in 65C816, except pattern XB that i relative to new
595
 3121                        		; istructions of 65C816 (all implied)
596
 3122                        		; these pattern are translated to 87..8F
597
 3123                        		; here value is 00XXXPPP where XXX encode istruction and
598
 3124                        		; PPP (where PPP not equal 010 and not equal 110) encode addressing
599
 3125                        		; PPP = 010 or PPP = 110 (op-code XB) mean istruction with 1 byte
600
 3126  FF1E56  EA            		nop
601
 3127  FF1E57  29 07         		and	#$07		; mask PPP
602
 3128  FF1E59  69 07         		adc	#$07		; translate to 08..0F (here CF = 1)
603
 3129  FF1E5B  80 02         		bra	?06		; value 0A and 0E are implied instructions
604
 3130
605
 3131                        	?04:	; final pattern '01' -> op-code = X1, X5, X9, XD
606
 3132                        		; are all op-codes in group 1 instructions (relative to accumulator)
607
 3133                        		; here value is 00XXXYYY where XXX encode the instruction and YYY
608
 3134                        		; the addressing mode (the standard addressing mode of 6502 family)
609
 3135                        		; all these op-codes are translated to 80..87
610
 3136
611
 3137  FF1E5D  29 07         		and	#$07		; mask YYY
612
 3138  FF1E5F  09 80         	?06:	ora	#$80		; translate to 80..8F
613
 3139  FF1E61  AA            	?08:	tax			; index to access table AMODE
614
 3140  FF1E62  BF EC 23 FF   		lda	>AMODE,x	; here X = 00..8F
615
 3141  FF1E66  85 E4         		sta	asmmode		; save  bit 7 & 6 flag (immediate 16 bit)
616
 3142  FF1E68  29 1F         		and	#$1F		; mask addressing mode
617
 3143  FF1E6A  64 E9         		stz	asmrel		; clear flag relative address
618
 3144  FF1E6C  64 E8         		stz	asmmov		; clear flag mvn/mvp op-code
619
 3145  FF1E6E  64 EA         		stz	asmstf		; clear flag rep/sep op-code
620
 3146  FF1E70  C9 0D         		cmp	#AREL		; test relative addressing 8 bit
621
  Tue Jul 17 11:00:24 2018                                                                                               Page   11
622
 
623
 
624
 
625
 
626
 3147  FF1E72  D0 04         		bne	?10
627
 3148  FF1E74  A2 80         		ldx	#$80		; flag relative 8 bit
628
 3149  FF1E76  80 06         		bra	?12
629
 3150  FF1E78  C9 15         	?10	cmp	#A16R		; test relative addressing 16 bit
630
 3151  FF1E7A  D0 06         		bne	?14
631
 3152  FF1E7C  A2 C0         		ldx	#$C0		; flag relative 16 bit
632
 3153  FF1E7E  86 E9         	?12:	stx	asmrel
633
 3154  FF1E80  80 1A         		bra	?20
634
 3155  FF1E82  C9 14         	?14:	cmp	#AMOV
635
 3156  FF1E84  D0 06         		bne	?16
636
 3157  FF1E86  A2 80         		ldx	#$80
637
 3158  FF1E88  86 E8         		stx	asmmov		; flag mvn/mvp op-code
638
 3159  FF1E8A  80 10         		bra	?20
639
 3160  FF1E8C  C0 C2         	?16:	cpy	#$C2		; rep # op-code?
640
 3161  FF1E8E  D0 04         		bne	?17
641
 3162  FF1E90  A2 C0         		ldx	#$C0		; flag rep #
642
 3163  FF1E92  80 06         		bra	?18
643
 3164  FF1E94  C0 E2         	?17:	cpy	#$E2		; sep # op-code?
644
 3165  FF1E96  D0 04         		bne	?20
645
 3166  FF1E98  A2 80         		ldx	#$80		; flag sep #
646
 3167  FF1E9A  86 EA         	?18:	stx	asmstf
647
 3168  FF1E9C  0A            	?20:	asl	a
648
 3169  FF1E9D  AA            		tax			; index to access printing mode table
649
 3170  FF1E9E                		ACC16
650
 3171  FF1E9E  C2 20         		rep	#PMFLAG
651
 3172                        		.LONGA	on
652
 3173                        		.MNLIST
653
 3174  FF1EA0  BF 8E 24 FF   		lda	>ENCTAB,x
654
 3175  FF1EA4  85 E2         		sta	asmpr		; save printing mode
655
 3176  FF1EA6                		ACC08
656
 3177  FF1EA6  E2 20         		sep	#PMFLAG
657
 3178                        		.LONGA	off
658
 3179                        		.MNLIST
659
 3180  FF1EA8  29 03         		and	#$03
660
 3181  FF1EAA  AA            		tax			; number of bytes
661
 3182  FF1EAB  24 E4         		bit	asmmode
662
 3183  FF1EAD  30 08         		bmi	?24		; test A/M 16 bit
663
 3184  FF1EAF  50 0B         		bvc	?28		; no #immediate 16 bit mode for X/Y
664
 3185  FF1EB1  24 D8         		bit	asmlong		; test bit 6 -> X/Y 16 bit ?
665
 3186  FF1EB3  50 07         		bvc	?28		; no -- X/Y 8 bit
666
 3187  FF1EB5  70 04         		bvs	?26		; yes, X/Y #immdediate 16 bit
667
 3188  FF1EB7  24 D8         	?24:	bit	asmlong		; test bit 7 -> A/M 16 bit ?
668
 3189  FF1EB9  10 01         		bpl	?28		; no -- A/M 8 bit
669
 3190  FF1EBB  E8            	?26:	inx			; add one more byte (#immediate 16 bit)
670
 3191  FF1EBC  86 E5         	?28:	stx	asmnb		; number of bytes of instruction
671
 3192  FF1EBE  98            		tya			; A = op-code
672
 3193  FF1EBF  A2 0D         		ldx	#OPTABLEN
673
 3194  FF1EC1  DF D0 23 FF   	?32:	cmp	>OPTAB,x	; translate index op-code
674
 3195  FF1EC5  F0 05         		beq	?34		; found
675
 3196  FF1EC7  CA            		dex
676
 3197  FF1EC8  10 F7         		bpl	?32		; loop
677
 3198  FF1ECA  30 05         		bmi	?36		; not found
678
 3199  FF1ECC  BF DE 23 FF   	?34:	lda	>TRANSL,x
679
 3200  FF1ED0  60            		rts
680
 3201  FF1ED1  29 8F         	?36:	and	#$8F
681
 3202  FF1ED3  AA            		tax
682
 3203  FF1ED4  98            	     	tya
683
  Tue Jul 17 11:00:24 2018                                                                                               Page   12
684
 
685
 
686
 
687
 
688
 3204  FF1ED5  29 9F         		and	#$9F
689
 3205  FF1ED7  85 E6         		sta	tmpl
690
 3206  FF1ED9  98            		tya
691
 3207  FF1EDA  29 1F         		and	#$1F
692
 3208  FF1EDC  85 E7         		sta	tmph
693
 3209  FF1EDE  98            		tya
694
 3210  FF1EDF  A0 03         		ldy	#$03
695
 3211  FF1EE1  E0 8A         		cpx	#$8A
696
 3212  FF1EE3  F0 30         		beq	?44
697
 3213  FF1EE5  4A            	?38:	lsr	a
698
 3214  FF1EE6  90 2D         		bcc	?44
699
 3215  FF1EE8  4A            		lsr	a
700
 3216  FF1EE9  90 08         		bcc	?40
701
 3217  FF1EEB  E0 0B         		cpx	#$0B
702
 3218  FF1EED  F0 2A         		beq	?48
703
 3219  FF1EEF  E0 8B         		cpx	#$8B
704
 3220  FF1EF1  F0 26         		beq	?48
705
 3221  FF1EF3  4A            	?40:	lsr	a
706
 3222  FF1EF4  09 20         		ora	#$20
707
 3223  FF1EF6  88            		dey
708
 3224  FF1EF7  D0 FA         		bne	?40
709
 3225  FF1EF9  E0 03         		cpx	#$03
710
 3226  FF1EFB  F0 1B         		beq	?46
711
 3227  FF1EFD  E0 83         		cpx	#$83
712
 3228  FF1EFF  F0 17         		beq	?46
713
 3229  FF1F01  A6 E7         		ldx	tmph
714
 3230  FF1F03  E0 12         		cpx	#$12
715
 3231  FF1F05  F0 17         		beq	?50
716
 3232  FF1F07  E0 02         		cpx	#$02
717
 3233  FF1F09  F0 17         		beq	?52
718
 3234  FF1F0B  A6 E6         		ldx	tmpl
719
 3235  FF1F0D  E0 1A         		cpx	#$1A
720
 3236  FF1F0F  D0 03         		bne	?42
721
 3237  FF1F11  18            		clc
722
 3238  FF1F12  69 28         		adc	#$28
723
 3239  FF1F14  60            	?42:	rts
724
 3240  FF1F15  88            	?44:	dey
725
 3241  FF1F16  D0 CD         		bne	?38
726
 3242  FF1F18  60            	?46:	rts
727
 3243  FF1F19  4A            	?48:	lsr	a
728
 3244  FF1F1A  4A            		lsr	a
729
 3245  FF1F1B  09 40         		ora	#$40
730
 3246  FF1F1D  60            		rts
731
 3247  FF1F1E  18            	?50:	clc
732
 3248  FF1F1F  69 08         		adc	#$08
733
 3249  FF1F21  60            		rts
734
 3250  FF1F22  18            	?52:	clc
735
 3251  FF1F23  69 20         		adc	#$20
736
 3252  FF1F25  60            		rts
737
 3253                        		;; 6502/65C02
738
 3254  FF1F26  64 E8         	?100:	stz	asmbit			; flag rmb/smb/bbr/bbs
739
 3255  FF1F28  70 0D         		bvs	?101a			; 65C02
740
 3256  FF1F2A  A2 11         		ldx	#INVLEN
741
 3257  FF1F2C  DF 56 25 FF   	?101c:	cmp	>OPTAB1,x
742
 3258  FF1F30  F0 74         		beq	?112			; 6502 invalid op-code
743
 3259  FF1F32  CA            		dex
744
 3260  FF1F33  10 F7         		bpl	?101c
745
  Tue Jul 17 11:00:24 2018                                                                                               Page   13
746
 
747
 
748
 
749
 
750
 3261  FF1F35  80 14         		bra	?103
751
 3262  FF1F37  A2 07         	?101a:	ldx	#OPTAB1LEN		; translation for 65C02
752
 3263  FF1F39  DF 56 25 FF   	?101:	cmp	>OPTAB1,x
753
 3264  FF1F3D  D0 09         		bne	?102
754
 3265  FF1F3F  48            		pha
755
 3266  FF1F40  BF 68 25 FF   		lda	>TRANSL1,x
756
 3267  FF1F44  A8            		tay
757
 3268  FF1F45  68            		pla
758
 3269  FF1F46  80 03         		bra	?103
759
 3270  FF1F48  CA            	?102:	dex
760
 3271  FF1F49  10 EE         		bpl	?101
761
 3272  FF1F4B  4A            	?103:	lsr	a
762
 3273  FF1F4C  90 2B         		bcc	?106			; even op-code
763
 3274  FF1F4E  4A            		lsr	a
764
 3275  FF1F4F  90 37         		bcc	?108			; op-code with final '01' pattern
765
 3276
766
 3277                        		; '11' final pattern: X3, X7, XB, XF op-code
767
 3278                        		; for 65C02 valid X7 ed XF only -- all invalid for 6502
768
 3279  FF1F51
769
 3280  FF1F51  24 D9         		bit	asmcpu
770
 3281  FF1F53  50 51         		bvc	?112			; invalid op-code for 6502
771
 3282  FF1F55  4A            		lsr	a
772
 3283  FF1F56  90 4E         		bcc	?112			; invalid op-code for 65C02
773
 3284  FF1F58
774
 3285                        		; BBRX -> 0XXX1111 => 0000XXX1
775
 3286                        		; BBSX -> 1XXX1111 => 0001XXX1
776
 3287                        		; RMBX -> 0XXX0111 => 0000XXX0
777
 3288                        		; SMBX -> 1XXX0111 => 0001XXX0
778
 3289
779
 3290  FF1F58  A2 00         		ldx	#0			; X = 0 if RMB/SMB
780
 3291  FF1F5A  48            		pha
781
 3292  FF1F5B  4A            		lsr	a			; test bit 0
782
 3293  FF1F5C  29 07         		and	#$07
783
 3294  FF1F5E  85 E9         		sta	asmxop			; asmxop = 0..7
784
 3295  FF1F60  68            		pla
785
 3296  FF1F61
786
 3297                        		; now C = 1 if BBR/BBS - CF = 0 if RMB/SMB
787
 3298  FF1F61  90 01         		bcc	?104
788
 3299  FF1F63  E8            		inx				; X = 1 if BBR/BBS
789
 3300  FF1F64  08            	?104:	php				; salva C
790
 3301  FF1F65  0A            		asl	a			; A<5> = 0 per BBR/RMB
791
 3302  FF1F66  29 20         		and	#$20			; mask  bit 5
792
 3303  FF1F68  28            		plp
793
 3304  FF1F69  90 02         		bcc	?105
794
 3305  FF1F6B  09 40         		ora	#$40			; A<6> = 1 if BBR/BBS
795
 3306  FF1F6D
796
 3307                        		; A = 000 00000 if RMB
797
 3308                        		; A = 001 00000 if SMB
798
 3309                        		; A = 010 00000 if BBR
799
 3310                        		; A = 011 00000 if BBS
800
 3311  FF1F6D
801
 3312  FF1F6D  09 03         	?105:	ora	#$03
802
 3313  FF1F6F  A8            		tay				; translate code for 65C02
803
 3314  FF1F70
804
 3315                        		; Y = 03 if RMB
805
 3316                        		; Y = 23 if SMB
806
 3317                        		; Y = 43 if BBR
807
  Tue Jul 17 11:00:24 2018                                                                                               Page   14
808
 
809
 
810
 
811
 
812
 3318                        		; Y = 63 if BBS
813
 3319  FF1F70
814
 3320  FF1F70  A9 80         		lda	#$80
815
 3321  FF1F72  85 E8         		sta	asmbit			; flag rmb/smb/bbr/bbs
816
 3322  FF1F74  8A            		txa
817
 3323  FF1F75  09 88         		ora	#$88			; A = 88..89
818
 3324  FF1F77  80 1D         		bra	?110			; access table
819
 3325  FF1F79
820
 3326                        	?106:	; final pattern '10010' for 65C02 op-code as LDA(ZP)
821
 3327  FF1F79  AA            		tax
822
 3328  FF1F7A  29 0F         		and	#$0F
823
 3329  FF1F7C  C9 09         		cmp	#$09
824
 3330  FF1F7E  D0 05         		bne	?107
825
 3331  FF1F80  24 D9         		bit	asmcpu
826
 3332  FF1F82  50 22         		bvc	?112			; invalid 6502 opcode
827
 3333  FF1F84  88            		dey				; translate 65C02 opcode
828
 3334  FF1F85  8A            	?107:	txa
829
 3335  FF1F86  80 0E         		bra	?110
830
 3336  FF1F88
831
 3337                        	?108:	; '01' final pattern all valid for 65C02 -- $89 is invalid for 6502
832
 3338                        		; after 2 lsr -> $89 = $22 -- if 6502 this is invalid
833
 3339                        		; for 65C02 this is BIT # op-code, that will be translated to $24
834
 3340  FF1F88  C9 22         		cmp	#$22			; opcode $89 ?
835
 3341  FF1F8A  D0 06         		bne	?109			; no
836
 3342  FF1F8C  24 D9         		bit	asmcpu
837
 3343  FF1F8E  50 16         		bvc	?112			; invalid 6502 opcode
838
 3344  FF1F90  A0 24         		ldy	#$24			; translate 65C02 op-code
839
 3345
840
 3346                        	?109:	;  A = 00XXXYYY where YYY encode addressing mode
841
 3347  FF1F92  29 07         		and	#$07			; mask YYY
842
 3348  FF1F94  09 80         		ora	#$80			; A = 80..87
843
 3349
844
 3350                        	?110:	; access addressing mode table
845
 3351  FF1F96  4A            		lsr	a
846
 3352  FF1F97  AA            		tax
847
 3353  FF1F98  BF 70 25 FF   		lda	>AMODE1,x
848
 3354  FF1F9C  B0 04         		bcs	?111			; odd -> low
849
 3355  FF1F9E  4A            		lsr	a			; even -> high
850
 3356  FF1F9F  4A            		lsr	a
851
 3357  FF1FA0  4A            		lsr	a
852
 3358  FF1FA1  4A            		lsr	a
853
 3359  FF1FA2  29 0F         	?111:	and	#$0F
854
 3360  FF1FA4  D0 04         		bne	?114			; valid !
855
 3361  FF1FA6  A0 E3         	?112:	ldy	#$E3			; invalid opcode
856
 3362  FF1FA8  A9 00         		lda	#$00
857
 3363  FF1FAA  AA            	?114:	tax
858
 3364  FF1FAB  BF B5 25 FF   		lda	>ENCTAB1,x
859
 3365  FF1FAF  85 E2         		sta	asmpr			; printing bits
860
 3366  FF1FB1  29 03         		and	#$03
861
 3367  FF1FB3  85 E5         		sta	asmnb			; # bytes
862
 3368  FF1FB5  E0 0D         		cpx	#$0D			; test realtive addressing
863
 3369  FF1FB7  D0 06         		bne	?115a
864
 3370  FF1FB9  24 E8         		bit	asmbit
865
 3371  FF1FBB  10 02         		bpl	?115a			; no BBR/BBS/RMS/SMB
866
 3372  FF1FBD  E6 E5         		inc	asmnb			; BBR/BBS 3 bytes instructions
867
 3373  FF1FBF  98            	?115a:	tya
868
 3374  FF1FC0  29 8F         		and	#$8F
869
  Tue Jul 17 11:00:24 2018                                                                                               Page   15
870
 
871
 
872
 
873
 
874
 3375  FF1FC2  85 E7         		sta	tmph
875
 3376  FF1FC4  AA            		tax
876
 3377  FF1FC5  98            	     	tya
877
 3378  FF1FC6  29 9F         		and	#$9F
878
 3379  FF1FC8  85 E6         		sta	tmpl
879
 3380  FF1FCA  98            		tya
880
 3381  FF1FCB  A0 03         		ldy	#$03
881
 3382  FF1FCD  E0 8A         		cpx	#$8A
882
 3383  FF1FCF  F0 22         		beq	?120
883
 3384  FF1FD1  4A            	?115:	lsr	a
884
 3385  FF1FD2  90 1F         		bcc	?120
885
 3386  FF1FD4  4A            		lsr	a
886
 3387  FF1FD5  4A            	?116:	lsr	a
887
 3388  FF1FD6  09 20         		ora	#$20
888
 3389  FF1FD8  88            		dey
889
 3390  FF1FD9  D0 FA         		bne	?116
890
 3391  FF1FDB  A6 E7         		ldx	tmph
891
 3392  FF1FDD  E0 03         		cpx	#$03
892
 3393  FF1FDF  F0 04         		beq	?117
893
 3394  FF1FE1  E0 83         		cpx	#$83
894
 3395  FF1FE3  D0 04         		bne	?118
895
 3396  FF1FE5  18            	?117:	clc
896
 3397  FF1FE6  69 0C         		adc	#$0C
897
 3398  FF1FE8  60            		rts
898
 3399  FF1FE9  A6 E6         	?118:	ldx	tmpl
899
 3400  FF1FEB  E0 1A         		cpx	#$1A
900
 3401  FF1FED  D0 03         		bne	?119
901
 3402  FF1FEF  18            		clc
902
 3403  FF1FF0  69 10         		adc	#$10
903
 3404  FF1FF2  60            	?119:	rts
904
 3405  FF1FF3  88            	?120:	dey
905
 3406  FF1FF4  D0 DB         		bne	?115
906
 3407  FF1FF6  60            		rts
907
 3408
908
 3409                        	; print mnemonic of the translated op-code
909
 3410  FF1FF7                	printm:
910
 3411  FF1FF7  AA            		tax
911
 3412  FF1FF8  24 D9         		bit	asmcpu
912
 3413  FF1FFA  10 0C         		bpl	?06		; 65C816
913
 3414  FF1FFC  BF BE 24 FF   		lda	>MEMTBLL1,x	; 6502/C02
914
 3415  FF2000  85 E6         		sta	tmpl
915
 3416  FF2002  BF 0A 25 FF   		lda	>MEMTBLH1,x
916
 3417  FF2006  80 0A         		bra	?08
917
 3418  FF2008  BF 0A 23 FF   	?06:	lda	>MEMTBLL,x
918
 3419  FF200C  85 E6         		sta	tmpl
919
 3420  FF200E  BF 6D 23 FF   		lda	>MEMTBLH,x
920
 3421  FF2012  85 E7         	?08:	sta	tmph
921
 3422  FF2014  A2 03         		ldx	#3
922
 3423  FF2016  A9 00         	?10:	lda	#$00
923
 3424  FF2018  A0 05         		ldy	#$05
924
 3425  FF201A  06 E7         	?12:	asl	tmph
925
 3426  FF201C  26 E6         		rol	tmpl
926
 3427  FF201E  2A            		rol	a
927
 3428  FF201F  88            		dey
928
 3429  FF2020  D0 F8         		bne	?12
929
 3430  FF2022  69 3F         		adc	#'?'
930
 3431  FF2024                		TXTCHAROUT		; print mnemonic
931
  Tue Jul 17 11:00:24 2018                                                                                               Page   16
932
 
933
 
934
 
935
 
936
 3432  FF2024  02 06         		cop	$06
937
 3433                        		.MNLIST
938
 3434  FF2026  CA            		dex
939
 3435  FF2027  D0 ED         		bne	?10
940
 3436  FF2029                		TXTPRCHAR		; print blank
941
 3437  FF2029  02 08         		cop	$08
942
 3438                        		.MNLIST
943
 3439  FF202B  20            		.DB	' '
944
 3440  FF202C  60            		rts
945
 3441
946
 3442                        	;---------------------------------------------------------------------------
947
 3443                        	; assembler
948
 3444                        	;---------------------------------------------------------------------------
949
 3445
950
 3446  FF202D                	Cmd_a:
951
 3447  FF202D  B0 33         		bcs	?20		; error: missing start address
952
 3448  FF202F  20 92 18      		jsr	TmpToAddr
953
 3449  FF2032  A2 00         	?01:	ldx	#0
954
 3450  FF2034  86 EF         		stx	P0TMP+1
955
 3451  FF2036  20 48 1A      	?02:	jsr	GetCurCh	; next char
956
 3452  FF2039  D0 04         		bne	?03
957
 3453  FF203B  E0 00         		cpx	#0
958
 3454  FF203D  F0 22         		beq	?19		; empty buffer: exit
959
 3455  FF203F  C9 20         	?03:	cmp	#' '
960
 3456  FF2041  F0 EF         		beq	?01		; skip starting blank
961
 3457  FF2043  20 BF 22      		jsr	upcase
962
 3458  FF2046  95 E2         		sta	TSTR,x		; buffer mnemonic
963
 3459  FF2048  E8            		inx
964
 3460  FF2049  E0 03         		cpx	#3		; must be 3 chars.
965
 3461  FF204B  D0 E9         		bne	?02
966
 3462  FF204D  CA            	?04:	dex			; compact mnemonic
967
 3463  FF204E  30 15         		bmi	?21
968
 3464  FF2050  B5 E2         		lda	TSTR,x
969
 3465  FF2052  38            		sec
970
 3466  FF2053  E9 3F         		sbc	#'?'
971
 3467  FF2055  A0 05         		ldy	#5
972
 3468  FF2057  4A            	?05:	lsr	a
973
 3469  FF2058  66 EF         		ror	P0TMP+1
974
 3470  FF205A  66 EE         		ror	P0TMP
975
 3471  FF205C  88            		dey
976
 3472  FF205D  D0 F8         		bne	?05
977
 3473  FF205F  F0 EC         		beq	?04
978
 3474  FF2061  60            	?19:	rts
979
 3475  FF2062  4C 34 01      	?20:	jmp	ErrCls2		; error
980
 3476  FF2065  A5 EE         	?21:	lda	P0TMP		; test mnemonic '???'
981
 3477  FF2067  05 EF         		ora	P0TMP+1
982
 3478  FF2069  F0 F7         		beq	?20
983
 3479  FF206B  A2 02         		ldx	#2
984
 3480  FF206D  20 48 1A      	?22:	jsr	GetCurCh
985
 3481  FF2070  F0 39         		beq	?24
986
 3482  FF2072  C9 20         		cmp	#' '
987
 3483  FF2074  F0 F7         		beq	?22		; skip blank
988
 3484  FF2076  20 BF 22      		jsr	upcase
989
 3485  FF2079  20 CA 22      		jsr	chkdgt
990
 3486  FF207C  B0 26         		bcs	?23		; no hex digit
991
 3487  FF207E  20 D8 22      		jsr	dgt2hex
992
 3488
993
  Tue Jul 17 11:00:24 2018                                                                                               Page   17
994
 
995
 
996
 
997
 
998
 3489                        		; if 6502/65C02:
999
 3490                        		; for BBR/BBS:	SMTmpL/SMTmpH -> absolute address
1000
 3491                        		;		asmtmpL        -> ZP address
1001
 3492                        		;		asmtmpH	      -> # bit
1002
 3493                        		; for SMB/RMB 	SMTmpL	      -> ZP address
1003
 3494                        		;		SMTmpH        -> # bit
1004
 3495                        		; others:	SMTmpL	      -> SMTmpL/SMTmpH -> address
1005
 3496                        		; if 65C816:	SMTmpL/H/K    -> address
1006
 3497  FF2081
1007
 3498  FF2081  24 D9         		bit	asmcpu
1008
 3499  FF2083  30 0C         		bmi	?22a
1009
 3500  FF2085  A4 BB         		ldy	SMTmpH		; translate
1010
 3501  FF2087  84 BC         		sty	SMTmpK
1011
 3502  FF2089  A4 BA         		ldy	SMTmpL
1012
 3503  FF208B  84 BB         		sty	SMTmpH
1013
 3504  FF208D  85 BA         		sta	SMTmpL
1014
 3505  FF208F  80 0E         		bra	?23a
1015
 3506  FF2091  A4 EC         	?22a:	ldy	asmtmpL		; translate values
1016
 3507  FF2093  84 ED         		sty	asmtmpH
1017
 3508  FF2095  A4 BB         		ldy	SMTmpH
1018
 3509  FF2097  84 EC         		sty	asmtmpL
1019
 3510  FF2099  A4 BA         		ldy	SMTmpL
1020
 3511  FF209B  84 BB         		sty	SMTmpH
1021
 3512  FF209D  85 BA         		sta	SMTmpL
1022
 3513  FF209F  A9 30         	?23a:	lda	#'0'
1023
 3514  FF20A1  95 EE         		sta	P0TMP,x
1024
 3515  FF20A3  E8            		inx
1025
 3516  FF20A4  95 EE         	?23:	sta	P0TMP,x
1026
 3517  FF20A6  E8            		inx
1027
 3518  FF20A7  E0 0E         		cpx	#$0E		; max. chars expected
1028
 3519  FF20A9  90 C2         		bcc	?22
1029
 3520  FF20AB  86 99         	?24:	stx	ScnSaveX	; salva #bytes maschera input
1030
 3521  FF20AD  64 9B         		stz	ScnTmpL		; op-code iniziale: 00
1031
 3522  FF20AF  64 9C         	?25:	stz	ScnTmpH		; indice iniziale maschera
1032
 3523  FF20B1  A5 9B         		lda	ScnTmpL		; op-code corrente
1033
 3524  FF20B3  20 48 1E      		jsr	getindx		; ricava dati op-code
1034
 3525  FF20B6  A6 E2         		ldx	asmpr		; salva modo istruzione
1035
 3526  FF20B8  86 9A         		stx	ScnSaveY
1036
 3527  FF20BA  AA            		tax				; indice
1037
 3528  FF20BB  24 D9         		bit	asmcpu
1038
 3529  FF20BD  30 11         		bmi	?25a			; cpu 8 bit
1039
 3530  FF20BF  BF 6D 23 FF   		lda	>MEMTBLH,x		; test mnemonico H
1040
 3531  FF20C3  20 C8 21      		jsr	?210
1041
 3532  FF20C6  BF 0A 23 FF   		lda	>MEMTBLL,x		; test mnemonico L
1042
 3533  FF20CA  20 C8 21      		jsr	?210
1043
 3534  FF20CD  4C E1 21      		jmp	?300
1044
 3535  FF20D0  BF 0A 25 FF   	?25a:	lda	>MEMTBLH1,x		; test mnemonico H
1045
 3536  FF20D4  20 C8 21      		jsr	?210
1046
 3537  FF20D7  BF BE 24 FF   		lda	>MEMTBLL1,x		; test mnemonico L
1047
 3538  FF20DB  20 C8 21      		jsr	?210
1048
 3539  FF20DE  24 E8         		bit	asmbit			; test SMB/RMB/BBR/BBS
1049
 3540  FF20E0  10 32         		bpl	?29			; no
1050
 3541  FF20E2  A6 E2         		ldx	asmpr			; modo ind.
1051
 3542  FF20E4  A5 BB         		lda	SMTmpH			; # bit per SMB/RMB
1052
 3543  FF20E6  E0 9D         		cpx	#$9D			; relativo ?
1053
 3544  FF20E8  D0 02         		bne	?26			; no
1054
 3545  FF20EA  A5 ED         		lda	asmtmpH			; # bit per BBR/BBS
1055
  Tue Jul 17 11:00:24 2018                                                                                               Page   18
1056
 
1057
 
1058
 
1059
 
1060
 3546  FF20EC  E6 9C         	?26:	inc	ScnTmpH			; scarta primo digit della maschera
1061
 3547  FF20EE  A6 9C         		ldx	ScnTmpH
1062
 3548  FF20F0  95 EE         		sta	P0TMP,x
1063
 3549  FF20F2  A5 C4         		lda	SMbndx			; # bit op code
1064
 3550  FF20F4  20 C8 21      		jsr	?210			; check # bit
1065
 3551  FF20F7  A9 2C         		lda	#','
1066
 3552  FF20F9  20 C8 21      		jsr	?210			; check virgola
1067
 3553  FF20FC  A6 E2         		ldx	asmpr			; modo ind.
1068
 3554  FF20FE  E0 9D         		cpx	#$9D			; relativo ?
1069
 3555  FF2100  D0 12         		bne	?29			; no
1070
 3556  FF2102  A9 24         		lda	#'$'
1071
 3557  FF2104  20 C8 21      		jsr	?210			; check ZP
1072
 3558  FF2107  A9 30         		lda	#'0'
1073
 3559  FF2109  20 C8 21      		jsr	?210
1074
 3560  FF210C  20 C8 21      		jsr	?210
1075
 3561  FF210F  A9 2C         		lda	#','
1076
 3562  FF2111  20 C8 21      		jsr	?210			; check virgola
1077
 3563  FF2114  A2 06         	?29:	ldx	#6
1078
 3564  FF2116  E0 03         	?30:	cpx	#3
1079
 3565  FF2118  D0 15         		bne	?40
1080
 3566  FF211A  A4 E5         		ldy	asmnb			; numero bytes
1081
 3567  FF211C  F0 11         		beq	?40
1082
 3568  FF211E  A5 E2         	?35:	lda	asmpr
1083
 3569  FF2120  C9 E8         		cmp	#$E8
1084
 3570  FF2122  A9 30         		lda	#'0'
1085
 3571  FF2124  B0 22         		bcs	?50
1086
 3572  FF2126  20 C8 21      		jsr	?210
1087
 3573  FF2129  20 C8 21      		jsr	?210
1088
 3574  FF212C  88            		dey
1089
 3575  FF212D  D0 EF         		bne	?35
1090
 3576  FF212F  06 E2         	?40:	asl	asmpr
1091
 3577  FF2131  90 10         		bcc	?45
1092
 3578  FF2133  BF C4 25 FF   		lda	>PRTAB11-1,x
1093
 3579  FF2137  20 C8 21      		jsr	?210
1094
 3580  FF213A  BF CA 25 FF   		lda	>PRTAB21-1,x
1095
 3581  FF213E  F0 03         		beq	?45
1096
 3582  FF2140  20 C8 21      		jsr	?210
1097
 3583  FF2143  CA            	?45:	dex
1098
 3584  FF2144  D0 D0         		bne	?30
1099
 3585  FF2146  F0 0C         		beq	?55
1100
 3586  FF2148  20 C8 21      	?50:	jsr	?210			; check $XXXX
1101
 3587  FF214B  20 C8 21      		jsr	?210
1102
 3588  FF214E  20 C8 21      		jsr	?210
1103
 3589  FF2151  20 C8 21      		jsr	?210
1104
 3590  FF2154  A5 99         	?55:	lda	ScnSaveX		; maschera coincide ?
1105
 3591  FF2156  C5 9C         		cmp	ScnTmpH
1106
 3592  FF2158  D0 78         		bne	?211			; no, prova next op-code
1107
 3593  FF215A  A4 E5         	?60:	ldy	asmnb			; numero bytes
1108
 3594  FF215C  F0 51         		beq	?96
1109
 3595  FF215E  A5 9A         		lda	ScnSaveY
1110
 3596  FF2160  C9 9D         		cmp	#$9D
1111
 3597  FF2162  D0 43         		bne	?90			; no ind. relativo
1112
 3598  FF2164
1113
 3599                        		; SMAddrL/H = ptr. opcode
1114
 3600                        		; il salto relativo va calcolato su ptr + #bytes istruzione
1115
 3601                        		; attualmente #bytes = SAddrL + 1
1116
 3602                        		; indirizzo del salto relativo in SMTmpL/H
1117
  Tue Jul 17 11:00:24 2018                                                                                               Page   19
1118
 
1119
 
1120
 
1121
 
1122
 3603  FF2164
1123
 3604  FF2164  A5 B6         	?60a:	lda	SMAddrL			; A,X = ptr opcode attuale
1124
 3605  FF2166  A6 B7         		ldx	SMAddrH
1125
 3606  FF2168  18            		clc
1126
 3607  FF2169  65 E5         		adc	asmnb
1127
 3608  FF216B  90 01         		bcc	?61
1128
 3609  FF216D  E8            		inx
1129
 3610  FF216E  1A            	?61:	inc	a
1130
 3611  FF216F  D0 01         		bne	?62
1131
 3612  FF2171  E8            		inx
1132
 3613  FF2172  85 E6         	?62: 	sta	tmpl			; TmpL/H = ptr next istruzione
1133
 3614  FF2174  86 E7         		stx	tmph
1134
 3615  FF2176  38            		sec				; calcolo offset
1135
 3616  FF2177  A5 BA         		lda	SMTmpL
1136
 3617  FF2179  E5 E6         		sbc	tmpl
1137
 3618  FF217B  85 ED         		sta	asmtmpH			; salva offset low
1138
 3619  FF217D  A5 BB         		lda	SMTmpH
1139
 3620  FF217F  E5 E7         		sbc	tmph
1140
 3621  FF2181  90 08         		bcc	?70			; offset negativo
1141
 3622  FF2183  D0 54         		bne	?215			; errore: offset > 00FF
1142
 3623  FF2185  A6 ED         		ldx	asmtmpH			; offset 1 byte
1143
 3624  FF2187  30 50         		bmi	?215			; errore: offset positivo max. = 7F
1144
 3625  FF2189  10 08         		bpl	?80			; offset positivo OK
1145
 3626  FF218B  A8            	?70:	tay				; offset negativo parte high
1146
 3627  FF218C  C8            		iny				; deve essere FF
1147
 3628  FF218D  D0 4A         		bne	?215			; errore: offset negativo fuori range
1148
 3629  FF218F  A6 ED         		ldx	asmtmpH			; offset negativo
1149
 3630  FF2191  10 46         		bpl	?215			; errore: deve essere negativo
1150
 3631  FF2193  8A            	?80:	txa
1151
 3632  FF2194  A4 E5         		ldy	asmnb			; # bytes
1152
 3633  FF2196  24 D9         		bit	asmcpu
1153
 3634  FF2198  10 10         		bpl	?94			; no rmb/smb/bbr/bbs for 65C816
1154
 3635  FF219A  24 E8         		bit	asmbit
1155
 3636  FF219C  10 0C         		bpl	?94			; no BBR/BBS
1156
 3637  FF219E  97 B6         		sta	[SMAddrL],y		; BBR/BBS: store offset
1157
 3638  FF21A0  88            		dey
1158
 3639  FF21A1  A5 EC         		lda	asmtmpL			; BBR/BBS: store ZP
1159
 3640  FF21A3  97 B6         		sta	[SMAddrL],y
1160
 3641  FF21A5  80 08         		bra	?96			; store op-code
1161
 3642  FF21A7  BB            	?90:	tyx
1162
 3643  FF21A8  B5 B9         		lda	SMTmpL-1,x		; memorizza i bytes
1163
 3644  FF21AA  97 B6         	?94:	sta	[SMAddrL],y
1164
 3645  FF21AC  88            		dey
1165
 3646  FF21AD  D0 F8         		bne	?90
1166
 3647  FF21AF  A5 9B         	?96:	lda	ScnTmpL			; store op-code
1167
 3648  FF21B1  87 B6         		sta	[SMAddrL]
1168
 3649  FF21B3                		SCNPRINT
1169
 3650  FF21B3  02 01         		cop	$01
1170
 3651                        		.MNLIST
1171
 3652  FF21B5  0D 01         		.DB	KB_CR, SCN_CSRUP	; CR + cursore up
1172
 3653  FF21B7  61 20 1B 51 00 		.DB	'a ', KB_ESC, 'Q', 0
1173
 3654  FF21BC  20 40 1D      		jsr	disx162			; disassembla SMAddrL/H
1174
 3655  FF21BF  A5 E5         		lda	asmnb			; #bytes
1175
 3656  FF21C1  1A            		inc	a			; offset next istruzione
1176
 3657  FF21C2  20 2A 1D      		jsr	IncPtr			; update SMAddrL/H
1177
 3658
1178
 3659                        		; inserisce ora nel buffer tastiera il seguente comando:
1179
  Tue Jul 17 11:00:24 2018                                                                                               Page   20
1180
 
1181
 
1182
 
1183
 
1184
 3660                        		; 'A YYXXXX '
1185
 3661                        		; si disabilita temporaneamente auto insert nel
1186
 3662                        		; caso il comando venisse dato dopo un d
1187
 3663  FF21C5
1188
 3664  FF21C5  4C 6D 22      		jmp	?500
1189
 3665  FF21C8
1190
 3666                        		; check maschera op-code
1191
 3667  FF21C8  DA            	?210:	phx
1192
 3668  FF21C9  A6 9C         		ldx	ScnTmpH
1193
 3669  FF21CB  D5 EE         		cmp	P0TMP,x
1194
 3670  FF21CD  F0 0D         		beq	?220
1195
 3671  FF21CF  FA            		plx
1196
 3672  FF21D0  68            		pla
1197
 3673  FF21D1  68            		pla
1198
 3674  FF21D2  E6 9B         	?211:	inc	ScnTmpL			; next op-code
1199
 3675  FF21D4  F0 03         		beq	?215
1200
 3676  FF21D6  4C AF 20      		jmp	?25
1201
 3677  FF21D9  4C 34 01      	?215:	jmp	ErrCls2
1202
 3678  FF21DC  E8            	?220:	inx
1203
 3679  FF21DD  86 9C         		stx	ScnTmpH
1204
 3680  FF21DF  FA            		plx
1205
 3681  FF21E0  60            		rts
1206
 3682
1207
 3683                        	;; 65C816
1208
 3684  FF21E1  A2 09         	?300:	ldx	#9
1209
 3685  FF21E3  E0 05         	?330:	cpx	#5
1210
 3686  FF21E5  D0 2A         		bne	?340
1211
 3687  FF21E7  A4 E5         		ldy	asmnb			; numero bytes
1212
 3688  FF21E9  F0 26         		beq	?340
1213
 3689  FF21EB  A9 30         	?335:	lda	#'0'
1214
 3690  FF21ED  24 E9         		bit	asmrel
1215
 3691  FF21EF  30 3D         		bmi	?350		; check XXXX - full hex address
1216
 3692  FF21F1  20 C8 21      		jsr	?210		; check XX (a pair of hex digits)
1217
 3693  FF21F4  20 C8 21      		jsr	?210
1218
 3694  FF21F7  24 E8         		bit	asmmov
1219
 3695  FF21F9  10 13         		bpl	?337
1220
 3696  FF21FB  C0 02         		cpy	#$02		; mvn/mvp op-code: '#$src,#$dst' syntax
1221
 3697  FF21FD  90 0F         		bcc	?337
1222
 3698  FF21FF  A9 2C         		lda	#','
1223
 3699  FF2201  20 C8 21      		jsr	?210		; check virgola
1224
 3700  FF2204  A9 23         		lda	#'#'
1225
 3701  FF2206  20 C8 21      		jsr	?210		; check '#'
1226
 3702  FF2209  A9 24         		lda	#'$'
1227
 3703  FF220B  20 C8 21      		jsr	?210		; check '$'
1228
 3704  FF220E  88            	?337:	dey
1229
 3705  FF220F  D0 DA         		bne	?335
1230
 3706  FF2211                	?340:	ACC16
1231
 3707  FF2211  C2 20         		rep	#PMFLAG
1232
 3708                        		.LONGA	on
1233
 3709                        		.MNLIST
1234
 3710  FF2213  06 E2         		asl	asmpr
1235
 3711  FF2215                		ACC08
1236
 3712  FF2215  E2 20         		sep	#PMFLAG
1237
 3713                        		.LONGA	off
1238
 3714                        		.MNLIST
1239
 3715  FF2217  90 10         		bcc	?345
1240
 3716  FF2219  BF 7B 24 FF   		lda	>PRTAB1-1,x
1241
  Tue Jul 17 11:00:24 2018                                                                                               Page   21
1242
 
1243
 
1244
 
1245
 
1246
 3717  FF221D  20 C8 21      		jsr	?210
1247
 3718  FF2220  BF 84 24 FF   		lda	>PRTAB2-1,x
1248
 3719  FF2224  F0 03         		beq	?345
1249
 3720  FF2226  20 C8 21      		jsr	?210
1250
 3721  FF2229  CA            	?345:	dex
1251
 3722  FF222A  D0 B7         		bne	?330
1252
 3723  FF222C  F0 0C         		beq	?355
1253
 3724  FF222E  20 C8 21      	?350:	jsr	?210			; check $XXXX
1254
 3725  FF2231  20 C8 21      		jsr	?210
1255
 3726  FF2234  20 C8 21      		jsr	?210
1256
 3727  FF2237  20 C8 21      		jsr	?210
1257
 3728  FF223A  A5 99         	?355:	lda	ScnSaveX		; maschera coincide ?
1258
 3729  FF223C  C5 9C         		cmp	ScnTmpH
1259
 3730  FF223E  D0 92         		bne	?211			; no, prova next op-code
1260
 3731  FF2240  A4 E5         	?360:	ldy	asmnb			; numero bytes
1261
 3732  FF2242  D0 03         		bne	?361
1262
 3733  FF2244  4C AF 21      		jmp	?96		; store op-code
1263
 3734  FF2247  24 E9         	?361:	bit	asmrel
1264
 3735  FF2249  30 03         		bmi	?362
1265
 3736  FF224B  4C A7 21      		jmp	?90		; store all bytes
1266
 3737  FF224E  70 03         	?362:	bvs	?363
1267
 3738  FF2250  4C 64 21      		jmp	?60a
1268
 3739  FF2253
1269
 3740  FF2253                	?363:
1270
 3741                        		; SMAddrL/H = ptr. opcode
1271
 3742                        		; il salto relativo va calcolato su ptr + #bytes istruzione
1272
 3743                        		; attualmente #bytes = SAddrL + 1
1273
 3744                        		; indirizzo del salto relativo in SMTmpL/H
1274
 3745
1275
 3746  FF2253  A9 00         		lda	#0
1276
 3747  FF2255  EB            		xba
1277
 3748  FF2256  A5 E5         		lda	asmnb
1278
 3749  FF2258  38            		sec
1279
 3750  FF2259                		ACC16
1280
 3751  FF2259  C2 20         		rep	#PMFLAG
1281
 3752                        		.LONGA	on
1282
 3753                        		.MNLIST
1283
 3754  FF225B  65 B6         		adc	SMAddrL		; ptr opcode attuale
1284
 3755  FF225D  38            		sec
1285
 3756  FF225E  E5 BA         		sbc	SMTmpL
1286
 3757  FF2260  49 FF FF      		eor	#$FFFF
1287
 3758  FF2263  1A            		inc	a
1288
 3759  FF2264  85 BA         		sta	SMTmpL		; offset
1289
 3760  FF2266                		ACC08
1290
 3761  FF2266  E2 20         		sep	#PMFLAG
1291
 3762                        		.LONGA	off
1292
 3763                        		.MNLIST
1293
 3764  FF2268  A4 E5         		ldy	asmnb			; # bytes
1294
 3765  FF226A  4C A7 21      		jmp	?90
1295
 3766
1296
 3767  FF226D  A2 00         	?500:	ldx	#0
1297
 3768  FF226F  A9 61         		lda	#'a'
1298
 3769  FF2271  85 E3         		sta	XBUF+1
1299
 3770  FF2273  64 E2         		stz	XBUF
1300
 3771  FF2275  A9 20         		lda	#' '
1301
 3772  FF2277  85 E5         		sta	XBUF+3
1302
 3773  FF2279  64 E4         		stz	XBUF+2
1303
  Tue Jul 17 11:00:24 2018                                                                                               Page   22
1304
 
1305
 
1306
 
1307
 
1308
 3774  FF227B  A5 B8         		lda	SMAddrK
1309
 3775  FF227D  20 7C 19      		jsr	FF_Byte2Hex
1310
 3776  FF2280  85 E7         		sta	XBUF+5
1311
 3777  FF2282  64 E6         		stz	XBUF+4
1312
 3778  FF2284  86 E9         		stx	XBUF+7
1313
 3779  FF2286  64 E8         		stz	XBUF+6
1314
 3780  FF2288  A5 B7         		lda	SMAddrH
1315
 3781  FF228A  20 7C 19      		jsr	FF_Byte2Hex
1316
 3782  FF228D  85 EB         		sta	XBUF+9
1317
 3783  FF228F  64 EA         		stz	XBUF+8
1318
 3784  FF2291  86 ED         		stx	XBUF+11
1319
 3785  FF2293  64 EC         		stz	XBUF+10
1320
 3786  FF2295  A5 B6         		lda	SMAddrL
1321
 3787  FF2297  20 7C 19      		jsr	FF_Byte2Hex
1322
 3788  FF229A  85 EF         		sta	XBUF+13
1323
 3789  FF229C  64 EE         		stz	XBUF+12
1324
 3790  FF229E  86 F1         		stx	XBUF+15
1325
 3791  FF22A0  64 F0         		stz	XBUF+14
1326
 3792  FF22A2  A9 20         		lda	#' '
1327
 3793  FF22A4  85 F3         		sta	XBUF+17
1328
 3794  FF22A6  64 F2         		stz	XBUF+16
1329
 3795  FF22A8  78            		sei
1330
 3796  FF22A9  A2 12         		ldx	#18
1331
 3797  FF22AB  86 62         		stx	KbdCnt
1332
 3798  FF22AD  86 60         		stx	KbdITail
1333
 3799  FF22AF  64 61         		stz	KbdIHead
1334
 3800  FF22B1  CA            		dex
1335
 3801  FF22B2  B5 E2         	?501:	lda	XBUF,x
1336
 3802  FF22B4  95 00         		sta	KbdBuf,x
1337
 3803  FF22B6  CA            		dex
1338
 3804  FF22B7  10 F9         		bpl	?501
1339
 3805  FF22B9  58            		cli
1340
 3806  FF22BA  A9 80         		lda	#$80
1341
 3807  FF22BC  14 74         		trb	ScnAutoIns
1342
 3808  FF22BE  60            		rts
1343
 3809
1344
 3810                        	; convert A to up case
1345
 3811  FF22BF                	upcase:
1346
 3812  FF22BF  C9 61         		cmp	#'a'
1347
 3813  FF22C1  90 06         		bcc	?01
1348
 3814  FF22C3  C9 7B         		cmp	#('z'+1)
1349
 3815  FF22C5  B0 02         		bcs	?01
1350
 3816  FF22C7  29 DF         		and	#$DF
1351
 3817  FF22C9  60            	?01:	rts
1352
 3818
1353
 3819                        	; check A if hex digit
1354
 3820  FF22CA                	chkdgt:
1355
 3821  FF22CA  C9 41         		cmp	#'A'
1356
 3822  FF22CC  90 03         		bcc	?01
1357
 3823  FF22CE  C9 47         		cmp	#'G'
1358
 3824  FF22D0  60            		rts
1359
 3825  FF22D1  C9 30         	?01:	cmp	#'0'
1360
 3826  FF22D3  90 28         		bcc	CRTS
1361
 3827  FF22D5  C9 3A         		cmp	#('9'+1)
1362
 3828  FF22D7  60            		rts
1363
 3829
1364
 3830                        	; return in A the value of the next 2 digits from input buffer
1365
  Tue Jul 17 11:00:24 2018                                                                                               Page   23
1366
 
1367
 
1368
 
1369
 
1370
 3831  FF22D8                	dgt2hex:
1371
 3832  FF22D8  20 FF 22      		jsr	dgt2nbl		; convert digit in nibble
1372
 3833  FF22DB  85 E6         		sta	tmpl
1373
 3834  FF22DD  20 48 1A      		jsr	GetCurCh	; next byte
1374
 3835  FF22E0  20 BF 22      		jsr	upcase
1375
 3836  FF22E3  20 CA 22      		jsr	chkdgt		; check if digit
1376
 3837  FF22E6  90 06         		bcc	?01
1377
 3838  FF22E8  C6 C4         		dec	SMbndx
1378
 3839  FF22EA  A5 E6         		lda	tmpl
1379
 3840  FF22EC  18            		clc
1380
 3841  FF22ED  60            		rts
1381
 3842  FF22EE  48            	?01:	pha
1382
 3843  FF22EF  A5 E6         		lda	tmpl
1383
 3844  FF22F1  0A            		asl	a
1384
 3845  FF22F2  0A            		asl	a
1385
 3846  FF22F3  0A            		asl	a
1386
 3847  FF22F4  0A            		asl	a
1387
 3848  FF22F5  85 E6         		sta	tmpl
1388
 3849  FF22F7  68            		pla
1389
 3850  FF22F8  20 FF 22      		jsr	dgt2nbl		; convert 2nd digt to nibble
1390
 3851  FF22FB  05 E6         		ora	tmpl		; concatene value
1391
 3852  FF22FD                	CRTS:
1392
 3853  FF22FD  38            		sec
1393
 3854  FF22FE  60            		rts
1394
 3855
1395
 3856                        	; convert digiut in A in nibble
1396
 3857  FF22FF                	dgt2nbl:
1397
 3858  FF22FF  C9 3A         		cmp	#('9'+1)
1398
 3859  FF2301  08            		php
1399
 3860  FF2302  29 0F         		and	#$0F
1400
 3861  FF2304  28            		plp
1401
 3862  FF2305  90 02         		bcc	?01
1402
 3863  FF2307  69 08         		adc	#$08
1403
 3864  FF2309  60            	?01:	rts
1404
 3865
1405
 3866                        	;---------------------------------------------------------------------------
1406
 3867                        	; tables used for 65C816
1407
 3868                        	;---------------------------------------------------------------------------
1408
 3869
1409
 3870                        	; table of compact mnemonic for 65C816 op-code (low byte)
1410
 3871  FF230A                	MEMTBLL:
1411
 3872                        		;;	BRK  PHP  BPL  CLC  JSR  PLP  BMI  SEC
1412
 3873  FF230A  1C 8A 1C 23 5D 		.DB	$1C, $8A, $1C, $23, $5D, $8B, $1B, $A1	; 00
1413
               8B 1B A1
1414
 3874                        		;;	RTI  PHA  BVC  CLI  RTS  PLA  BVS  SEI
1415
 3875  FF2312  9D 8A 1D 23 9D 		.DB	$9D, $8A, $1D, $23, $9D, $8B, $1D, $A1	; 08
1416
               8B 1D A1
1417
 3876                        		;;	BRA  DEY  BCC  TYA  LDY  TAY  BCS  CLV
1418
 3877  FF231A  1C 29 19 AE 69 		.DB	$1C, $29, $19, $AE, $69, $A8, $19, $23	; 10
1419
               A8 19 23
1420
 3878                        		;;	CPY  INY  BNE  CLD  CPX  INX  BEQ  SED
1421
 3879  FF2322  24 53 1B 23 24 		.DB	$24, $53, $1B, $23, $24, $53, $19, $A1	; 18
1422
               53 19 A1
1423
 3880                        		;;	TSB  BIT  JMP  JMP  STY  LDY  CPY  CPX
1424
 3881  FF232A  AD 1A 5B 5B A5 		.DB	$AD, $1A, $5B, $5B, $A5, $69, $24, $24	; 20
1425
               69 24 24
1426
 3882                        		;;	TXA  TXS  TAX  TSX  DEX  PHX  NOP  PLX
1427
  Tue Jul 17 11:00:24 2018                                                                                               Page   24
1428
 
1429
 
1430
 
1431
 
1432
 3883  FF2332  AE AE A8 AD 29 		.DB	$AE, $AE, $A8, $AD, $29, $8A, $7C, $8B	; 28
1433
               8A 7C 8B
1434
 3884                        		;;	ASL  ROL  LSR  ROR  STX  LDX  DEC  INC
1435
 3885  FF233A  15 9C 6D 9C A5 		.DB	$15, $9C, $6D, $9C, $A5, $69, $29, $53	; 30
1436
               69 29 53
1437
 3886                        		;;	ORA  AND  EOR  ADC  STA  LDA  CMP  SBC
1438
 3887  FF2342  84 13 34 11 A5 		.DB	$84, $13, $34, $11, $A5, $69, $23, $A0	; 38
1439
               69 23 A0
1440
 3888                        		;;	PHD  TCS  PLD  TSC  PHK  TCD  RTL  TDC
1441
 3889  FF234A  8A A9 8B AD 8A 		.DB	$8A, $A9, $8B, $AD, $8A, $A9, $9D, $A9	; 40
1442
               A9 9D A9
1443
 3890                        		;;	PHB  TXY  PLB  TYX  WAI  STP  XBA  XCE
1444
 3891  FF2352  8A AE 8B AE C0 		.DB	$8A, $AE, $8B, $AE, $C0, $A5, $C8, $C9	; 48
1445
               A5 C8 C9
1446
 3892                        		;;	COP  JSL  WDM  PER  BRL  LDX  REP  SEP
1447
 3893  FF235A  24 5D C1 89 1C 		.DB	$24, $5D, $C1, $89, $1C, $69, $99, $A1	; 50
1448
               69 99 A1
1449
 3894                        		;;	INC  DEC  PHY  PLY  TRB  STZ  MVP  MVN
1450
 3895  FF2362  53 29 8A 8B AC 		.DB	$53, $29, $8A, $8B, $AC, $A5, $75, $75	; 58
1451
               A5 75 75
1452
 3896                        		;;	PEI  PEA  JML
1453
 3897  FF236A  89 89 5B      		.DB	$89, $89, $5B
1454
 3898
1455
 3899                        	; table of compact mnemonic for 65C816 op-code (high byte)
1456
 3900  FF236D                	MEMTBLH:
1457
 3901                        		;;	BRK  PHP  BPL  CLC  JSR  PLP  BMI  SEC
1458
 3902  FF236D  D8 62 5A 48 26 		.DB	$D8, $62, $5A, $48, $26, $62, $94, $88	; 00
1459
               62 94 88
1460
 3903                        		;;	RTI  PHA  BVC  CLI  RTS  PLA  BVS  SEI
1461
 3904  FF2375  54 44 C8 54 68 		.DB	$54, $44, $C8, $54, $68, $44, $E8, $94	; 08
1462
               44 E8 94
1463
 3905                        		;;	BRA  DEY  BCC  TYA  LDY  TAY  BCS  CLV
1464
 3906  FF237D  C4 B4 08 84 74 		.DB	$C4, $B4, $08, $84, $74, $B4, $28, $6E	; 10
1465
               B4 28 6E
1466
 3907                        		;;	CPY  INY  BNE  CLD  CPX  INX  BEQ  SED
1467
 3908  FF2385  74 F4 CC 4A 72 		.DB	$74, $F4, $CC, $4A, $72, $F2, $A4, $8A	; 18
1468
               F2 A4 8A
1469
 3909                        		;;	TSB  BIT  JMP  JMP  STY  LDY  CPY  CPX
1470
 3910  FF238D  06 AA A2 A2 74 		.DB	$06, $AA, $A2, $A2, $74, $74, $74, $72	; 20
1471
               74 74 72
1472
 3911                        		;;	TXA  TXS  TAX  TSX  DEX  PHX  NOP  PLX
1473
 3912  FF2395  44 68 B2 32 B2 		.DB	$44, $68, $B2, $32, $B2, $72, $22, $72	; 28
1474
               72 22 72
1475
 3913                        		;;	ASL  ROL  LSR  ROR  STX  LDX  DEC  INC
1476
 3914  FF239D  1A 1A 26 26 72 		.DB	$1A, $1A, $26, $26, $72, $72, $88, $C8	; 30
1477
               72 88 C8
1478
 3915                        		;;	ORA  AND  EOR  ADC  STA  LDA  CMP  SBC
1479
 3916  FF23A5  C4 CA 26 48 44 		.DB	$C4, $CA, $26, $48, $44, $44, $A2, $C8	; 38
1480
               44 A2 C8
1481
 3917                        		;;	PHD  TCS  PLD  TSC  PHK  TCD  RTL  TDC
1482
 3918  FF23AD  4A 28 4A 08 58 		.DB	$4A, $28, $4A, $08, $58, $0A, $5A, $48	; 40
1483
               0A 5A 48
1484
 3919                        		;;	PHB  TXY  PLB  TYX  WAI  STP  XBA  XCE
1485
 3920  FF23B5  46 74 46 B2 94 		.DB	$46, $74, $46, $B2, $94, $62, $C4, $0C	; 48
1486
               62 C4 0C
1487
 3921                        		;;	COP  JSL  WDM  PER  BRL  LDX  REP  SEP
1488
 3922  FF23BD  22 1A 5C A6 DA 		.DB	$22, $1A, $5C, $A6, $DA, $72, $A2, $A2	; 50
1489
  Tue Jul 17 11:00:24 2018                                                                                               Page   25
1490
 
1491
 
1492
 
1493
 
1494
               72 A2 A2
1495
 3923                        		;;	INC  DEC  PHY  PLY  TRB  STZ  MVP  MVN
1496
 3924  FF23C5  C8 88 74 74 C6 		.DB	$C8, $88, $74, $74, $C6, $76, $E2, $DE	; 58
1497
               76 E2 DE
1498
 3925                        		;;	PEI  PEA  JML
1499
 3926  FF23CD  94 84 9A      		.DB	$94, $84, $9A
1500
 3927
1501
 3928                        	; table of op-code that will be trnslated for access mnemonics table
1502
 3929  FF23D0                	OPTAB:
1503
 3930                        		;;	STZ  STZ  STZ  STZ  TRB  TRB  JML  JML
1504
 3931  FF23D0  64 74 9C 9E 14 		.DB	$64, $74, $9C, $9E, $14, $1C, $5C, $DC
1505
               1C 5C DC
1506
 3932                        		;;	JSR  MVP  MVN  PEI  PEA  BIT
1507
 3933  FF23D8  FC 44 54 D4 F4 		.DB	$FC, $44, $54, $D4, $F4, $89
1508
               89
1509
 3934  FF23DE
1510
 3935          00000D        	OPTABLEN	.EQU	($ - OPTAB - 1)
1511
 3936
1512
 3937                        	; translated index for access mnemonics table
1513
 3938  FF23DE                	TRANSL:
1514
 3939  FF23DE  5D 5D 5D 5D 5C 		.DB	$5D, $5D, $5D, $5D, $5C, $5C, $62, $62
1515
               5C 62 62
1516
 3940  FF23E6  04 5E 5F 60 61 		.DB	$04, $5E, $5F, $60, $61, $21
1517
               21
1518
 3941
1519
 3942                        	; table of addressing mode for even op-code
1520
 3943                        	; this table is indexed by value 00..7F
1521
 3944  FF23EC                	AMODE:
1522
 3945                        	;; 00..0E
1523
 3946                        	;;	BRK		COP #		TSB dp		ASL dp
1524
 3947  FF23EC  00 01 02 02   	.DB	AIMPL,		AIMM,		ADP,		ADP
1525
 3948  FF23F0
1526
 3949                        	;;	PHP		ASL A		TSB abs		ASL abs
1527
 3950  FF23F0  00 00 03 03   	.DB	AIMPL,		AIMPL,		AABS,		AABS
1528
 3951
1529
 3952  FF23F4
1530
 3953                        	;; 10..1E
1531
 3954                        	;;	BPL 		ORA (dp)	TRB dp		ASL dp,x
1532
 3955  FF23F4  0D 0F 02 08   	.DB	AREL,		AIND,		ADP,		ADPX
1533
 3956
1534
 3957                        	;;	CLC		INC A		TRB abs		ASL abs,x
1535
 3958  FF23F8  00 00 03 09   	.DB	AIMPL,		AIMPL,		AABS,		AABSX
1536
 3959
1537
 3960                        	;; 20..2E
1538
 3961                        	;;	JSR abs		JSL long	BIT dp		ROL dp
1539
 3962  FF23FC  03 04 02 02   	.DB	AABS,		ALONG,		ADP,		ADP
1540
 3963  FF2400
1541
 3964                        	;;	PLP		ROL A		BIT abs		ROL abs
1542
 3965  FF2400  00 00 03 03   	.DB	AIMPL,		AIMPL,		AABS,		AABS
1543
 3966
1544
 3967
1545
 3968                        	;; 30..3E
1546
 3969                        	;;	BMI		AND (dp)	BIT dp,x	ROL dp,x
1547
 3970  FF2404  0D 0F 08 08   	.DB	AREL,		AIND,		ADPX,		ADPX
1548
 3971
1549
 3972                        	;;	SEC		DEC A		BIT abs,x	ROL abs,x
1550
 3973  FF2408  00 00 09 09   	.DB	AIMPL,		AIMPL,		AABSX,		AABSX
1551
  Tue Jul 17 11:00:24 2018                                                                                               Page   26
1552
 
1553
 
1554
 
1555
 
1556
 3974
1557
 3975
1558
 3976                        	;; 40..4E
1559
 3977                        	;;	RTI		WDM #		MVP		LSR dp
1560
 3978  FF240C  00 01 14 02   	.DB	AIMPL,		AIMM,		AMOV,		ADP
1561
 3979
1562
 3980                        	;;	PHA		LSR A		JMP abs		LSR abs
1563
 3981  FF2410  00 00 03 03   	.DB	AIMPL,		AIMPL,		AABS,		AABS
1564
 3982
1565
 3983
1566
 3984                        	;; 50.5E
1567
 3985                        	;;	BVC		EOR (dp)	MVN		LSR dp,x
1568
 3986  FF2414  0D 0F 14 08   	.DB	AREL,		AIND,		AMOV,		ADPX
1569
 3987
1570
 3988                        	;;	CLI		PHY		JML long	LSR abs,x
1571
 3989  FF2418  00 00 04 09   	.DB	AIMPL,		AIMPL,		ALONG,		AABSX
1572
 3990
1573
 3991
1574
 3992                        	;; 60..6E
1575
 3993                        	;;	RTS		PER rel16	STZ dp		ROR dp
1576
 3994  FF241C  00 15 02 02   	.DB	AIMPL,		A16R,		ADP,		ADP
1577
 3995
1578
 3996                        	;;	PLA		ROR A		JMP (abs)	ROR abs
1579
 3997  FF2420  00 00 0B 03   	.DB	AIMPL,		AIMPL,		ABIND,		AABS
1580
 3998
1581
 3999
1582
 4000                        	;; 70..7E
1583
 4001                        	;;	BVS		ADC (dp)	STZ dp,x	ROR dp,x
1584
 4002  FF2424  0D 0F 08 08   	.DB	AREL,		AIND,		ADPX,		ADPX
1585
 4003
1586
 4004                        	;;	SEI		PLY		JMP (abs,x)	ROR abs,x
1587
 4005  FF2428  00 00 0E 09   	.DB	AIMPL,		AIMPL,		ABXI,		AABSX
1588
 4006
1589
 4007
1590
 4008                        	;; 80..8E
1591
 4009                        	;;	BRA		BRL		STY dp		STX dp
1592
 4010  FF242C  0D 15 02 02   	.DB	AREL,		A16R,		ADP,		ADP
1593
 4011
1594
 4012                        	;;	DEY		TXA		STY abs		STX abs
1595
 4013  FF2430  00 00 03 03   	.DB	AIMPL,		AIMPL,		AABS,		AABS
1596
 4014
1597
 4015
1598
 4016                        	;; 90..9E
1599
 4017                        	;;	BCC		STA (dp)	STY dp,x	STX dp,y
1600
 4018  FF2434  0D 0F 08 0C   	.DB	AREL,		AIND,		ADPX,		ADPY
1601
 4019
1602
 4020                        	;;	TYA		TXS		STZ abs		STZ abs,x
1603
 4021  FF2438  00 00 03 09   	.DB	AIMPL,		AIMPL,		AABS,		AABSX
1604
 4022
1605
 4023
1606
 4024                        	;; A0..AE
1607
 4025                        	;;	LDY #		LDX #		LDY dp		LDX dp
1608
 4026  FF243C  41 41 02 02   	.DB	AXIMM,		AXIMM,		ADP,		ADP
1609
 4027  FF2440
1610
 4028                        	;;	TAY		TAX		LDY abs		LDX abs
1611
 4029  FF2440  00 00 03 03   	.DB	AIMPL,		AIMPL,		AABS,		AABS
1612
 4030
1613
  Tue Jul 17 11:00:24 2018                                                                                               Page   27
1614
 
1615
 
1616
 
1617
 
1618
 4031
1619
 4032                        	;; B0..BE
1620
 4033                        	;;	BCS		LDA (dp)	LDY dp,x	LDX dp,y
1621
 4034  FF2444  0D 0F 08 0C   	.DB	AREL,		AIND,		ADPX,		ADPY
1622
 4035
1623
 4036                        	;;	CLV		TSX		LDY abs,x	LDX abs,y
1624
 4037  FF2448  00 00 09 0A   	.DB	AIMPL,		AIMPL,		AABSX,		AABSY
1625
 4038
1626
 4039
1627
 4040                        	;; C0..CE
1628
 4041                        	;;	CPY #		REP #		CPY dp		DEC dp
1629
 4042  FF244C  41 01 02 02   	.DB	AXIMM,		AIMM,		ADP,		ADP
1630
 4043  FF2450
1631
 4044                        	;;	INY		DEX		CPY abs		DEC abs
1632
 4045  FF2450  00 00 03 03   	.DB	AIMPL,		AIMPL,		AABS,		AABS
1633
 4046  FF2454
1634
 4047  FF2454
1635
 4048                        	;; D0..DE
1636
 4049                        	;;	BNE		CMP (dp)	PEI (dp)	DEC dp,x
1637
 4050  FF2454  0D 0F 0F 08   	.DB	AREL,		AIND,		AIND,		ADPX
1638
 4051
1639
 4052                        	;;	CLD		PHX		JML [abs]	DEC abs,x
1640
 4053  FF2458  00 00 16 09   	.DB	AIMPL,		AIMPL,		AJML,		AABSX
1641
 4054
1642
 4055
1643
 4056                        	;; E0..EE
1644
 4057                        	;;	CPX #		SEP #		CPX dp		INC dp
1645
 4058  FF245C  41 01 02 02   	.DB	AXIMM,		AIMM,		ADP,		ADP
1646
 4059
1647
 4060                        	;;	INX		NOP		CPX abs		INC abs
1648
 4061  FF2460  00 00 03 03   	.DB	AIMPL,		AIMPL,		AABS,		AABS
1649
 4062
1650
 4063
1651
 4064                        	;; F0..FE
1652
 4065                        	;;	BEQ		SBC (dp)	PEA #16		INC dp,x
1653
 4066  FF2464  0D 0F 17 08   	.DB	AREL,		AIND,		A16IMM,		ADPX,
1654
 4067
1655
 4068                        	;;	SED		PLX		JSR (abs,x)	INC abs,x
1656
 4069  FF2468  00 00 0E 09   	.DB	AIMPL,		AIMPL,		ABXI,		AABSX
1657
 4070
1658
 4071                        	; addressing mode for odd op-code -- note that all op-code <XB> are implied
1659
 4072                        	; op-code <X1>, <X3>, <X5>, <X7>, <X9>, <XD>, <XF> are relative to accumulator
1660
 4073                        	; this table is indexed by value 80..8F
1661
 4074                        	;; X1, X5, X9, XD
1662
 4075                        	;;	(dp,x)		dp		#		abs
1663
 4076  FF246C  06 02 81 03   	.DB	AXIND,		ADP,		AMIMM,		AABS
1664
 4077
1665
 4078                        	;; X1, X5, X9, XD
1666
 4079                        	;;	(dp),y		dp,x		abs,y		abs,x
1667
 4080  FF2470  07 08 0A 09   	.DB	AYIND,		ADPX,		AABSY,		AABSX
1668
 4081
1669
 4082                        	;; X3, X7, XB, XF
1670
 4083                        	;;	rel,s		[dp]		implied		long
1671
 4084  FF2474  10 11 00 04   	.DB	ASTK,		ALIND,		AIMPL,		ALONG
1672
 4085
1673
 4086                        	;; X3, X7, XB, XF
1674
 4087                        	;;	(rel,s),y	[dp],y		implied		long,x
1675
  Tue Jul 17 11:00:24 2018                                                                                               Page   28
1676
 
1677
 
1678
 
1679
 
1680
 4088  FF2478  13 12 00 05   	.DB	AYSTK,		AYLIND,		AIMPL,		ALONGX
1681
 4089
1682
 4090
1683
 4091                        	;; table for print symbols for the addressing mode
1684
 4092  FF247C                	PRTAB1:
1685
 4093  FF247C  2C 29 5D 2C 2C 		.DB	',)],,#([$'
1686
               23 28 5B 24
1687
 4094
1688
 4095  FF2485                	PRTAB2:
1689
 4096  FF2485  59 00 00 53 58 		.DB	'Y', 0, 0, 'SX$$$', 0
1690
               24 24 24 00
1691
 4097
1692
 4098                        	;; table that encode printing symbols and number of bytes for the op-code
1693
 4099                        	;; this table is indexed by a value given by table AMODE
1694
 4100                        	;; last 2 bits give the numbers of bytes
1695
 4101                        	;; bit <15:5> specify what must be printed (index in array PRTABx)
1696
 4102                        	;; after bit 12 and bit 06 must be printed an hexadecimal value
1697
 4103                        	;; <15>		$	NULL
1698
 4104                        	;; <14>		[	$
1699
 4105                        	;; <13>		(	$
1700
 4106                        	;; <12>		#	$
1701
 4107                        	;; <11>		,	X
1702
 4108                        	;; <10>		,	S
1703
 4109                        	;; <09>		]	NULL
1704
 4110                        	;; <08>		)	NULL
1705
 4111                        	;; <07>		,	Y
1706
 4112                        	;; <06>
1707
 4113                        	;; <05>
1708
 4114                        	;; <04>
1709
 4115                        	;; <03>
1710
 4116                        	;; <02>
1711
 4117                        	;; <01:00>	number of bytes (0..3)
1712
 4118  FF248E                	ENCTAB:
1713
 4119  FF248E  0000 0110 0180 		.DW	$0000, $1001, $8001, $8002, $8003, $8803, $2901, $2181
1714
               0280 0380 0388
1715
               0129 8121
1716
 4120  FF249E  0188 0288 8280 		.DW	$8801, $8802, $8082, $2102, $8081, $8001, $2902, $2101
1717
               0221 8180 0180
1718
               0229 0121
1719
 4121  FF24AE  0184 0142 8142 		.DW	$8401, $4201, $4281, $2581, $1002, $8002, $4202, $1002
1720
               8125 0210 0280
1721
               0242 0210
1722
 4122
1723
 4123                        	;---------------------------------------------------------------------------
1724
 4124                        	; tables used for 6502/65C02
1725
 4125                        	;---------------------------------------------------------------------------
1726
 4126
1727
 4127                        	; compact mnemonics for 6502/65C02
1728
 4128  FF24BE                	MEMTBLL1:
1729
 4129  FF24BE  1C 8A 1C 23 5D 		.DB	$1C, $8A, $1C, $23, $5D, $8B, $1B, $A1
1730
               8B 1B A1
1731
 4130  FF24C6  9D 8A 1D 23 9D 		.DB	$9D, $8A, $1D, $23, $9D, $8B, $1D, $A1
1732
               8B 1D A1
1733
 4131  FF24CE  1C 29 19 AE 69 		.DB	$1C, $29, $19, $AE, $69, $A8, $19, $23
1734
               A8 19 23
1735
 4132  FF24D6  24 53 1B 23 24 		.DB	$24, $53, $1B, $23, $24, $53, $19, $A1
1736
               53 19 A1
1737
  Tue Jul 17 11:00:24 2018                                                                                               Page   29
1738
 
1739
 
1740
 
1741
 
1742
 4133  FF24DE  00 1A 5B 5B A5 		.DB	$00, $1A, $5B, $5B, $A5, $69, $24, $24
1743
               69 24 24
1744
 4134  FF24E6  AE AE A8 AD 29 		.DB	$AE, $AE, $A8, $AD, $29, $8A, $7C, $8B
1745
               8A 7C 8B
1746
 4135  FF24EE  15 9C 6D 9C A5 		.DB	$15, $9C, $6D, $9C, $A5, $69, $29, $53
1747
               69 29 53
1748
 4136  FF24F6  84 13 34 11 A5 		.DB	$84, $13, $34, $11, $A5, $69, $23, $A0
1749
               69 23 A0
1750
 4137  FF24FE  53 29 8A 8B 9B 		.DB	$53, $29, $8A, $8B, $9B, $A3, $18, $18
1751
               A3 18 18
1752
 4138  FF2506  A5 AD AC 00   		.DB	$A5, $AD, $AC, $00
1753
 4139  FF250A
1754
 4140  FF250A                	MEMTBLH1:
1755
 4141  FF250A  D8 62 5A 48 26 		.DB	$D8, $62, $5A, $48, $26, $62, $94, $88
1756
               62 94 88
1757
 4142  FF2512  54 44 C8 54 68 		.DB	$54, $44, $C8, $54, $68, $44, $E8, $94
1758
               44 E8 94
1759
 4143  FF251A  C4 B4 08 84 74 		.DB	$C4, $B4, $08, $84, $74, $B4, $28, $6E
1760
               B4 28 6E
1761
 4144  FF2522  74 F4 CC 4A 72 		.DB	$74, $F4, $CC, $4A, $72, $F2, $A4, $8A
1762
               F2 A4 8A
1763
 4145  FF252A  00 AA A2 A2 74 		.DB	$00, $AA, $A2, $A2, $74, $74, $74, $72
1764
               74 74 72
1765
 4146  FF2532  44 68 B2 32 B2 		.DB	$44, $68, $B2, $32, $B2, $72, $22, $72
1766
               72 22 72
1767
 4147  FF253A  1A 1A 26 26 72 		.DB	$1A, $1A, $26, $26, $72, $72, $88, $C8
1768
               72 88 C8
1769
 4148  FF2542  C4 CA 26 48 44 		.DB	$C4, $CA, $26, $48, $44, $44, $A2, $C8
1770
               44 A2 C8
1771
 4149  FF254A  C8 88 74 74 86 		.DB	$C8, $88, $74, $74, $86, $86, $E6, $E8
1772
               86 E6 E8
1773
 4150  FF2552  76 06 C6 00   		.DB	$76, $06, $C6, $00
1774
 4151
1775
 4152                        	; 6502 invalid opcode
1776
 4153  FF2556                	OPTAB1:
1777
 4154  FF2556  64 74 9C 9E 04 		.DB	$64, $74, $9C, $9E, $04, $0C, $14, $1C
1778
               0C 14 1C
1779
 4155  FF255E
1780
 4156          000007        	OPTAB1LEN	.EQU	($ - OPTAB1 - 1)
1781
 4157
1782
 4158  FF255E  80 34 1A 3A 5A 		.DB	$80, $34, $1A, $3A, $5A, $7A, $DA, $FA, $3C, $7C
1783
               7A DA FA 3C 7C
1784
 4159
1785
 4160          000011        	INVLEN		.EQU	($ - OPTAB1 - 1)
1786
 4161
1787
 4162                        	; translation table for some 65C02 op-code
1788
 4163  FF2568                	TRANSL1:
1789
 4164  FF2568  83 83 83 83 A3 		.DB	$83, $83, $83, $83, $A3, $A3, $C3, $C3
1790
               A3 C3 C3
1791
 4165
1792
 4166                        	; encoded addressing mode
1793
 4167                        	;
1794
 4168                        	;	0:	invalid
1795
 4169                        	;	1:	#
1796
 4170                        	;	2:	ZP	(tesrt asmbit)
1797
 4171                        	;	3:	ABS
1798
 4172                        	;	4:	IMPLIED
1799
  Tue Jul 17 11:00:24 2018                                                                                               Page   30
1800
 
1801
 
1802
 
1803
 
1804
 4173                        	;	5:	ACCUM
1805
 4174                        	;	6:	(ZP,X)
1806
 4175                        	;	7:	(ZP),Y
1807
 4176                        	;	8:	ZP,X
1808
 4177                        	;	9:	ABS,X
1809
 4178                        	;	A:	ABS,Y
1810
 4179                        	;	B:	(ABS)
1811
 4180                        	;	C:	ZP,Y
1812
 4181                        	;	D:	REL	(test asmbit)
1813
 4182                        	;	E:	(ABS,X)
1814
 4183                        	;	F:	(ZP)
1815
 4184
1816
 4185                        	; 6502/65C02 addressing mode table
1817
 4186  FF2570                	AMODE1:
1818
 4187                        		; even op-code
1819
 4188  FF2570  40 22 45 33 DF 		.DB	$40, $22, $45, $33, $DF, $28, $45, $39	; 00..07 - OP 00..1E
1820
               28 45 39
1821
 4189  FF2578  30 22 45 33 DF 		.DB	$30, $22, $45, $33, $DF, $88, $45, $99	; 08..0F - OP 20..3E
1822
               88 45 99
1823
 4190  FF2580  40 02 45 33 DF 		.DB	$40, $02, $45, $33, $DF, $08, $44, $09	; 10..17 - OP 40..5E
1824
               08 44 09
1825
 4191  FF2588  40 22 45 B3 DF 		.DB	$40, $22, $45, $B3, $DF, $88, $44, $E9	; 18..1F - OP 60..7E
1826
               88 44 E9
1827
 4192  FF2590  D0 22 44 33 DF 		.DB	$D0, $22, $44, $33, $DF, $8C, $44, $39	; 20..27 - OP 80..9E
1828
               8C 44 39
1829
 4193  FF2598  11 22 44 33 DF 		.DB	$11, $22, $44, $33, $DF, $8C, $44, $9A	; 28..2F - OP A0..BE
1830
               8C 44 9A
1831
 4194  FF25A0  10 22 44 33 DF 		.DB	$10, $22, $44, $33, $DF, $08, $44, $09	; 30..37 - OP C0..DE
1832
               08 44 09
1833
 4195  FF25A8  10 22 44 33 DF 		.DB	$10, $22, $44, $33, $DF, $08, $44, $09	; 38..3F - OP E0..FE
1834
               08 44 09
1835
 4196  FF25B0
1836
 4197                        		; odd op-code
1837
 4198  FF25B0  62 13 78 A9   		.DB	$62, $13, $78, $A9			; 80..87
1838
 4199  FF25B4
1839
 4200  FF25B4  2D            		.DB	$2D					; 88..89 - RMB/BBR
1840
 4201
1841
 4202  FF25B5                	ENCTAB1:
1842
 4203  FF25B5  00 21 81 82 00 		.DB	$00, $21, $81, $82, $00, $00, $59, $4D
1843
               00 59 4D
1844
 4204  FF25BD  91 92 86 4A 85 		.DB	$91, $92, $86, $4A, $85, $9D, $5A, $49
1845
               9D 5A 49
1846
 4205
1847
 4206                        	;; table for print symbols for the 6502/65C02 addressing mode
1848
 4207  FF25C5                	PRTAB11:
1849
 4208  FF25C5  2C 29 2C 23 28 		.DB	',),#($'
1850
               24
1851
 4209  FF25CB                	PRTAB21:
1852
 4210  FF25CB  59 00 58 24 24 		.DB	'Y', 0, 'X$$', 0
1853
               00
1854
 
1855
 
1856
             Lines Assembled : 4132                  Errors : 0
1857
 
1858
 
1859