2023年5月19日金曜日

FM-7にRTCとSDを接続する試み(SDカード編 その5 修正版です)

SDRWFMが完成したつもりでしたが、不具合がいくつか見つかりましたので修正しました。


自分で使用する場合には無意識のうちに不具合が出ないような使い方をしてしまいますので、知人に使用していただいて不具合などのチェックをしていただきました。


前回と同じ画像です

(前回と同じ画像を貼ってありますが、画像がないとアイコンが表示されないようなので、それを避けるためです。)


修正点は以下の3点です。
(1)ファイル名に「-」(ハイフン)を使えるようにしました。
 パラメータ取得時に、入力文字列を区切るための文字を0x30未満の文字すべてとしていたので、ハイフンも区切り文字として扱われてしまっていました。F-BASICではファイル名にハイフンも含まれますので、区切り文字から外すように修正しました。
(2)Windows上のXM7などでバイナリ保存したファイルをSDにコピーして、それをFM-7で読み出すと正常に読み込めない場合がある点を修正しました。
 バイナリ保存されたBASICプログラム中には、リンクポインタとして保存アドレスが直接書き込まれているので、同じFM-7であっても機器の条件によってBASICプログラムの保存アドレスが異なることがあるために、そのまま読み込んだのでは正常な範囲に保存されないことがあり得ます。これを解決するために、F-BASICに用意されているリンクポインタの修正をするルーチンを使用して、リンクポインタを変換しながら読み込むことにしました。
(3)FM-7上で機械語ファイルを保存する場合に、末尾の5バイトのフッタを付加していませんでした。実用上の不便はありませんが、互換性を考慮してフッタを付加することにしました。

その他、修正点ではありませんが、使用するSD(SDHCも)カードを初期化する際にはアロケーションサイズを32KBにする必要があることも指摘していただきました。


0001				*
0002				*  SDRWFM.TXT
0003				*
0004				*  SD Read/Write for FM-7
0005				*
0006				*    use RTC & SD Card
0007				*
0008				*    6821(PIA) Port A -- RTC (I2C Mode)
0009				*
0010				*        SBC     RTC                 Ext IO
0011				*    CA2  2  --       --  HV4 LV4 --   IO1
0012				*    PA0  3  --  SCL  --  HV1 LV1 --   IO4
0013				*    PA1  4  --       --  HV2 LV2 --   IO3
0014				*    PA7 10  --  SDA  --  HV3 LV3 --   IO2
0015				*    GND     --       --          --   GND
0016				*            --       --          --   3V3
0017				*
0018				*                     
0019				*    6821(PIA) Port B -- SD (SPI Mode)
0020				*
0021				*        SBC                  SD
0022				*    CB2 12  --  HV4 LV4 --   SCK
0023				*    PB0 13  --  HV1 LV1 --   CS
0024				*    PB1 14  --  HV2 LV2 --   MISO
0025				*    PB7 20  --  HV3 LV3 --   MOSI
0026				*    GND 31  --          --   GND
0027				*    VCC 33  --          --   VCC
0028				*
0029				*    cf. all data line use level converter
0030				*
0031				*    PB  output mode
0032				*    CB2 1bit output
0033				*
0034				*    READ/WRITE BUFFER  $5E00 - 5FFF
0035				*
0036				*    Ascii program readable '2023.04.18
0037				*    Fix date routine       '2023.04.12
0038				*    Implement write cmd    '2023.04.07
0039				*    Add command            '2023.03.14
0040				*    Change use Port B      '2023.03.07
0041				*    Original version       '2022.06.11
0042				*         Copyright by Y.Yamamoto
0043				*
0044	6000			STTADR	EQU     $6000   		
0045				
0046	FBB8			INCHA 	EQU     $FBB8   		for FM-7
0047	FBBB			OUTCHA	EQU     $FBBB   		for FM-7
0048	FBF7			CSRON 	EQU     $FBF7   		for FM-7
0049	D807			LININP	EQU     $D807   		for FM-7 (to $043D- )
0050				*DEVNO EQU $BF for FM-7
0051	043D			LINBUF	EQU     $043D   		1 line input buffer for F-BASIC
0052	033C			TXTBUF	EQU     $033C   		text buffer after conversion for F-BASIC
0053	9162			RDLINO	EQU     $9162   		read line number for F-BASIC
0054	FBF1			LININT	EQU     $FBF1   		(=C28C) one line translation for F-BASIC
0055	C730			FIXPTR	EQU     $C730   		fix link pointer of binary saved file for F-BASIC
0056	004B			LINO1 	EQU     $4B     		
0057	033A			LINO2 	EQU     $33A    		
0058	000D			CR    	EQU     $0D     		
0059	000A			LF    	EQU     $0A     		
0060	0020			SPC   	EQU     $20     		
0061	001B			ESC   	EQU     $1B     		
0062				
0063	5E00			RWBUF 	EQU     STTADR-$200		
0064				
0065	02FA			FMDAT 	EQU     $02FA   		date of FM-7
0066	FD9E			PBDAT 	EQU     $FD9E   		for FM-7
0067	FD9F			PBCTL 	EQU     PBDAT+1 		
0068	0033			BASADP	EQU     $33     		(33,34) pointer for F-BASIC
0069	0035			BASAEP	EQU     $35     		(35,36) pointer for F-BASIC
0070	2000			TXTADR	EQU     $2000   		load adr for TEXT
0071	00E5			DELMK 	EQU     $E5     		delete mark
0072				
0073	6000			      	ORG     STTADR  		
0074				
0075	6000	16	00A0	START 	LBRA    MAIN    		
0076	6003	01		VN    	FCB     1       		version no
0077	6004	00		SCTN0 	FCB     0       		top adrs of sct
0078	6005	00		SCTN1 	FCB     0       		
0079	6006	00		SCTN2 	FCB     0       		
0080	6007	00		SCTN3 	FCB     0       		
0081	6008	00		RESDAT	FCB     0       		response data
0082	6009	00		SDHC  	FCB     0       		sd:0,sdhc:1
0083				
0084	600A	0000		SCTBPB	FDB     00      		sct no of BPB(4bytes)
0085	600C	0000		      	FDB     00      		
0086	600E	0000		SCTFAT	FDB     00      		sct no of FAT#1(4bytes)
0087	6010	0000		      	FDB     00      		
0088	6012	0000		SCTDIR	FDB     00      		sct no of DIR(4bytes)
0089	6014	0000		      	FDB     00      		
0090	6016	0000		SCTDSV	FDB     00      		save sct no of DIR(4bytes)
0091	6018	0000		      	FDB     00      		
0092	601A	0000		SCTCLT	FDB     00      		sct no of top CLUSTER(4bytes)
0093	601C	0000		      	FDB     00      		if SD:#2, SDHC:#3
0094	601E	00		SCTPCL	FCB     0       		sct per cluster
0095	601F	FF		DIRENT	RMB     32      		directory entry
0096	603F	FF		WMDY  	RMB     3       		mon,day,year
0097	6042	FF		WFSIZ 	RMB     4       		file size(4bytes)
0098	6046	FF		FILSIZ	RMB     2       		file size
0099	6048	0000		CLSTH 	FDB     00      		cluster High
0100	604A	0000		CLSTL 	FDB     00      		cluster Low
0101	604C	00		CNT   	FCB     0       		
0102	604D	00		MCFLG 	FCB     0       		0:machine code, $FF,$FE:binary save 1:else
0103	604E	00		TPGFLG	FCB     0       		1:top page 0:else
0104	604F	FF		FNAME 	RMB     11      		file name(8+3)
0105	605A	00		DPGNO 	FCB     0       		page no of empty dir entry
0106	605B	0000		DIROFS	FDB     00      		offset of empty dir entry
0107	605D	0000		BASEXP	FDB     00      		basic exe adr
0108	605F	0000		MCADP 	FDB     00      		machine code start adr
0109	6061	0000		MCAEP 	FDB     00      		machine code end adr
0110	6063	0000		MCEXP 	FDB     00      		machine dode exec adr
0111	6065	0000		EXSTFL	FDB     00      		ofset of exist dir entry
0112	6067	0000		CVTLEN	FDB     00      		length of converted text
0113	6069	0000		RDTOP 	FDB     00      		adr of read point
0114	606B	0000		SVTOP 	FDB     00      		adr of saved point
0115	606D	0000		WK1   	FDB     00      		
0116	606F	0000		WK2   	FDB     00      		
0117	6071	0000		WK3   	FDB     00      		
0118	6073	0000		WK4   	FDB     00      		
0119	6075	0000		WK0   	FDB     00      		
0120				
0121	6077	FF		INPBUF	RMB     8       		
0122	607F	FF		CNVBUF	RMB     4       		
0123	6083	FF		FILBUF	RMB     32      		
0124				
0125	60A3			MAIN  	EQU     *       		
0126				*=====reset pia=====
0127				*portB:output
0128	60A3	86	30	      	LDA     #$30    		
0129	60A5	B7	FD9F	      	STA     PBCTL   		select ddra, cb2:0
0130	60A8	86	FD	      	LDA     #$FD    		pb0,7:out,pb1:in
0131	60AA	B7	FD9E	      	STA     PBDAT   		set output mode
0132	60AD	86	34	      	LDA     #$34    		
0133	60AF	B7	FD9F	      	STA     PBCTL   		select peripheral,cb2:0
0134				 
0135				*for pia exist check
0136	60B2	86	55	      	LDA     #$55    		test data
0137	60B4	B7	FD9E	      	STA     PBDAT   		
0138	60B7	B6	FD9E	      	LDA     PBDAT   		
0139	60BA	84	FD	      	ANDA    #$FD    		pb1=0
0140	60BC	81	55	      	CMPA    #$55    		
0141	60BE	27	07	      	BEQ     INIT    		
0142	60C0	8E	707B	      	LDX     #MERR   		
0143	60C3	17	0D5D	      	LBSR    PSTRNG  		
0144	60C6	39		      	RTS     			Return F-BASIC
0145				
0146	60C7			INIT  	EQU     *       		
0147	60C7	17	0094	      	LBSR    SDINIT  		
0148				
0149				****************************************
0150				* MAIN MENU
0151				****************************************
0152	60CA			MENU  	EQU     *       		
0153	60CA	4F		      	CLRA    			
0154	60CB	1F	8B	      	TFR     A,DP    		
0155	60CD	8E	6F90	      	LDX     #MSMENU1		
0156	60D0	17	0D50	      	LBSR    PSTRNG  		
0157	60D3	BD	FBF7	      	JSR     CSRON   		cursor on
0158	60D6	BD	6F12	      	JSR     INOUTC  		
0159	60D9	84	DF	      	ANDA    #$DF    		to upper
0160				
0161	60DB	81	46	      	CMPA    #'F     		
0162	60DD	26	05	      	BNE     MENU1   		
0163	60DF	17	0324	      	LBSR    DSPDIR  		
0164	60E2	20	E6	      	BRA     MENU    		
0165	60E4	81	4C	MENU1 	CMPA    #'L     		
0166	60E6	26	05	      	BNE     MENU2   		
0167	60E8	17	03BF	      	LBSR    LDFILE  		
0168	60EB	20	DD	      	BRA     MENU    		
0169	60ED	81	42	MENU2 	CMPA    #'B     		
0170	60EF	26	05	      	BNE     MENU3   		
0171	60F1	17	06C5	      	LBSR    WRBFILE 		
0172	60F4	20	D4	      	BRA     MENU    		
0173	60F6	81	4D	MENU3 	CMPA    #'M     		
0174	60F8	26	05	      	BNE     MENU4   		
0175	60FA	17	0732	      	LBSR    WRMFILE 		
0176	60FD	20	CB	      	BRA     MENU    		
0177	60FF	81	4B	MENU4 	CMPA    #'K     		
0178	6101	26	05	      	BNE     MENU5   		
0179	6103	17	065E	      	LBSR    KILFILE 		
0180	6106	20	C2	      	BRA     MENU    		
0181	6108	81	53	MENU5 	CMPA    #'S     		
0182	610A	26	04	      	BNE     MENU6   		
0183	610C	8D	50	      	BSR     SDINIT  		
0184	610E	20	BA	      	BRA     MENU    		
0185	6110	81	4F	MENU6 	CMPA    #'O     		
0186	6112	26	04	      	BNE     MENU7   		
0187	6114	20	0A	      	BRA     OPMENU  		
0188	6116	20	B2	      	BRA     MENU    		
0189	6118	81	51	MENU7 	CMPA    #'Q     		
0190	611A	26	AE	      	BNE     MENU    		
0191	611C	17	0C49	      	LBSR    PCRLF   		
0192	611F	39		      	RTS     			Return F-BASIC
0193				
0194				*
0195	6120			OPMENU	EQU     *       		
0196	6120	8E	6FE9	      	LDX     #MSMENU2		
0197	6123	17	0CFD	      	LBSR    PSTRNG  		
0198	6126	BD	6F12	      	JSR     INOUTC  		
0199	6129	80	30	      	SUBA    #$30    		
0200	612B	26	02	      	BNE     OPMEN6  		0?
0201	612D	20	9B	      	BRA     MENU    		
0202				
0203	612F	4A		OPMEN6	DECA    			1?
0204	6130	26	05	      	BNE     OPMEN7  		
0205	6132	17	0246	      	LBSR    RDSCT   		
0206	6135	20	E9	      	BRA     OPMENU  		
0207	6137	4A		OPMEN7	DECA    			2?
0208	6138	26	05	      	BNE     OPMEN8  		
0209	613A	17	01C1	      	LBSR    DSPSDDAT		
0210	613D	20	E1	      	BRA     OPMENU  		
0211	613F	4A		OPMEN8	DECA    			3?
0212	6140	26	05	      	BNE     OPMEN9  		
0213	6142	17	0249	      	LBSR    DSPMBR  		
0214	6145	20	D9	      	BRA     OPMENU  		
0215	6147	4A		OPMEN9	DECA    			4?
0216	6148	26	05	      	BNE     OPMEN10 		
0217	614A	17	0295	      	LBSR    DSPBPB  		
0218	614D	20	D1	      	BRA     OPMENU  		
0219	614F	4A		OPMEN10	DECA    			5?
0220	6150	26	CE	      	BNE     OPMENU  		
0221	6152	17	029F	      	LBSR    DSPFAT  		
0222	6155	20	C9	      	BRA     OPMENU  		
0223				
0224				*
0225	6157			SDERR 	EQU     *       		
0226	6157	8E	707B	      	LDX     #MERR   		
0227	615A	17	0CC6	      	LBSR    PSTRNG  		
0228	615D	39		      	RTS     			Return F-BASIC
0229				
0230				****************************************
0231				* SD Initialize routine
0232				****************************************
0233	615E			SDINIT	EQU     *       		
0234				*---------- start ----------
0235	615E	8E	7064	      	LDX     #MSINIT 		
0236	6161	17	0CBF	      	LBSR    PSTRNG  		
0237				* cs:1,di:1,sck>74ms
0238	6164	86	FF	      	LDA     #$FF    		mosi:b7=H,miso:b1=H(for PIA),cs:b0=H
0239	6166	B7	FD9E	      	STA     PBDAT   		
0240	6169	C6	50	      	LDB     #80     		80times
0241	616B	17	0BB5	ISTT  	LBSR    SETCKL  		
0242	616E	17	0BBB	      	LBSR    SETCKH  		
0243	6171	5A		      	DECB    			
0244	6172	26	F7	      	BNE     ISTT    		
0245				*
0246				*---------- cmd 0 ----------
0247	6174			SCMD0 	EQU     *       		
0248	6174	17	0BAC	      	LBSR    SETCKL  		
0249	6177	C6	06	      	LDB     #6      		
0250	6179	8E	6F2C	      	LDX     #CMD0   		
0251	617C	A6	80	SC01  	LDA     ,X+     		
0252	617E	17	0B34	      	LBSR    SNDDAT  		
0253	6181	5A		      	DECB    			
0254	6182	26	F8	      	BNE     SC01    		
0255				*get response
0256	6184	5F		      	CLRB    			
0257	6185			GR00  				
0258	6185	5A		      	DECB    			
0259	6186	27	CF	      	BEQ     SDERR   		
0260	6188	17	0B46	      	LBSR    GETDAT  		
0261	618B	B6	6008	      	LDA     RESDAT  		
0262	618E	81	01	      	CMPA    #$01    		
0263	6190	26	F3	      	BNE     GR00    		
0264				*
0265				*---------- cmd 8 ----------
0266	6192			SCMD8 	EQU     *       		
0267	6192	17	0B8E	      	LBSR    SETCKL  		
0268	6195	86	FF	      	LDA     #$FF    		dummy cmd
0269	6197	17	0B1B	      	LBSR    SNDDAT  		
0270	619A	C6	06	      	LDB     #6      		
0271	619C	8E	6F44	      	LDX     #CMD8   		
0272	619F	A6	80	SC80  	LDA     ,X+     		
0273	61A1	17	0B11	      	LBSR    SNDDAT  		
0274	61A4	5A		      	DECB    			
0275	61A5	26	F8	      	BNE     SC80    		
0276				*get response
0277	61A7			GR80  				
0278	61A7	17	0B27	      	LBSR    GETDAT  		
0279	61AA	B6	6008	      	LDA     RESDAT  		
0280				 
0281	61AD	17	0B21	      	LBSR    GETDAT  		
0282	61B0	B6	6008	      	LDA     RESDAT  		
0283	61B3	81	01	      	CMPA    #$01    		
0284	61B5	26	F0	      	BNE     GR80    		
0285	61B7	C6	04	      	LDB     #4      		
0286	61B9	17	0B15	GR81  	LBSR    GETDAT  		
0287	61BC	B6	6008	      	LDA     RESDAT  		
0288	61BF	5A		      	DECB    			
0289	61C0	26	F7	      	BNE     GR81    		
0290				*
0291				*---------- cmd 58 ----------
0292	61C2			SCMD58	EQU     *       		
0293	61C2	17	0B5E	      	LBSR    SETCKL  		
0294	61C5	86	FF	      	LDA     #$FF    		dummy cmd
0295	61C7	17	0AEB	      	LBSR    SNDDAT  		
0296	61CA	C6	06	      	LDB     #6      		
0297	61CC	8E	6F4A	      	LDX     #CMD58  		
0298	61CF	A6	80	SC581 	LDA     ,X+     		
0299	61D1	17	0AE1	      	LBSR    SNDDAT  		
0300	61D4	5A		      	DECB    			
0301	61D5	26	F8	      	BNE     SC581   		
0302				*get response
0303	61D7			GR580 				
0304	61D7	17	0AF7	      	LBSR    GETDAT  		
0305	61DA	B6	6008	      	LDA     RESDAT  		
0306	61DD	81	01	      	CMPA    #$01    		
0307	61DF	26	F6	      	BNE     GR580   		
0308	61E1	C6	04	GR581 	LDB     #4      		
0309	61E3	17	0AEB	GR582 	LBSR    GETDAT  		
0310	61E6	B6	6008	      	LDA     RESDAT  		
0311	61E9	5A		      	DECB    			
0312	61EA	26	F7	      	BNE     GR582   		
0313	61EC			RPT41 	EQU     *       		
0314				*---------- cmd 55 ----------
0315	61EC			SCMD55	EQU     *       		
0316	61EC	17	0B34	      	LBSR    SETCKL  		
0317	61EF	86	FF	      	LDA     #$FF    		dummy cmd
0318	61F1	17	0AC1	      	LBSR    SNDDAT  		
0319	61F4	C6	06	      	LDB     #6      		
0320	61F6	8E	6F50	      	LDX     #CMD55  		
0321	61F9	A6	80	SC551 	LDA     ,X+     		
0322	61FB	17	0AB7	      	LBSR    SNDDAT  		
0323	61FE	5A		      	DECB    			
0324	61FF	26	F8	      	BNE     SC551   		
0325				*get response
0326				* CLRB
0327	6201			GR550 				
0328	6201	17	0ACD	      	LBSR    GETDAT  		
0329	6204	B6	6008	      	LDA     RESDAT  		
0330	6207	81	01	      	CMPA    #$01    		
0331	6209	26	F6	      	BNE     GR550   		
0332				 
0333				*---------- acmd 41 ----------
0334	620B			ASCMD41	EQU     *       		
0335	620B	17	0B15	      	LBSR    SETCKL  		
0336	620E	86	FF	      	LDA     #$FF    		dummy cmd
0337	6210	17	0AA2	      	LBSR    SNDDAT  		
0338	6213	C6	06	      	LDB     #6      		
0339	6215	8E	6F56	      	LDX     #ACMD41 		
0340	6218	A6	80	ASC411	LDA     ,X+     		
0341	621A	17	0A98	      	LBSR    SNDDAT  		
0342	621D	5A		      	DECB    			
0343	621E	26	F8	      	BNE     ASC411  		
0344				*get response
0345	6220			GR410 				
0346	6220	17	0AAE	      	LBSR    GETDAT  		
0347	6223	B6	6008	      	LDA     RESDAT  		
0348	6226	17	0AA8	      	LBSR    GETDAT  		
0349	6229	B6	6008	      	LDA     RESDAT  		
0350	622C	81	00	      	CMPA    #$00    		
0351	622E	26	BC	      	BNE     RPT41   		
0352				 
0353				*---------- second cmd 58 ----------
0354	6230			SCMD258	EQU     *       		
0355	6230	17	0AF0	      	LBSR    SETCKL  		
0356	6233	86	FF	      	LDA     #$FF    		dummy cmd
0357	6235	17	0A7D	      	LBSR    SNDDAT  		
0358	6238	C6	06	      	LDB     #6      		
0359	623A	8E	6F4A	      	LDX     #CMD58  		
0360	623D	A6	80	SC2581	LDA     ,X+     		
0361	623F	17	0A73	      	LBSR    SNDDAT  		
0362	6242	5A		      	DECB    			
0363	6243	26	F8	      	BNE     SC2581  		
0364				*get response
0365	6245			GR2580				
0366	6245	17	0A89	      	LBSR    GETDAT  		
0367	6248	B6	6008	      	LDA     RESDAT  		
0368	624B	81	00	      	CMPA    #$00    		
0369	624D	26	F6	      	BNE     GR2580  		
0370	624F	17	0A7F	      	LBSR    GETDAT  		
0371	6252	B6	6008	      	LDA     RESDAT  		
0372	6255	48		      	LSLA    			
0373	6256	48		      	LSLA    			
0374	6257	24	03	      	BCC     GR2581  		
0375	6259	7C	6009	      	INC     SDHC    		if sdhc then 1
0376	625C	C6	03	GR2581	LDB     #3      		
0377	625E	17	0A70	GR2582	LBSR    GETDAT  		
0378	6261	B6	6008	      	LDA     RESDAT  		
0379	6264	5A		      	DECB    			
0380	6265	26	F7	      	BNE     GR2582  		
0381				 
0382	6267	8E	704E	      	LDX     #MSSD0  		
0383	626A	B6	6009	      	LDA     SDHC    		
0384	626D	27	03	      	BEQ     SD1     		
0385	626F	8E	7058	      	LDX     #MSSD1  		
0386	6272	17	0BAE	SD1   	LBSR    PSTRNG  		
0387				*
0388				*set sct no of BPB
0389	6275	17	0134	      	LBSR    GETMBR  		
0390	6278	8E	5FCA	      	LDX     #RWBUF+446+8+4		
0391	627B	108E	600A	      	LDY     #SCTBPB 		
0392	627F	C6	04	      	LDB     #4      		
0393	6281	A6	82	ILOP1 	LDA     ,-X     		
0394	6283	A7	A0	      	STA     ,Y+     		
0395	6285	5A		      	DECB    			
0396	6286	26	F9	      	BNE     ILOP1   		
0397				 
0398				*set sct no of FAT#1
0399	6288	17	013E	      	LBSR    GETBPB  		
0400	628B	8E	600A	      	LDX     #SCTBPB 		
0401	628E	108E	600E	      	LDY     #SCTFAT 		
0402	6292	C6	04	      	LDB     #4      		
0403	6294	17	0982	      	LBSR    TRANS   		
0404	6297	8E	600E	      	LDX     #SCTFAT 		
0405	629A	108E	5E0E	      	LDY     #RWBUF+$0E		for SD & SDHC
0406	629E	17	0B51	      	LBSR    ADD42   		
0407				 
0408				*set sct no of DIR
0409	62A1	8E	600E	      	LDX     #SCTFAT 		
0410	62A4	108E	6012	      	LDY     #SCTDIR 		
0411	62A8	C6	04	      	LDB     #4      		
0412	62AA	17	096C	      	LBSR    TRANS   		
0413	62AD	8E	5E16	      	LDX     #RWBUF+$16		for SD
0414	62B0	7D	6009	      	TST     SDHC    		0:SD,1:SDHC
0415	62B3	27	03	      	BEQ     SKP1    		
0416	62B5	C6	0E	      	LDB     #$24-$16		
0417	62B7	3A		      	ABX     			for SDHC
0418	62B8	1F	12	SKP1  	TFR     X,Y     		
0419	62BA	8E	6012	      	LDX     #SCTDIR 		
0420	62BD	17	0B32	      	LBSR    ADD42   		
0421	62C0	17	0B2F	      	LBSR    ADD42   		skip for FAT#2
0422				 
0423				*save no of directory
0424	62C3	8E	6012	      	LDX     #SCTDIR 		
0425	62C6	108E	6016	      	LDY     #SCTDSV 		
0426	62CA	C6	04	      	LDB     #4      		
0427	62CC	17	094A	      	LBSR    TRANS   		
0428				
0429				*set sct per cluster
0430	62CF	8E	5E0D	      	LDX     #RWBUF+$0D		
0431	62D2	A6	84	      	LDA     ,X      		
0432	62D4	B7	601E	      	STA     SCTPCL  		
0433				 
0434				*set sct no of CLUSTER#2
0435	62D7	8E	6012	      	LDX     #SCTDIR 		
0436	62DA	108E	601A	      	LDY     #SCTCLT 		
0437	62DE	C6	04	      	LDB     #4      		
0438	62E0	17	0936	      	LBSR    TRANS   		
0439				 
0440	62E3	108E	606F	      	LDY     #WK1+2  		
0441	62E7	86	00	      	LDA     #$00    		
0442	62E9	A7	A2	      	STA     ,-Y     		
0443	62EB	86	20	      	LDA     #$20    		for SD
0444	62ED	7D	6009	      	TST     SDHC    		
0445	62F0	27	03	      	BEQ     SKP2    		
0446	62F2	B6	601E	      	LDA     SCTPCL  		for SDHC
0447	62F5	A7	A2	SKP2  	STA     ,-Y     		
0448	62F7	8E	601A	      	LDX     #SCTCLT 		
0449	62FA	17	0AF5	      	LBSR    ADD42   		
0450	62FD	39		      	RTS     			
0451				
0452				****************************************
0453				* GET SD DATA ROUTINE
0454				* use CMD9
0455				****************************************
0456	62FE			DSPSDDAT	EQU     *       		
0457	62FE	17	0A67	      	LBSR    PCRLF   		
0458	6301	17	0A1F	      	LBSR    SETCKL  		
0459	6304	C6	06	      	LDB     #6      		
0460	6306	8E	6F5C	      	LDX     #CMD9   		
0461	6309	A6	80	SC91  	LDA     ,X+     		
0462	630B	17	09A7	      	LBSR    SNDDAT  		
0463	630E	5A		      	DECB    			
0464	630F	26	F8	      	BNE     SC91    		
0465				*get response
0466	6311			GR90  				
0467	6311	17	09BD	      	LBSR    GETDAT  		
0468	6314	B6	6008	      	LDA     RESDAT  		
0469	6317	81	00	      	CMPA    #$00    		
0470	6319	26	F6	      	BNE     GR90    		
0471				 
0472	631B	C6	14	      	LDB     #16+1+2+1		fe,crcH,crcL,ff
0473	631D	17	09B1	GR91  	LBSR    GETDAT  		
0474	6320	B6	6008	      	LDA     RESDAT  		
0475	6323	5A		      	DECB    			
0476	6324	26	F7	      	BNE     GR91    		
0477	6326	17	0A3F	      	LBSR    PCRLF   		
0478				
0479				*disp offset of MBR,FAT#1,DIR,CLUSTER#2
0480	6329	8E	709B	      	LDX     #MSOFS  		
0481	632C	17	0AF4	      	LBSR    PSTRNG  		
0482	632F	8E	70AB	      	LDX     #MSBPB  		
0483	6332	17	0AEE	      	LBSR    PSTRNG  		
0484	6335	8E	600A	      	LDX     #SCTBPB 		
0485	6338	17	0A24	      	LBSR    DSPBI2  		
0486	633B	17	0A35	      	LBSR    OUTSPC  		
0487	633E	17	0A1E	      	LBSR    DSPBI2  		
0488				
0489	6341	8E	70B4	      	LDX     #MSFAT  		
0490	6344	17	0ADC	      	LBSR    PSTRNG  		
0491	6347	8E	600E	      	LDX     #SCTFAT 		
0492	634A	17	0A12	      	LBSR    DSPBI2  		
0493	634D	17	0A23	      	LBSR    OUTSPC  		
0494	6350	17	0A0C	      	LBSR    DSPBI2  		
0495				
0496	6353	8E	70BD	      	LDX     #MSDIR  		
0497	6356	17	0ACA	      	LBSR    PSTRNG  		
0498	6359	8E	6012	      	LDX     #SCTDIR 		
0499	635C	17	0A00	      	LBSR    DSPBI2  		
0500	635F	17	0A11	      	LBSR    OUTSPC  		
0501	6362	17	09FA	      	LBSR    DSPBI2  		
0502				
0503	6365	8E	70C6	      	LDX     #MSCL2  		
0504	6368	17	0AB8	      	LBSR    PSTRNG  		
0505	636B	8E	601A	      	LDX     #SCTCLT 		
0506	636E	17	09EE	      	LBSR    DSPBI2  		
0507	6371	17	09FF	      	LBSR    OUTSPC  		
0508	6374	17	09E8	      	LBSR    DSPBI2  		
0509	6377	17	09EE	      	LBSR    PCRLF   		
0510	637A	39		      	RTS     			
0511				
0512				*
0513				****************************************
0514				* READ ROUTINE
0515				* use CMD17
0516				* set sctno to SCTN2,SCTN3
0517				* read data set to RWBUF
0518				****************************************
0519	637B			RDSCT 	EQU     *       		
0520	637B	17	09EA	      	LBSR    PCRLF   		
0521	637E	17	096A	      	LBSR    INSCT   		input sct no
0522	6381	17	08DD	      	LBSR    RD1SCT  		read 1 sct
0523				
0524				*disp data
0525	6384	17	09E1	      	LBSR    PCRLF   		
0526	6387	17	090D	      	LBSR    DSPBUF  		
0527	638A	17	09DB	      	LBSR    PCRLF   		
0528	638D	39		      	RTS     			
0529				
0530				****************************************
0531				* Read MBR & Disp parameter of BPB
0532				****************************************
0533	638E			DSPMBR	EQU     *       		
0534	638E	17	09D7	      	LBSR    PCRLF   		
0535	6391	8D	19	      	BSR     GETMBR  		
0536				
0537				*disp BPB
0538	6393	17	09D2	      	LBSR    PCRLF   		
0539	6396	8E	5FBE	      	LDX     #RWBUF+446		1st BPB point
0540	6399	C6	10	GET1  	LDB     #16     		
0541	639B	A6	80	GET2  	LDA     ,X+     		
0542	639D	17	0995	      	LBSR    DSPBIN  		disp data
0543	63A0	5A		      	DECB    			
0544	63A1	26	F8	      	BNE     GET2    		
0545	63A3	17	09C2	      	LBSR    PCRLF   		
0546	63A6	8C	5FFE	      	CMPX    #RWBUF+510		446+16*4
0547	63A9	25	EE	      	BLO     GET1    		
0548	63AB	39		      	RTS     			
0549				
0550				*----------------------------------------
0551				*read MBR
0552	63AC			GETMBR	EQU     *       		
0553	63AC	8E	6004	      	LDX     #SCTN0  		
0554	63AF	C6	04	      	LDB     #4      		
0555	63B1	4F		      	CLRA    			
0556	63B2	17	086F	      	LBSR    FILL    		set sct no is 0
0557	63B5	17	093C	      	LBSR    SETSCT  		
0558	63B8	17	08A6	      	LBSR    RD1SCT  		read 1 sct
0559	63BB	39		      	RTS     			
0560				
0561				*----------------------------------------
0562				*set sector no to SCTN0
0563				*from X,X+1,X+2,X+3 to SCTN0-SCTN3
0564	63BC			SETSNO	EQU     *       		
0565	63BC	108E	6004	      	LDY     #SCTN0  		
0566	63C0	C6	04	      	LDB     #4      		
0567	63C2	17	0854	      	LBSR    TRANS   		
0568	63C5	17	092C	      	LBSR    SETSCT  		
0569	63C8	39		      	RTS     			
0570				
0571				*----------------------------------------
0572				*read BPB
0573	63C9			GETBPB	EQU     *       		
0574	63C9	8D	E1	      	BSR     GETMBR  		
0575				*set sct no of BPB
0576	63CB	8E	5FCA	      	LDX     #RWBUF+446+8+4		
0577	63CE	108E	6004	      	LDY     #SCTN0  		
0578	63D2	C6	04	      	LDB     #4      		
0579	63D4	A6	82	GTBLOP	LDA     ,-X     		
0580	63D6	A7	A0	      	STA     ,Y+     		
0581	63D8	5A		      	DECB    			
0582	63D9	26	F9	      	BNE     GTBLOP  		
0583	63DB	17	0916	      	LBSR    SETSCT  		
0584	63DE	17	0880	      	LBSR    RD1SCT  		read 1 sct
0585	63E1	39		      	RTS     			
0586				
0587				****************************************
0588				* Disp BPB(Bios Parameter Block)
0589				****************************************
0590	63E2			DSPBPB	EQU     *       		
0591	63E2	8E	600A	      	LDX     #SCTBPB 		
0592	63E5	8D	D5	      	BSR     SETSNO  		
0593	63E7	17	0877	      	LBSR    RD1SCT  		read 1 sct
0594				 
0595				*disp BPB
0596	63EA	17	097B	      	LBSR    PCRLF   		
0597	63ED	17	08A7	      	LBSR    DSPBUF  		
0598	63F0	17	0975	      	LBSR    PCRLF   		
0599	63F3	39		      	RTS     			
0600				
0601				****************************************
0602				* Disp FAT#1
0603				****************************************
0604	63F4			DSPFAT	EQU     *       		
0605	63F4	8E	600E	      	LDX     #SCTFAT 		
0606	63F7	8D	C3	      	BSR     SETSNO  		
0607	63F9	17	0865	      	LBSR    RD1SCT  		read 1 sct
0608				 
0609				*disp FAT
0610	63FC	17	0969	      	LBSR    PCRLF   		
0611	63FF	17	0895	      	LBSR    DSPBUF  		
0612	6402	17	0963	      	LBSR    PCRLF   		
0613	6405	39		      	RTS     			
0614				
0615				****************************************
0616				* Disp Directory
0617				****************************************
0618	6406			DSPDIR	EQU     *       		
0619				*return no of DIR
0620	6406	8E	6016	      	LDX     #SCTDSV 		
0621	6409	108E	6012	      	LDY     #SCTDIR 		
0622	640D	C6	04	      	LDB     #4      		
0623	640F	17	0807	      	LBSR    TRANS   		
0624	6412	8E	6012	DSPFL0	LDX     #SCTDIR 		
0625	6415	8D	A5	      	BSR     SETSNO  		
0626	6417	17	0847	      	LBSR    RD1SCT  		read 1 sct
0627				 
0628				*disp FILE name
0629	641A	17	094B	      	LBSR    PCRLF   		
0630	641D	17	0948	      	LBSR    PCRLF   		
0631	6420	8E	5E00	      	LDX     #RWBUF  		
0632				
0633	6423	A6	84	DSPFL1	LDA     ,X      		
0634	6425	1027	0080	      	LBEQ    DSPEND  		if top of filename is 0 then end
0635	6429	81	E5	      	CMPA    #$E5    		delete mark?
0636	642B	27	06	      	BEQ     DSPCKE  		
0637	642D	A6	0B	      	LDA     11,X    		attr
0638				* CMPA #$0F long file name?
0639				* BEQ DSPCKE
0640				* CMPA #$10 directory?
0641				* BEQ DSPCKE
0642	642F	81	20	      	CMPA    #$20    		
0643	6431	27	0A	      	BEQ     DSPFL2  		archive file only
0644	6433	30	88 20	DSPCKE	LEAX    32,X    		next directory entry
0645	6436	8C	6000	      	CMPX    #RWBUF+512		over buf?
0646	6439	24	56	      	BHS     DSPFL5  		
0647	643B	20	E6	      	BRA     DSPFL1  		
0648				 
0649	643D			DSPFL2				
0650				*disp filename
0651	643D	C6	08	      	LDB     #8      		
0652	643F	A6	80	DSPFL3	LDA     ,X+     		
0653	6441	BD	FBBB	      	JSR     OUTCHA  		
0654	6444	5A		      	DECB    			
0655	6445	26	F8	      	BNE     DSPFL3  		
0656				*disp ext
0657	6447	86	2E	      	LDA     #'.     		
0658	6449	BD	FBBB	      	JSR     OUTCHA  		
0659	644C	C6	03	      	LDB     #3      		
0660	644E	A6	80	DSPFL4	LDA     ,X+     		
0661	6450	BD	FBBB	      	JSR     OUTCHA  		
0662	6453	5A		      	DECB    			
0663	6454	26	F8	      	BNE     DSPFL4  		
0664				
0665				*get FILE time data
0666	6456	30	07	      	LEAX    7,X     		
0667	6458	EC	81	      	LDD     ,X++    		
0668	645A	FD	606D	      	STD     WK1     		
0669				
0670				*get CLUSTER(H) data
0671	645D	EC	81	      	LDD     ,X++    		
0672	645F	1E	89	      	EXG     A,B     		
0673	6461	FD	6048	      	STD     CLSTH   		
0674	6464	30	04	      	LEAX    4,X     		
0675	6466	EC	81	      	LDD     ,X++    		
0676	6468	1E	89	      	EXG     A,B     		
0677	646A	FD	604A	      	STD     CLSTL   		
0678				 
0679				*get FILE size data
0680	646D	108E	6046	      	LDY     #WFSIZ+4		
0681	6471	C6	04	      	LDB     #4      		
0682	6473	A6	80	DSPC1 	LDA     ,X+     		
0683	6475	A7	A2	      	STA     ,-Y     		
0684	6477	5A		      	DECB    			
0685	6478	26	F9	      	BNE     DSPC1   		
0686				
0687				*disp FILE size
0688	647A	BD	6D73	      	JSR     OUTSPC  		
0689	647D	17	0A12	      	LBSR    DSPSIZ  		disp FILE size
0690				
0691				*disp FILE time
0692	6480	FC	606D	      	LDD     WK1     		
0693	6483	17	09AD	      	LBSR    DSPYMD  		disp MM-DD-YY
0694				
0695				*disp CLUSTER(Lonly)
0696	6486	17	0A5A	      	LBSR    DSPCLS  		
0697	6489	17	08DC	      	LBSR    PCRLF   		
0698				 
0699	648C	8C	6000	      	CMPX    #RWBUF+512		
0700	648F	25	92	      	BLO     DSPFL1  		
0701	6491	8E	6012	DSPFL5	LDX     #SCTDIR 		
0702	6494	17	0796	      	LBSR    INCX4   		sct no +1
0703	6497	8E	713F	      	LDX     #MSNXTP 		
0704	649A	17	0986	      	LBSR    PSTRNG  		
0705	649D	BD	FBB8	DSPFL6	JSR     INCHA   		
0706	64A0	81	20	      	CMPA    #SPC    		
0707	64A2	1027	FF6C	      	LBEQ    DSPFL0  		
0708	64A6	BD	6D68	      	JSR     PCRLF   		
0709	64A9	39		DSPEND	RTS     			
0710				
0711				****************************************
0712				* Load FILE
0713				****************************************
0714	64AA			LDFILE	EQU     *       		
0715	64AA	17	0241	      	LBSR    GETFDT  		
0716	64AD	BE	6065	      	LDX     EXSTFL  		if 0 not exist
0717	64B0	1027	0125	      	LBEQ    LDNEND  		
0718				 
0719				*get cluster no
0720	64B4	EC	88 14	      	LDD     $14,X   		
0721	64B7	1E	89	      	EXG     A,B     		
0722	64B9	FD	6048	      	STD     CLSTH   		high cluster no
0723	64BC	EC	88 1A	      	LDD     $1A,X   		
0724	64BF	1E	89	      	EXG     A,B     		
0725	64C1	FD	604A	      	STD     CLSTL   		low cluster no
0726				*sub start cluster no (SD:2,SDHC:3)
0727	64C4	83	0002	      	SUBD    #2      		
0728	64C7	7D	6009	      	TST     SDHC    		SD:0,SDHC:1
0729	64CA	27	03	      	BEQ     LD3     		
0730	64CC	83	0001	      	SUBD    #1      		D:cluster no (start 0)
0731				*       (A=0,cluster no is only B)
0732				
0733	64CF	34	36	LD3   	PSHS    A,B,X,Y 		
0734	64D1	8E	601A	      	LDX     #SCTCLT 		top of cluster no
0735	64D4	108E	606D	      	LDY     #WK1    		
0736	64D8	C6	04	      	LDB     #4      		
0737	64DA	17	073C	      	LBSR    TRANS   		
0738	64DD	35	36	      	PULS    A,B,X,Y 		
0739				 
0740				*calc start cluster no of file
0741				*(B)x40h
0742	64DF	34	30	      	PSHS    X,Y     		
0743	64E1	8E	606D	      	LDX     #WK1    		
0744	64E4	17	0755	      	LBSR    ADD40H  		
0745	64E7	35	30	      	PULS    X,Y     		
0746				
0747				*get file size
0748	64E9	34	30	      	PSHS    X,Y     		
0749	64EB	30	88 20	      	LEAX    32,X    		
0750	64EE	108E	6042	      	LDY     #WFSIZ  		
0751	64F2	C6	04	      	LDB     #4      		
0752	64F4	A6	82	LD41  	LDA     ,-X     		
0753	64F6	A7	A0	      	STA     ,Y+     		
0754	64F8	5A		      	DECB    			
0755	64F9	26	F9	      	BNE     LD41    		
0756	64FB	35	30	      	PULS    X,Y     		
0757				 
0758	64FD	EC	88 1D	      	LDD     $1D,X   		upper of file size
0759	6500	1E	89	      	EXG     A,B     		
0760	6502	44		      	LSRA    			
0761	6503	56		      	RORB    			
0762	6504	C3	0001	      	ADDD    #1      		wfsiz/$200+1
0763				 
0764				*limited to 1 cluster(40h sct)
0765	6507	C1	40	      	CMPB    #$40    		40h sct?
0766	6509	23	02	      	BLS     LD5     		
0767	650B	C6	40	      	LDB     #$40    		
0768	650D	F7	604C	LD5   	STB     CNT     		sct counter
0769	6510	F7	604E	      	STB     TPGFLG  		set top page
0770				 
0771				*set start sct no of file
0772	6513	34	12	      	PSHS    A,X     		
0773	6515	8E	70FE	      	LDX     #MSLDNG 		
0774	6518	17	0908	      	LBSR    PSTRNG  		
0775	651B	35	12	      	PULS    A,X     		
0776	651D			LDLOP 				
0777	651D	86	2E	      	LDA     #'.     		
0778	651F	BD	FBBB	      	JSR     OUTCHA  		
0779	6522	8E	606D	      	LDX     #WK1    		
0780	6525	108E	6004	      	LDY     #SCTN0  		
0781	6529	C6	04	      	LDB     #4      		
0782	652B	17	06EB	      	LBSR    TRANS   		
0783	652E	17	07C3	      	LBSR    SETSCT  		
0784	6531	17	072D	      	LBSR    RD1SCT  		read 1 file data
0785				 
0786	6534	7D	604E	      	TST     TPGFLG  		top sector page?
0787	6537	27	71	      	BEQ     LD9     		
0788				 
0789				*at top sector, ini set
0790				*offset 00 data is
0791				*  $00    :machine code
0792				*  $0D    :BASIC PROGRAM (ascii save)
0793				*  $FF,$FE:BASIC PROGRAM (binary save)
0794				*  else   :general text
0795	6539	10BE	6044	      	LDY     WFSIZ+2 		
0796	653D	10BF	6046	      	STY     FILSIZ  		set file size
0797				 
0798	6541	8E	5E00	      	LDX     #RWBUF  		
0799	6544	A6	84	      	LDA     ,X      		
0800	6546	B7	604D	      	STA     MCFLG   		
0801	6549	27	04	      	BEQ     LD8     		machine code
0802	654B	2A	4B	      	BPL     LD81    		ascii saved basic or else
0803	654D	2B	45	      	BMI     LD80    		binary saved basic
0804				*at machine code, read header
0805	654F	10AE	01	LD8   	LDY     1,X     		get file size
0806	6552	10BF	6046	      	STY     FILSIZ  		
0807	6556	EE	03	      	LDU     3,X     		get store addr
0808				*disp store adr, size
0809	6558	8E	71A5	      	LDX     #MSMCAS 		
0810	655B	17	08C5	      	LBSR    PSTRNG  		
0811	655E	1F	30	      	TFR     U,D     		
0812	6560	34	04	      	PSHS    B       		
0813	6562	17	07D6	      	LBSR    DSPBI0  		
0814	6565	35	04	      	PULS    B       		
0815	6567	1F	98	      	TFR     B,A     		
0816	6569	17	07CF	      	LBSR    DSPBI0  		
0817	656C	86	2C	      	LDA     #',     		
0818	656E	BD	FBBB	      	JSR     OUTCHA  		
0819	6571	1F	20	      	TFR     Y,D     		
0820	6573	34	04	      	PSHS    B       		
0821	6575	17	07C3	      	LBSR    DSPBI0  		
0822	6578	35	04	      	PULS    B       		
0823	657A	1F	98	      	TFR     B,A     		
0824	657C	BD	6D3B	      	JSR     DSPBI0  		
0825				
0826				*offset?
0827	657F	8E	718C	      	LDX     #MSMCOF 		
0828	6582	17	089E	      	LBSR    PSTRNG  		
0829	6585	BD	6F12	      	JSR     INOUTC  		
0830	6588	84	DF	      	ANDA    #$DF    		
0831	658A	81	59	      	CMPA    #'Y     		
0832	658C	26	1C	      	BNE     LD9     		
0833	658E	33C9	E000	      	LEAU    -$2000,U		-$2000 offset
0834	6592	20	16	      	BRA     LD9     		
0835				 
0836	6594	DE	33	LD80  	LDU     BASADP  		basic file
0837	6596	20	12	      	BRA     LD9     		
0838				 
0839	6598			LD81  				
0840	6598	81	0D	      	CMPA    #$0D    		ascii saved BASIC?
0841	659A	27	05	      	BEQ     LD82    		
0842	659C	CE	2000	      	LDU     #TXTADR 		(else) not basic file
0843	659F	20	09	      	BRA     LD9     		
0844				 
0845	65A1			LD82  				
0846	65A1	DE	33	      	LDU     BASADP  		
0847	65A3	FF	606B	      	STU     SVTOP   		set save adr
0848	65A6	8D	69	      	BSR     MEMSET2 		for ascii saved BASIC
0849	65A8	20	02	      	BRA     LD10    		
0850				 
0851	65AA			LD9   				
0852	65AA	8D	35	      	BSR     MEMSET  		expand memory from rwbuf
0853				 
0854	65AC			LD10  				
0855	65AC	7F	604E	      	CLR     TPGFLG  		end of top page
0856	65AF	8E	606D	      	LDX     #WK1    		
0857	65B2	17	0678	      	LBSR    INCX4   		sct no +1
0858	65B5	7A	604C	      	DEC     CNT     		
0859	65B8	1026	FF61	      	LBNE    LDLOP   		
0860				 
0861	65BC			LDEND 				
0862	65BC	7D	604D	      	TST     MCFLG   		
0863	65BF	27	0E	      	BEQ     LDE0    		
0864	65C1	2A	0C	      	BPL     LDE0    		
0865				*fix link pointer
0866	65C3	9E	33	      	LDX     BASADP  		
0867	65C5	BD	C730	      	JSR     FIXPTR  		
0868				 
0869	65C8	FC	6044	      	LDD     WFSIZ+2 		
0870	65CB	D3	33	      	ADDD    BASADP  		
0871	65CD	DD	35	      	STD     BASAEP  		end adrs
0872	65CF	8E	7116	LDE0  	LDX     #MSLDED 		
0873	65D2	17	084E	      	LBSR    PSTRNG  		
0874	65D5	17	0790	LDE1  	LBSR    PCRLF   		
0875	65D8	39		      	RTS     			
0876				 
0877	65D9	8E	7131	LDNEND	LDX     #MSNOFL 		
0878	65DC	17	0844	      	LBSR    PSTRNG  		
0879	65DF	20	F4	      	BRA     LDE1    		
0880				
0881				*expand in memory from rwbuf
0882				*X:rwbuf, U:memory adr, Y:filesize
0883	65E1			MEMSET	EQU     *       		
0884	65E1	34	30	      	PSHS    X,Y     		
0885	65E3	8E	5E00	      	LDX     #RWBUF  		
0886	65E6	10BE	6046	      	LDY     FILSIZ  		
0887	65EA	7D	604E	      	TST     TPGFLG  		top page?
0888	65ED	27	0F	      	BEQ     MSLOP   		
0889	65EF	7D	604D	      	TST     MCFLG   		0,$FF($FE),etc
0890	65F2	27	04	      	BEQ     MS0     		
0891	65F4	2A	08	      	BPL     MSLOP   		etc
0892	65F6	2B	04	      	BMI     MS1     		basic file
0893				* machine code
0894	65F8	30	05	MS0   	LEAX    5,X     		skip header
0895	65FA	20	02	      	BRA     MSLOP   		
0896	65FC	30	03	MS1   	LEAX    3,X     		skip 3 FFs
0897				
0898	65FE	A6	80	MSLOP 	LDA     ,X+     		
0899	6600	A7	C0	      	STA     ,U+     		
0900	6602	31	3F	      	LEAY    -1,Y    		
0901	6604	27	05	      	BEQ     MS3     		
0902	6606	8C	6000	      	CMPX    #RWBUF+512		
0903	6609	25	F3	      	BLO     MSLOP   		
0904	660B	10BF	6046	MS3   	STY     FILSIZ  		
0905	660F	35	B0	      	PULS    X,Y,PC  		
0906				*
0907				*----------
0908				*after conversion, expand in memory from rwbuf
0909				*X:rwbuf, U:memory adr, Y:filesize
0910	6611			MEMSET2	EQU     *       		
0911	6611	34	30	      	PSHS    X,Y     		
0912	6613	A6	80	      	LDA     ,X+     		
0913	6615	81	0D	      	CMPA    #$0D    		skip top CR
0914	6617	26	0D	      	BNE     MEM2ED  		
0915	6619	A6	84	      	LDA     ,X      		
0916	661B	81	0A	      	CMPA    #$0A    		skip top LF
0917	661D	26	02	      	BNE     MM21    		
0918	661F	30	01	      	LEAX    1,X     		
0919	6621			MM21  				
0920	6621	BF	6069	      	STX     RDTOP   		start rwbuf+2
0921	6624	8D	0B	      	BSR     CNVINT  		
0922	6626			MEM2ED				
0923	6626	BE	606B	      	LDX     SVTOP   		
0924	6629	6F	80	      	CLR     ,X+     		
0925	662B	6F	80	      	CLR     ,X+     		
0926	662D	9F	35	      	STX     BASAEP  		
0927	662F	35	B0	      	PULS    X,Y,PC  		
0928				
0929				*
0930	6631			CNVINT	EQU     *       		
0931				*trans to LINBUF with change CR,LF to 00
0932				*X:rdtop
0933	6631			CNVLOP				
0934	6631	BE	6069	      	LDX     RDTOP   		
0935	6634	108E	043D	      	LDY     #LINBUF 		
0936				 
0937	6638			INLOP 				
0938	6638	A6	80	      	LDA     ,X+     		
0939	663A	A7	A0	      	STA     ,Y+     		
0940				*----------------------------
0941	663C	8C	6000	      	CMPX    #RWBUF+512		
0942	663F	25	2A	      	BLO     INL11   		
0943				 
0944	6641	7A	604C	      	DEC     CNT     		
0945	6644	26	01	      	BNE     INL10   		
0946	6646	39		      	RTS     			
0947				 
0948	6647			INL10 				
0949	6647	34	70	      	PSHS    X,Y,U   		
0950	6649	86	2E	      	LDA     #'.     		
0951	664B	BD	FBBB	      	JSR     OUTCHA  		
0952				 
0953	664E	8E	606D	      	LDX     #WK1    		
0954	6651	17	05D9	      	LBSR    INCX4   		sct no +1
0955	6654	108E	6004	      	LDY     #SCTN0  		
0956	6658	C6	04	      	LDB     #4      		
0957	665A	17	05BC	      	LBSR    TRANS   		
0958	665D	17	0694	      	LBSR    SETSCT  		
0959	6660	17	05FE	      	LBSR    RD1SCT  		read 1 file data
0960	6663	35	70	      	PULS    X,Y,U   		
0961				 
0962	6665	8E	5E00	      	LDX     #RWBUF  		
0963	6668	BF	6069	      	STX     RDTOP   		
0964				*----------------------------
0965	666B	81	0D	INL11 	CMPA    #$0D    		
0966	666D	26	C9	      	BNE     INLOP   		
0967	666F	A6	80	      	LDA     ,X+     		
0968	6671	81	0A	      	CMPA    #$0A    		
0969	6673	27	02	      	BEQ     INL2    		
0970	6675	30	1F	      	LEAX    -1,X    		
0971	6677	BF	6069	INL2  	STX     RDTOP   		next read point
0972	667A	6F	3F	      	CLR     -1,Y    		set terminate 00
0973	667C	6F	A4	      	CLR     ,Y      		
0974	667E	6F	21	      	CLR     1,Y     		
0975				
0976				*convert
0977	6680	DE	D9	      	LDU     $D9     		
0978	6682	34	40	      	PSHS    U       		
0979	6684	8E	043D	      	LDX     #LINBUF 		
0980	6687	9F	D9	      	STX     $D9     		
0981	6689	A6	84	      	LDA     ,X      		
0982	668B	1A	01	      	ORCC    #$01    		
0983	668D	BD	9162	      	JSR     RDLINO  		read line number
0984	6690	9E	4B	      	LDX     $4B     		
0985	6692	BF	033A	      	STX     $33A    		
0986	6695	0F	BF	      	CLR     $BF     		assume keyin
0987	6697	BD	FBF1	      	JSR     LININT  		(=C28C) one line translation
0988	669A	35	40	      	PULS    U       		
0989	669C	DF	D9	      	STU     $D9     		
0990				 
0991	669E	FD	6067	      	STD     CVTLEN  		store len+1
0992	66A1	10BE	6067	      	LDY     CVTLEN  		
0993				 
0994				*trans from TXTBUF to BASIC PROGRAM
0995	66A5	FE	606B	      	LDU     SVTOP   		
0996	66A8	33	42	      	LEAU    2,U     		
0997	66AA	BE	033A	      	LDX     $33A    		
0998	66AD	AF	C1	      	STX     ,U++    		
0999	66AF	8E	033C	      	LDX     #TXTBUF 		
1000				 
1001				*save to bas buf
1002	66B2	A6	80	INL12 	LDA     ,X+     		
1003	66B4	A7	C0	      	STA     ,U+     		
1004	66B6	31	3F	      	LEAY    -1,Y    		
1005	66B8	26	F8	      	BNE     INL12   		
1006				 
1007	66BA	BE	606B	      	LDX     SVTOP   		
1008	66BD	1F	10	      	TFR     X,D     		
1009	66BF	F3	6067	      	ADDD    CVTLEN  		
1010	66C2	ED	84	      	STD     ,X      		store next pointer
1011	66C4	FD	606B	      	STD     SVTOP   		save next point
1012				 
1013	66C7	BE	6069	      	LDX     RDTOP   		
1014	66CA	A6	84	      	LDA     ,X      		
1015	66CC	1026	FF61	      	LBNE    CNVLOP  		
1016	66D0	39		CEND  	RTS     			
1017				
1018				*----------
1019				*X:top of FILE NAME
1020				*return C=1:match,C=0:not match
1021	66D1			CMPFN 	EQU     *       		
1022	66D1	34	10	      	PSHS    X       		
1023	66D3	108E	604F	      	LDY     #FNAME  		
1024	66D7	C6	08	      	LDB     #8      		
1025	66D9	A6	80	CMPLOP	LDA     ,X+     		
1026	66DB	81	E5	      	CMPA    #$E5    		delete mark?
1027	66DD	27	0B	      	BEQ     NOTM    		
1028	66DF	A1	A0	      	CMPA    ,Y+     		
1029	66E1	26	07	      	BNE     NOTM    		
1030	66E3	5A		      	DECB    			
1031	66E4	26	F3	      	BNE     CMPLOP  		
1032	66E6	1A	01	MATCH 	ORCC    #$01    		C=1
1033	66E8	20	02	      	BRA     CMPEND  		
1034	66EA	1C	FE	NOTM  	ANDCC   #$FE    		C=0
1035	66EC	35	90	CMPEND	PULS    X,PC    		
1036				
1037				*------------------------------
1038				*input filename
1039				*output:
1040				* if exist EXSTFL(directory entry)
1041				*    not exist EXSTFL(=0)
1042	66EE			GETFDT	EQU     *       		
1043	66EE	34	02	      	PSHS    A       		
1044	66F0	8E	0000	      	LDX     #0      		
1045	66F3	BF	6065	      	STX     EXSTFL  		
1046				*return no of DIR
1047	66F6	8E	6016	      	LDX     #SCTDSV 		
1048	66F9	108E	6012	      	LDY     #SCTDIR 		
1049	66FD	C6	04	      	LDB     #4      		
1050	66FF	17	0517	      	LBSR    TRANS   		
1051				 
1052	6702	35	02	      	PULS    A       		
1053	6704	81	4D	      	CMPA    #'M     		
1054	6706	26	05	      	BNE     GTF1    		
1055	6708	8E	70E6	      	LDX     #MSMSV  		
1056	670B	20	03	      	BRA     GTF2    		
1057	670D	8E	70D6	GTF1  	LDX     #MSINFN 		
1058	6710	17	0710	GTF2  	LBSR    PSTRNG  		
1059	6713	17	0166	      	LBSR    INPFLDAT		input file name
1060				 
1061				*set filename
1062	6716	8E	6083	      	LDX     #FILBUF 		
1063	6719	17	00E9	      	LBSR    SETFNM  		
1064				 
1065	671C	8E	6012	LDFL0 	LDX     #SCTDIR 		
1066	671F	17	FC9A	      	LBSR    SETSNO  		
1067	6722	17	053C	      	LBSR    RD1SCT  		read 1 sct
1068				 
1069	6725	8E	5E00	      	LDX     #RWBUF  		
1070	6728	A6	84	LDFL1 	LDA     ,X      		
1071	672A	27	37	      	BEQ     LDFLE   		if top of filename is 0 then end
1072	672C	81	E5	      	CMPA    #$E5    		delete mark?
1073	672E	26	10	      	BNE     LD1     		
1074	6730	A6	0B	      	LDA     11,X    		attr
1075	6732	81	20	      	CMPA    #$20    		archive file only
1076	6734	27	0A	      	BEQ     LD1     		
1077	6736	30	88 20	      	LEAX    32,X    		next directory entry
1078	6739	8C	6000	      	CMPX    #RWBUF+512		over buf?
1079	673C	24	0E	      	BHS     LDFL5   		
1080	673E	20	E8	      	BRA     LDFL1   		
1081				
1082				*check file name
1083	6740			LD1   				
1084	6740	8D	8F	      	BSR     CMPFN   		C=1:match
1085	6742	25	10	      	BCS     LD2     		
1086	6744	30	88 20	      	LEAX    32,X    		
1087	6747	8C	6000	      	CMPX    #RWBUF+512		
1088	674A	25	DC	      	BLO     LDFL1   		
1089				 
1090	674C			LDFL5 				
1091	674C	8E	6012	      	LDX     #SCTDIR 		
1092	674F	17	04DB	      	LBSR    INCX4   		sct no +1
1093	6752	20	C8	      	BRA     LDFL0   		
1094				 
1095				*hit file, get dirctory entry
1096	6754	BF	6065	LD2   	STX     EXSTFL  		adr of dir entry
1097	6757	108E	601F	      	LDY     #DIRENT 		
1098	675B	C6	20	      	LDB     #32     		
1099	675D	17	04B9	      	LBSR    TRANS   		
1100	6760	8E	601F	      	LDX     #DIRENT 		
1101	6763	39		LDFLE 	RTS     			
1102				
1103				*
1104				****************************************
1105				* KILL FILE
1106				****************************************
1107	6764			KILFILE	EQU     *       		
1108	6764	8D	88	      	BSR     GETFDT  		
1109	6766	BE	6065	      	LDX     EXSTFL  		if 0 not exist
1110	6769	27	5B	      	BEQ     NOFEND  		
1111				 
1112	676B	8E	715C	      	LDX     #MSKILL 		
1113	676E	17	06B2	      	LBSR    PSTRNG  		
1114	6771	BD	6F12	      	JSR     INOUTC  		
1115	6774	84	DF	      	ANDA    #$DF    		
1116	6776	81	59	      	CMPA    #'Y     		
1117	6778	26	3E	      	BNE     KILEND  		
1118	677A	8D	01	      	BSR     KILSUB  		
1119	677C	39		      	RTS     			
1120				
1121				*----------
1122	677D			KILSUB	EQU     *       		
1123				*write dir
1124	677D	BE	6065	      	LDX     EXSTFL  		top adr of dir entry
1125	6780	EC	88 1A	      	LDD     $1A,X   		get clstlD 
1126	6783	1E	89	      	EXG     A,B     		B:cluster
1127	6785	FD	604A	      	STD     CLSTL   		
1128	6788	86	E5	      	LDA     #$E5    		delete mark
1129	678A	A7	84	      	STA     ,X      		
1130	678C	17	03C4	      	LBSR    WRTSD1  		
1131				 
1132				*get fat sct & write
1133	678F	8E	600E	      	LDX     #SCTFAT 		
1134	6792	17	FC27	      	LBSR    SETSNO  		
1135	6795	17	04C9	      	LBSR    RD1SCT  		read 1 sct
1136				 
1137	6798	FC	604A	      	LDD     CLSTL   		B:cluster
1138	679B	58		      	LSLB    			
1139	679C	7D	6009	      	TST     SDHC    		sd:0,sdhc:1
1140	679F	27	01	      	BEQ     KL1     		
1141	67A1	58		      	LSLB    			
1142	67A2	8E	5E00	KL1   	LDX     #RWBUF  		
1143	67A5	30	85	      	LEAX    B,X     		
1144	67A7	C6	02	      	LDB     #2      		
1145	67A9	7D	6009	      	TST     SDHC    		sd:0,sdhc:1
1146	67AC	27	02	      	BEQ     KL2     		
1147	67AE	C6	04	      	LDB     #4      		
1148	67B0	6F	80	KL2   	CLR     ,X+     		
1149	67B2	5A		      	DECB    			
1150	67B3	26	FB	      	BNE     KL2     		
1151	67B5	17	039B	      	LBSR    WRTSD1  		
1152	67B8			KILEND				
1153	67B8	39		      	RTS     			
1154				
1155				*
1156				****************************************
1157				* Write BASIC FILE
1158				****************************************
1159	67B9			WRBFILE	EQU     *       		
1160				*basic file exist check
1161	67B9	DC	35	      	LDD     BASAEP  		
1162	67BB	93	33	      	SUBD    BASADP  		
1163	67BD	1083	0002	      	CMPD    #2      		
1164	67C1	22	0A	      	BHI     WRB0    		exist
1165	67C3	17	05A2	      	LBSR    PCRLF   		
1166	67C6	8E	7131	NOFEND	LDX     #MSNOFL 		
1167	67C9	17	0657	      	LBSR    PSTRNG  		
1168	67CC	39		      	RTS     			
1169				
1170				*save BASIC program file(binary saved)
1171	67CD	86	FF	WRB0  	LDA     #$FF    		
1172	67CF	B7	604D	      	STA     MCFLG   		set basic file
1173				*input file name
1174	67D2	17	FF19	      	LBSR    GETFDT  		
1175	67D5	BE	6065	      	LDX     EXSTFL  		if 0 not exist
1176	67D8	27	11	      	BEQ     WRB1    		
1177				
1178				*confirm over write
1179	67DA	8E	716F	      	LDX     #MSEXST 		
1180	67DD	17	0643	      	LBSR    PSTRNG  		
1181	67E0	BD	6F12	      	JSR     INOUTC  		
1182	67E3	84	DF	      	ANDA    #$DF    		
1183	67E5	81	59	      	CMPA    #'Y     		
1184	67E7	26	1B	      	BNE     WRBEND  		
1185				*delete exist file
1186	67E9	8D	92	      	BSR     KILSUB  		
1187				
1188	67EB			WRB1  				
1189				*set filename
1190	67EB	8E	6083	      	LDX     #FILBUF 		
1191	67EE	8D	15	      	BSR     SETFNM  		
1192				 
1193				*adrs
1194				* BASADP start adr
1195				* BASAEP end adr
1196				* BASEXP exec adr
1197				
1198				*main of write routine
1199				*clear dir entry
1200	67F0	8D	2F	      	BSR     CLRDIR  		
1201				
1202	67F2	17	0104	      	LBSR    SRCFAT  		search empty cluster on FAT
1203	67F5	17	0159	      	LBSR    SRCDIR  		search empty DIR entry
1204	67F8	17	0195	      	LBSR    MKFLDT  		make file data
1205	67FB	17	021B	      	LBSR    WRTFIL  		write file
1206	67FE	17	03AF	      	LBSR    WRTDIR  		write DIR entry
1207	6801	17	03D9	      	LBSR    WRTFAT  		set FAT
1208	6804			WRBEND				
1209	6804	39		      	RTS     			
1210				
1211				*------------------------------
1212				*set filename
1213	6805			SETFNM	EQU     *       		
1214				*clear buf
1215	6805	108E	605A	      	LDY     #FNAME+11		
1216	6809	C6	0B	      	LDB     #11     		
1217	680B	86	20	      	LDA     #$20    		
1218	680D	A7	A2	WRFLP2	STA     ,-Y     		
1219	680F	5A		      	DECB    			
1220	6810	26	FB	      	BNE     WRFLP2  		
1221				 
1222				*store filename
1223	6812	A6	80	WRFL1 	LDA     ,X+     		
1224	6814	81	2D	      	CMPA    #'-     		
1225	6816	27	04	      	BEQ     WRFL11  		
1226	6818	81	30	      	CMPA    #$30    		
1227	681A	25	04	      	BLO     WRFL2   		until delimiter
1228	681C	A7	A0	WRFL11	STA     ,Y+     		
1229	681E	20	F2	      	BRA     WRFL1   		
1230	6820			WRFL2 				
1231	6820	39		      	RTS     			
1232				
1233				*------------------------------
1234				*clear dir entry
1235	6821			CLRDIR	EQU     *       		
1236	6821	8E	601F	      	LDX     #DIRENT 		
1237	6824	C6	20	      	LDB     #32     		
1238	6826	4F		      	CLRA    			
1239	6827	17	03FA	      	LBSR    FILL    		
1240	682A	86	20	      	LDA     #$20    		set attr
1241	682C	A7	0B	      	STA     $0B,X   		
1242	682E	39		      	RTS     			
1243				
1244				*
1245				****************************************
1246				* Write MACHINE FILE
1247				****************************************
1248	682F			WRMFILE	EQU     *       		
1249				*save machine code
1250				*filename,topadr,endadr,exeadr ...machine file
1251	682F	17	FEBC	      	LBSR    GETFDT  		
1252	6832	BE	6065	      	LDX     EXSTFL  		if 0 not exist
1253	6835	27	12	      	BEQ     WRM1    		
1254				 
1255				*confirm over write
1256	6837	8E	716F	      	LDX     #MSEXST 		
1257	683A	17	05E6	      	LBSR    PSTRNG  		
1258	683D	BD	6F12	      	JSR     INOUTC  		
1259	6840	84	DF	      	ANDA    #$DF    		
1260	6842	81	59	      	CMPA    #'Y     		
1261	6844	26	35	      	BNE     WRMEND  		
1262				*delete exist file
1263	6846	17	FF34	      	LBSR    KILSUB  		
1264				 
1265	6849			WRM1  				
1266	6849	7F	604D	      	CLR     MCFLG   		set machine code(set 0)
1267				 
1268				*set filename
1269	684C	8E	6083	      	LDX     #FILBUF 		
1270	684F	8D	B4	      	BSR     SETFNM  		
1271				 
1272				*set top adr
1273	6851	8D	43	      	BSR     ASC2BIN 		
1274	6853	10BF	605F	      	STY     MCADP   		start adr
1275	6857	8D	30	      	BSR     SRCDLM  		
1276	6859	8D	3B	      	BSR     ASC2BIN 		
1277	685B	10BF	6061	      	STY     MCAEP   		end adr
1278	685F	8D	28	      	BSR     SRCDLM  		
1279	6861	8D	33	      	BSR     ASC2BIN 		
1280	6863	10BF	6063	      	STY     MCEXP   		exec adr
1281				 
1282				*main of write routine
1283				*clear dir entry
1284	6867	8D	B8	      	BSR     CLRDIR  		
1285				
1286	6869	17	008D	      	LBSR    SRCFAT  		search empty cluster on FAT
1287	686C	17	00E2	      	LBSR    SRCDIR  		search empty DIR entry
1288	686F	17	011E	      	LBSR    MKFLDT  		make file data
1289	6872	17	01A4	      	LBSR    WRTFIL  		write file
1290	6875	17	0338	      	LBSR    WRTDIR  		write DIR entry
1291	6878	17	0362	      	LBSR    WRTFAT  		set FAT
1292	687B			WRMEND				
1293	687B	39		      	RTS     			
1294				
1295				*--------------------
1296				*input filename & parameter to filbuf
1297	687C			INPFLDAT	EQU     *       		
1298	687C	34	24	      	PSHS    B,Y     		
1299	687E	108E	6083	      	LDY     #FILBUF 		
1300	6882	C6	1E	      	LDB     #30     		
1301	6884	17	0692	      	LBSR    LININ   		
1302	6887	35	A4	      	PULS    B,Y,PC  		
1303				 
1304				*--------------------
1305				*search delimiter
1306				*delimiter:less than $30, excluding '-'($2D)
1307				*return X:point next char of delimiter
1308	6889			SRCDLM	EQU     *       		
1309	6889	30	1F	      	LEAX    -1,X    		
1310	688B	A6	80	SRDLM1	LDA     ,X+     		
1311	688D	81	2D	      	CMPA    #'-     		
1312	688F	27	FA	      	BEQ     SRDLM1  		
1313	6891	81	30	      	CMPA    #$30    		
1314	6893	24	F6	      	BHS     SRDLM1  		
1315	6895	39		      	RTS     			
1316				
1317				*--------------------
1318				*X - X+3, return Y
1319	6896			ASC2BIN	EQU     *       		
1320				*clr buf
1321	6896	34	10	      	PSHS    X       		
1322	6898	8E	607F	      	LDX     #CNVBUF 		
1323	689B	86	30	      	LDA     #$30    		
1324	689D	C6	04	      	LDB     #4      		
1325	689F	17	0382	      	LBSR    FILL    		
1326	68A2	35	10	      	PULS    X       		
1327				 
1328				*search next delimiter
1329				*return B:char count
1330	68A4	34	10	      	PSHS    X       		
1331	68A6	5F		      	CLRB    			
1332	68A7	5C		SRLOP1	INCB    			
1333	68A8	A6	80	      	LDA     ,X+     		
1334	68AA	81	30	      	CMPA    #$30    		count over $30
1335	68AC	24	F9	      	BHS     SRLOP1  		
1336	68AE	5A		      	DECB    			
1337	68AF	35	10	      	PULS    X       		
1338				 
1339				*trans
1340	68B1	108E	607F	      	LDY     #CNVBUF 		
1341	68B5	34	04	      	PSHS    B       		
1342	68B7	C6	04	      	LDB     #4      		
1343	68B9	E0	E4	      	SUBB    ,S      		
1344	68BB	31	A5	      	LEAY    B,Y     		
1345	68BD	35	04	      	PULS    B       		
1346	68BF	A6	80	SRLOP2	LDA     ,X+     		
1347	68C1	A7	A0	      	STA     ,Y+     		
1348	68C3	5A		      	DECB    			
1349	68C4	26	F9	      	BNE     SRLOP2  		
1350				 
1351				*convert to bin
1352	68C6	34	10	      	PSHS    X       		
1353	68C8	8E	607F	      	LDX     #CNVBUF 		
1354	68CB	EC	81	      	LDD     ,X++    		
1355	68CD	8D	0F	      	BSR     CNVSUB  		
1356	68CF	34	02	      	PSHS    A       		
1357	68D1	EC	81	      	LDD     ,X++    		
1358	68D3	8D	09	      	BSR     CNVSUB  		
1359	68D5	1F	89	      	TFR     A,B     		
1360	68D7	35	02	      	PULS    A       		
1361	68D9	1F	02	      	TFR     D,Y     		
1362	68DB	35	10	      	PULS    X       		
1363	68DD	39		      	RTS     			
1364				 
1365				*cnv sub
1366				*return A
1367	68DE			CNVSUB	EQU     *       		
1368	68DE	80	30	      	SUBA    #$30    		
1369	68E0	81	11	      	CMPA    #$11    		
1370	68E2	25	02	      	BLO     CNV1    		
1371	68E4	80	07	      	SUBA    #7      		
1372	68E6	48		CNV1  	LSLA    			
1373	68E7	48		      	LSLA    			
1374	68E8	48		      	LSLA    			
1375	68E9	48		      	LSLA    			
1376	68EA	C0	30	      	SUBB    #$30    		
1377	68EC	C1	11	      	CMPB    #$11    		
1378	68EE	25	02	      	BLO     CNV2    		
1379	68F0	C0	07	      	SUBB    #7      		
1380	68F2	C4	0F	CNV2  	ANDB    #$0F    		
1381	68F4	34	04	      	PSHS    B       		
1382	68F6	AB	E0	      	ADDA    ,S+     		
1383	68F8	39		      	RTS     			
1384				 
1385				*--------------------
1386				* search empty area in FAT
1387	68F9			SRCFAT	EQU     *       		
1388	68F9	8E	600E	      	LDX     #SCTFAT 		
1389	68FC	17	FABD	      	LBSR    SETSNO  		
1390	68FF	17	035F	      	LBSR    RD1SCT  		read 1 sct
1391				 
1392	6902	8E	5E00	      	LDX     #RWBUF  		
1393				*search $00
1394	6905			SRC0  				
1395	6905	C6	02	      	LDB     #2      		SD
1396	6907	7D	6009	      	TST     SDHC    		0:SD,1:SDHC
1397	690A	27	02	      	BEQ     SRCLOP  		
1398	690C	C6	04	      	LDB     #4      		SDHC
1399	690E	8D	32	SRCLOP	BSR     SRC00   		search 1st 00 ...1st 00
1400	6910	24	2F	      	BCC     SFATED  		not exist empty area
1401	6912	A6	80	      	LDA     ,X+     		next is 00? ..2nd 00
1402	6914	26	EF	      	BNE     SRC0    		restart
1403	6916	7D	6009	      	TST     SDHC    		0:SD,1:SDHC
1404	6919	27	0A	      	BEQ     SETX    		
1405	691B	A6	80	      	LDA     ,X+     		next is 00? ..3rd 00
1406	691D	26	E6	      	BNE     SRC0    		restart
1407	691F	A6	80	      	LDA     ,X+     		next is 00? ..4th 00
1408	6921	26	E2	      	BNE     SRC0    		restart
1409	6923	30	1E	      	LEAX    -2,X    		
1410	6925			SETX  				
1411	6925	30	1E	      	LEAX    -2,X    		pos in RWBUF
1412	6927	3089	A200	      	LEAX    -RWBUF,X		relative pos
1413	692B	1F	10	      	TFR     X,D     		
1414	692D	44		      	LSRA    			
1415	692E	56		      	RORB    			1/2
1416	692F	7D	6009	      	TST     SDHC    		0:SD,1:SDHC
1417	6932	27	02	      	BEQ     SETCL   		
1418	6934	44		      	LSRA    			
1419	6935	56		      	RORB    			1/2
1420	6936	FD	604A	SETCL 	STD     CLSTL   		
1421	6939	1E	89	      	EXG     A,B     		
1422	693B	8E	601F	      	LDX     #DIRENT 		
1423	693E	ED	88 1A	      	STD     $1A,X   		set cluster L to dirent
1424	6941	39		SFATED	RTS     			
1425				 
1426				*search 00 in FAT
1427	6942	8C	6000	SRC00 	CMPX    #RWBUF+512		
1428	6945	24	07	      	BHS     NOEXST  		
1429	6947	A6	80	      	LDA     ,X+     		
1430	6949	26	F7	      	BNE     SRC00   		
1431	694B	1A	01	EXIST 	ORCC    #$01    		set C
1432	694D	39		      	RTS     			
1433	694E	1C	FE	NOEXST	ANDCC   #$FE    		reset C
1434	6950	39		      	RTS     			
1435				
1436				*--------------------
1437				* search empty DIR entry
1438				* return:DPGNO,DIROFS
1439	6951			SRCDIR	EQU     *       		
1440	6951	7F	605A	      	CLR     DPGNO   		
1441				*return no of DIR
1442	6954	8E	6016	      	LDX     #SCTDSV 		
1443	6957	108E	6012	      	LDY     #SCTDIR 		
1444	695B	C6	04	      	LDB     #4      		
1445	695D	17	02B9	      	LBSR    TRANS   		
1446	6960	8E	6012	SRCFL0	LDX     #SCTDIR 		
1447	6963	17	FA56	SRCFL1	LBSR    SETSNO  		
1448	6966	17	02F8	      	LBSR    RD1SCT  		read 1 sct
1449				 
1450	6969	8E	5E00	      	LDX     #RWBUF  		
1451	696C	8C	6000	DLOP1 	CMPX    #RWBUF+512		
1452	696F	24	0D	      	BHS     SRCFL5  		
1453	6971	A6	80	      	LDA     ,X+     		
1454	6973	27	15	      	BEQ     DIRGET  		
1455	6975	81	E5	      	CMPA    #$E5    		delete mark?
1456	6977	27	11	      	BEQ     DIRGET  		
1457	6979	30	88 1F	      	LEAX    32-1,X  		
1458	697C	20	EE	      	BRA     DLOP1   		
1459				
1460	697E	7C	605A	SRCFL5	INC     DPGNO   		
1461	6981	8E	6012	      	LDX     #SCTDIR 		
1462	6984	17	02A6	      	LBSR    INCX4   		sct no +1
1463	6987	20	DA	      	BRA     SRCFL1  		
1464	6989			DSPED 				
1465	6989	39		      	RTS     			
1466				
1467	698A	30	1F	DIRGET	LEAX    -1,X    		
1468	698C	BF	605B	      	STX     DIROFS  		
1469	698F	39		      	RTS     			
1470				
1471				*--------------------
1472	6990			MKFLDT	EQU     *       		
1473				*cluster no & attr already set
1474				*file name input&set
1475	6990	8E	604F	      	LDX     #FNAME  		
1476	6993	108E	601F	      	LDY     #DIRENT 		
1477	6997	C6	0B	      	LDB     #11     		
1478	6999	17	027D	      	LBSR    TRANS   		set file name
1479				 
1480				*cal file size
1481	699C	7D	604D	      	TST     MCFLG   		00,FF(FE),else
1482	699F	2B	08	      	BMI     MKF1    		
1483	69A1	FC	6061	      	LDD     MCAEP   		
1484	69A4	B3	605F	      	SUBD    MCADP   		
1485	69A7	20	04	      	BRA     MKF2    		
1486	69A9			MKF1  				
1487	69A9	DC	35	      	LDD     BASAEP  		
1488	69AB	93	33	      	SUBD    BASADP  		
1489	69AD			MKF2  				
1490	69AD	C3	0001	      	ADDD    #1      		
1491	69B0	FD	6046	      	STD     FILSIZ  		
1492	69B3	FD	6075	      	STD     WK0     		
1493				* EXG A,B
1494				* LDX #DIRENT
1495				* STD $1C,X
1496				
1497				*set date (for FM-7)
1498	69B6	8D	12	      	BSR     STDATE  		
1499	69B8	FC	603F	      	LDD     WMDY    		
1500	69BB	1E	89	      	EXG     A,B     		
1501				 
1502				*year,month,day
1503	69BD	8E	601F	      	LDX     #DIRENT 		
1504	69C0	ED	88 18	      	STD     $18,X   		
1505	69C3	ED	88 10	      	STD     $10,X   		
1506	69C6	ED	88 12	      	STD     $12,X   		
1507	69C9	39		      	RTS     			
1508				
1509				*----------
1510				*FM day to SD
1511				*retuen WMDY,WMDY+1
1512	69CA			STDATE	EQU     *       		
1513	69CA	8E	02FA	      	LDX     #FMDAT  		date of FM-7
1514	69CD	108E	603F	      	LDY     #WMDY   		
1515	69D1	C6	03	      	LDB     #3      		
1516	69D3	34	04	ABLOP 	PSHS    B       		
1517	69D5	EC	81	      	LDD     ,X++    		
1518	69D7	8D	2E	      	BSR     APLUSB  		
1519	69D9	A7	A0	      	STA     ,Y+     		
1520	69DB	35	04	      	PULS    B       		
1521	69DD	26	F4	      	BNE     ABLOP   		
1522				*year
1523	69DF	B6	603F	      	LDA     WMDY    		
1524	69E2	8B	14	      	ADDA    #20     		---2000-1980
1525	69E4	48		      	LSLA    			
1526	69E5	B7	603F	      	STA     WMDY    		
1527				*month
1528	69E8	B6	6040	      	LDA     WMDY+1  		
1529	69EB	48		      	LSLA    			
1530	69EC	48		      	LSLA    			
1531	69ED	48		      	LSLA    			
1532	69EE	48		      	LSLA    			
1533	69EF	48		      	ASLA    			
1534	69F0	B7	6040	      	STA     WMDY+1  		
1535	69F3	F6	603F	      	LDB     WMDY    		
1536	69F6	C9	00	      	ADCB    #0      		plus C
1537	69F8	F7	603F	      	STB     WMDY    		
1538				*day
1539	69FB	B6	6041	      	LDA     WMDY+2  		
1540	69FE	84	1F	      	ANDA    #$1F    		
1541	6A00	BB	6040	      	ADDA    WMDY+1  		
1542	6A03	B7	6040	      	STA     WMDY+1  		
1543	6A06	39		      	RTS     			
1544				
1545				*lower nibble of A,B to A+B
1546	6A07			APLUSB	EQU     *       		
1547	6A07	34	10	      	PSHS    X       		
1548	6A09	34	04	      	PSHS    B       		
1549	6A0B	C6	0A	      	LDB     #10     		
1550	6A0D	3D		      	MUL     			
1551	6A0E	1F	01	      	TFR     D,X     		
1552	6A10	35	04	      	PULS    B       		
1553	6A12	3A		      	ABX     			
1554	6A13	1F	10	      	TFR     X,D     		
1555	6A15	1E	89	      	EXG     A,B     		A:data
1556	6A17	35	90	      	PULS    X,PC    		
1557				*
1558				*--------------------
1559	6A19			WRTFIL	EQU     *       		
1560				*calc file size for write to sd
1561	6A19	FC	6075	      	LDD     WK0     		
1562	6A1C	7D	604D	      	TST     MCFLG   		0,FF(FE),else
1563	6A1F	27	04	      	BEQ     WRTF0   		machine code
1564	6A21	2B	07	      	BMI     WRTF1   		basic(binary)
1565	6A23	2A	08	      	BPL     WRTF2   		else
1566	6A25	C3	000A	WRTF0 	ADDD    #10     		add header(&footer)
1567	6A28	20	03	      	BRA     WRTF2   		
1568	6A2A	C3	0003	WRTF1 	ADDD    #3      		add header
1569	6A2D			WRTF2 				
1570	6A2D	FD	6075	      	STD     WK0     		number of bytes actually written
1571	6A30	1E	89	      	EXG     A,B     		
1572	6A32	8E	601F	      	LDX     #DIRENT 		
1573	6A35	ED	88 1C	      	STD     $1C,X   		
1574	6A38	1E	89	      	EXG     A,B     		
1575				*calc counter (CNT:512byte units)
1576	6A3A	7F	604C	      	CLR     CNT     		
1577	6A3D	7C	604C	CALLOP	INC     CNT     		
1578	6A40	83	0200	      	SUBD    #512    		
1579	6A43	24	F8	      	BHS     CALLOP  		
1580				 
1581	6A45	86	01	      	LDA     #1      		
1582	6A47	B7	604E	      	STA     TPGFLG  		set top page
1583				
1584	6A4A	7D	604D	      	TST     MCFLG   		0,FF(FE),else
1585	6A4D	2B	05	      	BMI     WRTF3   		
1586	6A4F	BE	605F	      	LDX     MCADP   		saved top adr
1587	6A52	20	02	      	BRA     WRTF4   		
1588	6A54	9E	33	WRTF3 	LDX     BASADP  		saved top adr
1589	6A56	BF	606D	WRTF4 	STX     WK1     		src topadr
1590	6A59	CE	5E00	      	LDU     #RWBUF  		
1591				 
1592				*get clusterL
1593	6A5C	8E	601F	      	LDX     #DIRENT 		
1594	6A5F	EC	88 1A	      	LDD     $1A,X   		
1595	6A62	1E	89	      	EXG     A,B     		B:clusterL
1596				 
1597	6A64	BE	601A	      	LDX     SCTCLT  		sct no of top cluster
1598	6A67	BF	606F	      	STX     WK2     		
1599	6A6A	BE	601C	      	LDX     SCTCLT+2		
1600	6A6D	BF	6071	      	STX     WK2+2   		
1601				 
1602	6A70	C0	02	      	SUBB    #2      		for SD
1603	6A72	7D	6009	      	TST     SDHC    		0:SD,1:SDHC
1604	6A75	27	01	      	BEQ     WR2     		
1605	6A77	5A		      	DECB    			
1606	6A78			WR2   				
1607				
1608				*(X)..(X+3)+(B)x40h
1609	6A78	8E	606F	      	LDX     #WK2    		
1610	6A7B	17	01BE	      	LBSR    ADD40H  		cal of sct no
1611				 
1612				*set start sct no of file
1613	6A7E	34	10	      	PSHS    X       		
1614	6A80	8E	710A	      	LDX     #MSWTNG 		
1615	6A83	17	039D	      	LBSR    PSTRNG  		
1616	6A86	35	10	      	PULS    X       		
1617				 
1618	6A88			WRLOP 				
1619	6A88	86	2E	      	LDA     #'.     		
1620	6A8A	BD	FBBB	      	JSR     OUTCHA  		
1621	6A8D	FC	6075	      	LDD     WK0     		
1622	6A90	1F	02	      	TFR     D,Y     		
1623	6A92	1083	0200	      	CMPD    #512    		
1624	6A96	23	0A	      	BLS     WR3     		
1625	6A98	83	0200	      	SUBD    #512    		
1626	6A9B	FD	6075	      	STD     WK0     		
1627	6A9E	108E	0200	      	LDY     #512    		
1628	6AA2			WR3   				
1629				 
1630				*write data to rwbuf
1631				* (X)->(U:RWBUF)
1632				* (Y):SIZE 512bytes or Less
1633	6AA2	BE	606D	      	LDX     WK1     		
1634	6AA5	CE	5E00	      	LDU     #RWBUF  		
1635	6AA8	8D	44	      	BSR     WRSUB   		
1636				 
1637				*set to sctn0-3
1638	6AAA	34	30	      	PSHS    X,Y     		
1639	6AAC	8E	606F	      	LDX     #WK2    		
1640	6AAF	108E	6004	      	LDY     #SCTN0  		
1641	6AB3	C6	04	      	LDB     #4      		
1642	6AB5	17	0161	      	LBSR    TRANS   		
1643	6AB8	35	30	      	PULS    X,Y     		
1644				 
1645				*write data to sd
1646	6ABA	17	0093	      	LBSR    WRTSD   		...not wrtsd1
1647				
1648				*inc sctn0-3
1649	6ABD	8E	606F	      	LDX     #WK2    		
1650	6AC0	17	016A	      	LBSR    INCX4   		
1651	6AC3	BE	606D	      	LDX     WK1     		src topadr
1652	6AC6	3089	0200	      	LEAX    512,X   		
1653				*check top page
1654	6ACA	7D	604E	      	TST     TPGFLG  		top page?
1655	6ACD	27	0D	      	BEQ     WR6     		no
1656	6ACF	7D	604D	      	TST     MCFLG   		
1657	6AD2	27	04	      	BEQ     WR4     		machine code
1658	6AD4	2B	04	      	BMI     WR5     		basic(binary)
1659	6AD6	2A	04	      	BPL     WR6     		
1660	6AD8	30	1E	WR4   	LEAX    -2,X    		rewind 3or5
1661	6ADA	30	1D	WR5   	LEAX    -3,X    		
1662	6ADC			WR6   				 
1663	6ADC	7F	604E	      	CLR     TPGFLG  		
1664	6ADF	BF	606D	      	STX     WK1     		
1665	6AE2	7A	604C	      	DEC     CNT     		
1666	6AE5	26	A1	      	BNE     WRLOP   		
1667				 
1668	6AE7	8E	7123	WREND 	LDX     #MSWTED 		
1669	6AEA	17	0336	      	LBSR    PSTRNG  		
1670	6AED	39		      	RTS     			
1671				
1672				*----------
1673				*write data to rwbuf
1674				* (X)->(U:RWBUF)
1675				* (Y):SIZE 512bytes or Less
1676				*clear rwbuf
1677	6AEE			WRSUB 	EQU     *       		
1678	6AEE	34	30	      	PSHS    X,Y     		
1679	6AF0	4F		      	CLRA    			
1680	6AF1	8E	5E00	      	LDX     #RWBUF  		
1681	6AF4	108E	0200	      	LDY     #512    		
1682	6AF8	A7	80	WWCLOP	STA     ,X+     		
1683	6AFA	31	3F	      	LEAY    -1,Y    		
1684	6AFC	26	FA	      	BNE     WWCLOP  		
1685	6AFE	35	30	      	PULS    X,Y     		
1686				 
1687				*set data to rwbuf
1688	6B00	CE	5E00	      	LDU     #RWBUF  		
1689				 
1690	6B03	7D	604E	      	TST     TPGFLG  		1:top page,0:else
1691	6B06	27	16	      	BEQ     WRS01   		no
1692	6B08	7D	604D	      	TST     MCFLG   		0,$FF($FE),etc
1693	6B0B	2B	32	      	BMI     WRS1    		
1694				
1695				*add header of machine code
1696	6B0D	34	10	      	PSHS    X       		
1697	6B0F	4F		      	CLRA    			
1698	6B10	A7	C0	      	STA     ,U+     		$00
1699	6B12	BE	6046	      	LDX     FILSIZ  		
1700	6B15	AF	C1	      	STX     ,U++    		file size
1701	6B17	BE	605F	      	LDX     MCADP   		
1702	6B1A	AF	C1	      	STX     ,U++    		save adr
1703	6B1C	35	10	      	PULS    X       		
1704				
1705	6B1E			WRS01 				
1706				*check last page
1707	6B1E	B6	604C	      	LDA     CNT     		
1708	6B21	81	01	      	CMPA    #1      		
1709	6B23	26	02	      	BNE     WRS2    		
1710	6B25	31	3B	      	LEAY    -5,Y    		
1711				*set write data
1712	6B27	8D	1E	WRS2  	BSR     WRDSET  		
1713				*check last page
1714	6B29	B6	604C	      	LDA     CNT     		
1715	6B2C	81	01	      	CMPA    #1      		
1716	6B2E	26	0E	      	BNE     WRS3    		
1717				
1718				*add footer
1719	6B30			WRS211				
1720				* CMPU #RWBUF+512-5
1721				* BLS WRS21
1722				* RTS
1723	6B30	86	FF	WRS21 	LDA     #$FF    		
1724	6B32	A7	C0	      	STA     ,U+     		
1725	6B34	4F		      	CLRA    			
1726	6B35	A7	C0	      	STA     ,U+     		
1727	6B37	A7	C0	      	STA     ,U+     		
1728	6B39	BE	6063	      	LDX     MCEXP   		
1729	6B3C	AF	C1	      	STX     ,U++    		
1730	6B3E	39		WRS3  	RTS     			
1731				 
1732	6B3F			WRS1  				
1733				*add header of basic file
1734	6B3F	86	FF	      	LDA     #$FF    		
1735	6B41	A7	C0	      	STA     ,U+     		
1736	6B43	A7	C0	      	STA     ,U+     		
1737	6B45	A7	C0	      	STA     ,U+     		
1738				 
1739				*data set
1740	6B47	A6	80	WRDSET	LDA     ,X+     		
1741	6B49	A7	C0	      	STA     ,U+     		
1742	6B4B	31	3F	      	LEAY    -1,Y    		
1743	6B4D	26	F8	      	BNE     WRDSET  		
1744	6B4F	39		      	RTS     			
1745				
1746				*write data to sd
1747	6B50			WRTSD 	EQU     *       		
1748	6B50	17	01A1	      	LBSR    SETSCT  		*set SCT No
1749				*copy sct no to cmd param
1750	6B53	8E	6004	WRTSD1	LDX     #SCTN0  		
1751	6B56	108E	6F3F	      	LDY     #CMD24+1		
1752	6B5A	C6	04	      	LDB     #4      		
1753	6B5C	17	00BA	      	LBSR    TRANS   		
1754				*send cmd
1755	6B5F	17	01C1	      	LBSR    SETCKL  		
1756	6B62	C6	06	      	LDB     #6      		
1757	6B64	8E	6F3E	      	LDX     #CMD24  		
1758	6B67	A6	80	SDW1  	LDA     ,X+     		
1759	6B69	17	0149	      	LBSR    SNDDAT  		
1760	6B6C	5A		      	DECB    			
1761	6B6D	26	F8	      	BNE     SDW1    		
1762				*get cmd response
1763	6B6F			SDW2  				
1764	6B6F	17	015F	      	LBSR    GETDAT  		
1765	6B72	B6	6008	      	LDA     RESDAT  		
1766	6B75	81	00	      	CMPA    #$00    		
1767	6B77	26	F6	      	BNE     SDW2    		
1768				*1byte skip
1769	6B79	86	FF	      	LDA     #$FF    		
1770	6B7B	17	0137	      	LBSR    SNDDAT  		1byte skip
1771				 
1772				*send data packet
1773	6B7E	8E	5E00	      	LDX     #RWBUF  		<-temp -1="" 008d="" 0093="" 00b4="" 00b6="" 00ce="" 011a="" 011d="" 0126="" 0129="" 012b="" 0133="" 01="" 0200="" 02="" 03="" 04="" 05="" 06="" 08="" 0:sd="" 0f="" 108e="" 10be="" 12="" 16="" 1774="" 1775="" 1776="" 1777="" 1778="" 1779="" 1780="" 1781="" 1782="" 1783="" 1784="" 1785="" 1786="" 1787="" 1788="" 1789="" 1790="" 1791="" 1792="" 1793="" 1794="" 1795="" 1796="" 1797="" 1798="" 1799="" 17="" 1800="" 1801="" 1802="" 1803="" 1804="" 1805="" 1806="" 1807="" 1808="" 1809="" 1810="" 1811="" 1812="" 1813="" 1814="" 1815="" 1816="" 1817="" 1818="" 1819="" 1820="" 1821="" 1822="" 1823="" 1824="" 1825="" 1826="" 1827="" 1828="" 1829="" 1830="" 1831="" 1832="" 1833="" 1834="" 1835="" 1836="" 1837="" 1838="" 1839="" 1840="" 1841="" 1842="" 1843="" 1844="" 1845="" 1846="" 1847="" 1848="" 1849="" 1850="" 1851="" 1852="" 1853="" 1854="" 1855="" 1856="" 1857="" 1858="" 1859="" 1860="" 1861="" 1862="" 1863="" 1864="" 1865="" 1866="" 1867="" 1868="" 1869="" 1870="" 1871="" 1872="" 1873="" 1874="" 1875="" 1876="" 1877="" 1878="" 1879="" 1880="" 1881="" 1882="" 1883="" 1884="" 1885="" 1886="" 1887="" 1888="" 1889="" 1890="" 1891="" 1892="" 1893="" 1894="" 1895="" 1896="" 1897="" 1898="" 1899="" 1900="" 1901="" 1902="" 1903="" 1904="" 1905="" 1906="" 1907="" 1908="" 1909="" 1910="" 1911="" 1912="" 1913="" 1914="" 1915="" 1916="" 1917="" 1918="" 1919="" 1920="" 1921="" 1922="" 1923="" 1924="" 1925="" 1926="" 1927="" 1928="" 1929="" 1930="" 1931="" 1932="" 1933="" 1934="" 1935="" 1936="" 1937="" 1938="" 1939="" 1940="" 1941="" 1942="" 1943="" 1944="" 1945="" 1946="" 1947="" 1948="" 1949="" 1950="" 1951="" 1952="" 1953="" 1954="" 1955="" 1956="" 1957="" 1958="" 1959="" 1960="" 1961="" 1962="" 1963="" 1964="" 1965="" 1966="" 1967="" 1968="" 1969="" 1970="" 1971="" 1972="" 1973="" 1974="" 1975="" 1976="" 1977="" 1978="" 1979="" 1980="" 1981="" 1982="" 1983="" 1984="" 1985="" 1986="" 1987="" 1988="" 1989="" 1990="" 1991="" 1992="" 1993="" 1994="" 1995="" 1996="" 1997="" 1998="" 1="" 1a="" 1e="" 1f="" 20="" 24="" 26="" 27="" 2="" 31="" 34="" 35="" 36="" 39="" 3="" 3a="" 3d="" 3f="" 40="" 44="" 48="" 4c="" 50="" 54="" 5a="" 5c="" 5e00="" 5e="" 6004="" 6008="" 6009="" 600e="" 6012="" 6016="" 601f="" 605a="" 605b="" 60="" 68="" 6b81="" 6b85="" 6b87="" 6b8a="" 6b8c="" 6b8f="" 6b91="" 6b93="" 6b95="" 6b98="" 6b9b="" 6b9e="" 6ba1="" 6ba3="" 6ba5="" 6ba8="" 6bab="" 6bad="" 6baf="" 6bb0="" 6bb3="" 6bb7="" 6bb9="" 6bbb="" 6bbe="" 6bc1="" 6bc3="" 6bc5="" 6bc6="" 6bc8="" 6bcb="" 6bce="" 6bd1="" 6bd5="" 6bd7="" 6bd9="" 6bdc="" 6bdd="" 6be0="" 6be3="" 6be5="" 6be7="" 6be9="" 6bec="" 6bef="" 6bf1="" 6bf3="" 6bf5="" 6bf8="" 6bfa="" 6bfc="" 6bff="" 6c00="" 6c02="" 6c04="" 6c06="" 6c08="" 6c0a="" 6c0d="" 6c0f="" 6c11="" 6c13="" 6c15="" 6c18="" 6c19="" 6c1b="" 6c1d="" 6c1f="" 6c20="" 6c22="" 6c24="" 6c26="" 6c28="" 6c29="" 6c2b="" 6c2d="" 6c2f="" 6c31="" 6c33="" 6c35="" 6c37="" 6c39="" 6c3b="" 6c3c="" 6c3e="" 6c40="" 6c42="" 6c44="" 6c46="" 6c48="" 6c4a="" 6c4c="" 6c4e="" 6c50="" 6c52="" 6c54="" 6c56="" 6c58="" 6c5a="" 6c5c="" 6c5d="" 6c5f="" 6c61="" 6c64="" 6c68="" 6c6a="" 6c6c="" 6c6f="" 6c71="" 6c74="" 6c76="" 6c78="" 6c79="" 6c7b="" 6c7d="" 6c80="" 6c82="" 6c84="" 6c87="" 6c8b="" 6c8d="" 6c90="" 6c92="" 6c94="" 6c96="" 6c97="" 6c9a="" 6c9d="" 6c="" 6ca1="" 6ca3="" 6ca5="" 6ca8="" 6caa="" 6cac="" 6cad="" 6caf="" 6cb2="" 6cb4="" 6cb5="" 6cb7="" 6cba="" 6cbc="" 6cbe="" 6cc0="" 6cc2="" 6cc5="" 6cc7="" 6cc9="" 6cca="" 6ccc="" 6ccd="" 6ccf="" 6cd1="" 6cd3="" 6cd5="" 6cd7="" 6cd8="" 6cd9="" 6cda="" 6cdc="" 6cdf="" 6ce0="" 6f38="" 6f39="" 70="" 7d="" 7f="" 80="" 81="" 84="" 86="" 88="" 89="" 8a="" 8b="" 8d="" 8e="" 96="" a0="" a6="" a7="" a:fill="" a="" abx="" ad="" add0="" add1="" add2="" add3="" add40h="" adda="" addb="" adr="" adx0="" adx1="" adx2="" adx3="" anda="" b1-="" b6="" b7="" b:cnt="" bcc="" beq="" bne="" bra="" bsr="" buf="" busy="" c6="" cb="" ckrs="" clr="" cluster="" cmd="" cmpa="" copy="" crch="" crcl="" cs:b0="L" d="" data="" decb="" df="" dir="" dirofs="" disp="" dpgno="" dspb1="" dspb2="" dspb3="" dspbin="" dspbuf="" e5="" ec="" ed="" equ="" exg="" f4="" f5="" f6="" f7="" f7cd="" f7f1="" f9="" fb="" fc="" fd9e="" fe="" ff3b="" ff77="" ff="" fill="" filop="" get="" getd1="" getdat="" inc="" incx4="" lbsr="" lda="" ldb="" ldd="" ldx="" ldy="" leay="" lsla="" lsra="" miso:b1="H(for" no="" nop="" of="" ora="" param="" pbdat="" pcrlf="" pia="" pshs="" puls="" rd1="" rd1sct="" rd2="" rd3="" read="" resdat="" response="" return="" rts="" save="" sct="" sd:2="" sdhc:4="" sdhc="" send="" setckh="" setckl="" setsno="" sndd1="" snddat="" snddt1="" src="" sta="" temp="" tfr="" to="" token="" trans="" trlop="" tst="" until="" wait="" wrdlop="" wrdskp="" wrf1="" wrf2="" wrf3="" wrtdir="" wrtfat="" wrtsd1="" wspfl0="" x40h="" y:dst="" y="">C
1999	6CE1	79	6008	      	ROL     RESDAT  		C->b0
2000	6CE4	5A		      	DECB    			
2001	6CE5	26	EE	      	BNE     GETD1   		
2002	6CE7	8D	3A	      	BSR     SETCKL  		
2003	6CE9	35	86	      	PULS    A,B,PC  		
2004				*
2005				*------------------------------
2006				*input SCT No
2007	6CEB			INSCT 	EQU     *       		
2008	6CEB	8E	7046	      	LDX     #MSSCT  		
2009	6CEE	17	0132	      	LBSR    PSTRNG  		
2010	6CF1	17	0085	      	LBSR    GET8CH  		get 8chr, convert 4bin
2011				 
2012	6CF4			SETSCT	EQU     *       		
2013	6CF4	34	32	      	PSHS    A,X,Y   		
2014	6CF6	7D	6009	      	TST     SDHC    		0:SD,1:SDHC
2015	6CF9	26	1A	      	BNE     CALCHC  		
2016				*SD card
2017	6CFB	8E	6005	      	LDX     #SCTN1  		
2018	6CFE	108E	6004	      	LDY     #SCTN0  		
2019	6D02	C6	03	      	LDB     #3      		
2020	6D04	17	FF12	      	LBSR    TRANS   		
2021	6D07	7F	6007	      	CLR     SCTN3   		
2022				*calc top adrs of sct
2023	6D0A			CALCSD	EQU     *       		
2024	6D0A	78	6007	      	LSL     SCTN3   		
2025	6D0D	79	6006	      	ROL     SCTN2   		
2026	6D10	79	6005	      	ROL     SCTN1   		
2027	6D13	35	B2	      	PULS    A,X,Y,PC		
2028				
2029				*SDHC card
2030				*calc top adrs of sct
2031	6D15			CALCHC	EQU     *       		
2032	6D15	8E	6004	      	LDX     #SCTN0  		
2033	6D18	108E	6F39	      	LDY     #CMD17+1		
2034	6D1C	C6	04	      	LDB     #4      		
2035	6D1E	17	FEF8	      	LBSR    TRANS   		
2036	6D21	35	B2	      	PULS    A,X,Y,PC		
2037				
2038				*
2039				*set sck:L
2040	6D23			SETCKL	EQU     *       		
2041	6D23	34	02	      	PSHS    A       		
2042	6D25	86	34	      	LDA     #$34    		ca2=L
2043	6D27	B7	FD9F	      	STA     PBCTL   		
2044	6D2A	35	82	      	PULS    A,PC    		
2045				
2046				*set sck:H
2047	6D2C			SETCKH	EQU     *       		
2048	6D2C	34	02	      	PSHS    A       		
2049	6D2E	86	3C	      	LDA     #$3C    		ca2=H
2050	6D30	B7	FD9F	      	STA     PBCTL   		
2051	6D33	35	82	      	PULS    A,PC    		
2052				
2053				*binary(A)->ascii(A)(B)
2054	6D35			DSPBIN	EQU     *       		
2055	6D35	8D	04	      	BSR     DSPBI0  		
2056	6D37	BD	6D73	      	JSR     OUTSPC  		
2057	6D3A	39		      	RTS     			
2058				*
2059	6D3B			DSPBI0	EQU     *       		
2060	6D3B	34	06	      	PSHS    A,B     		
2061	6D3D	1F	89	      	TFR     A,B     		
2062	6D3F	44		      	LSRA    			
2063	6D40	44		      	LSRA    			
2064	6D41	44		      	LSRA    			
2065	6D42	44		      	LSRA    			
2066	6D43	8A	30	      	ORA     #$30    		
2067	6D45	C4	0F	      	ANDB    #$0F    		
2068	6D47	CA	30	      	ORB     #$30    		
2069	6D49	81	39	      	CMPA    #$39    		
2070	6D4B	23	02	      	BLS     BI21    		
2071	6D4D	8B	07	      	ADDA    #$07    		
2072	6D4F	C1	39	BI21  	CMPB    #$39    		
2073	6D51	23	02	      	BLS     BI22    		
2074	6D53	CB	07	      	ADDB    #$07    		
2075	6D55	BD	FBBB	BI22  	JSR     OUTCHA  		
2076	6D58	1F	98	      	TFR     B,A     		
2077	6D5A	BD	FBBB	      	JSR     OUTCHA  		
2078	6D5D	35	86	      	PULS    A,B,PC  		
2079				
2080				*
2081	6D5F			DSPBI2	EQU     *       		
2082	6D5F	A6	80	      	LDA     ,X+     		
2083	6D61	8D	D8	      	BSR     DSPBI0  		
2084	6D63	A6	80	      	LDA     ,X+     		
2085	6D65	8D	D4	      	BSR     DSPBI0  		
2086	6D67	39		      	RTS     			
2087				
2088				*
2089				*crlf
2090	6D68			PCRLF 	EQU     *       		
2091	6D68	86	0D	      	LDA     #CR     		
2092	6D6A	BD	FBBB	      	JSR     OUTCHA  		
2093	6D6D	86	0A	      	LDA     #LF     		
2094	6D6F	BD	FBBB	      	JSR     OUTCHA  		
2095	6D72	39		      	RTS     			
2096				
2097				*out spc
2098	6D73			OUTSPC	EQU     *       		
2099	6D73	86	20	      	LDA     #SPC    		
2100	6D75	BD	FBBB	      	JSR     OUTCHA  		
2101	6D78	39		      	RTS     			
2102				
2103				*
2104	6D79			GET8CH	EQU     *       		
2105				*input chr
2106	6D79	8E	6077	      	LDX     #INPBUF 		
2107	6D7C	5F		      	CLRB    			
2108	6D7D	BD	6F12	CLOP  	JSR     INOUTC  		
2109	6D80	81	0D	      	CMPA    #CR     		
2110	6D82	27	07	      	BEQ     INEND   		
2111	6D84	A7	85	      	STA     B,X     		
2112	6D86	5C		      	INCB    			
2113	6D87	C1	08	      	CMPB    #8      		
2114	6D89	25	F2	      	BLO     CLOP    		
2115				
2116	6D8B			INEND 				
2117				*shift
2118	6D8B	5D		      	TSTB    			
2119	6D8C	27	21	      	BEQ     CLEND   		
2120	6D8E	8E	6077	      	LDX     #INPBUF 		
2121	6D91	3A		      	ABX     			
2122	6D92	108E	607F	      	LDY     #INPBUF+8		
2123	6D96	34	04	      	PSHS    B       		
2124	6D98	A6	82	SFLOP 	LDA     ,-X     		
2125	6D9A	A7	A2	      	STA     ,-Y     		
2126	6D9C	5A		      	DECB    			
2127	6D9D	26	F9	      	BNE     SFLOP   		
2128				*clr
2129	6D9F	C6	08	CL1   	LDB     #8      		
2130	6DA1	E0	E0	      	SUBB    ,S+     		
2131	6DA3	27	0A	      	BEQ     CLEND   		
2132	6DA5	8E	6077	      	LDX     #INPBUF 		
2133	6DA8	86	30	      	LDA     #'0     		
2134	6DAA	A7	80	CLLOP 	STA     ,X+     		
2135	6DAC	5A		      	DECB    			
2136	6DAD	26	FB	      	BNE     CLLOP   		
2137	6DAF			CLEND 				
2138				
2139				*convert to bin
2140	6DAF	C6	04	      	LDB     #4      		
2141	6DB1	8E	6077	      	LDX     #INPBUF 		
2142	6DB4	108E	6004	      	LDY     #SCTN0  		
2143	6DB8			CVT1  				
2144	6DB8	A6	80	      	LDA     ,X+     		
2145	6DBA	8D	1E	      	BSR     CVBIN   		
2146	6DBC	25	16	      	BCS     EREND1  		
2147	6DBE	48		      	LSLA    			
2148	6DBF	48		      	LSLA    			
2149	6DC0	48		      	LSLA    			
2150	6DC1	48		      	LSLA    			
2151	6DC2	34	02	      	PSHS    A       		
2152	6DC4	A6	80	      	LDA     ,X+     		
2153	6DC6	8D	12	      	BSR     CVBIN   		
2154	6DC8	25	08	      	BCS     EREND0  		
2155	6DCA	AB	E0	      	ADDA    ,S+     		
2156	6DCC	A7	A0	      	STA     ,Y+     		
2157	6DCE	5A		      	DECB    			
2158	6DCF	26	E7	      	BNE     CVT1    		
2159	6DD1	39		      	RTS     			
2160				 
2161	6DD2	35	02	EREND0	PULS    A       		
2162	6DD4	8E	708C	EREND1	LDX     #MSERR  		
2163	6DD7	8D	4A	      	BSR     PSTRNG  		
2164	6DD9	39		EEND  	RTS     			
2165				
2166				*--------------------
2167				*ascii -> bin
2168	6DDA			CVBIN 	EQU     *       		
2169	6DDA	80	30	      	SUBA    #'0     		
2170	6DDC	2B	11	      	BMI     CVERR   		
2171	6DDE	81	09	      	CMPA    #9      		
2172	6DE0	23	0A	      	BLS     CVBEND  		
2173	6DE2	81	11	      	CMPA    #$11    		
2174	6DE4	25	09	      	BLO     CVERR   		
2175	6DE6	81	16	      	CMPA    #$16    		
2176	6DE8	22	05	      	BHI     CVERR   		
2177	6DEA	80	07	      	SUBA    #7      		
2178	6DEC			CVBEND				
2179	6DEC	1C	FE	      	ANDCC   #$FE    		reset C
2180	6DEE	39		      	RTS     			
2181	6DEF	1A	01	CVERR 	ORCC    #$01    		set C
2182	6DF1	39		      	RTS     			
2183				
2184				*--------------------
2185				*add 2bytes to 4bytes
2186				* X,X+1,X+2,X+3 + Y,Y+1
2187				* data X is big endian
2188				* data Y is little endian
2189	6DF2			ADD42 	EQU     *       		
2190	6DF2	34	36	      	PSHS    A,B,X,Y 		
2191	6DF4	32	7C	      	LEAS    -4,S    		
2192	6DF6	C6	04	      	LDB     #4      		
2193	6DF8	A6	80	AD1   	LDA     ,X+     		
2194	6DFA	A7	E0	      	STA     ,S+     		
2195	6DFC	5A		      	DECB    			
2196	6DFD	26	F9	      	BNE     AD1     		
2197				 
2198				*add (lower)
2199	6DFF	A6	A0	      	LDA     ,Y+     		
2200	6E01	AB	E2	      	ADDA    ,-S     		
2201	6E03	A7	E4	      	STA     ,S      		
2202	6E05	24	02	      	BCC     AD2     		
2203	6E07	6C	7F	      	INC     -1,S    		
2204				*add (upper)
2205	6E09	A6	A4	AD2   	LDA     ,Y      		
2206	6E0B	AB	E2	      	ADDA    ,-S     		
2207	6E0D	A7	E4	      	STA     ,S      		
2208	6E0F	24	02	      	BCC     AD3     		
2209	6E11	6C	7F	      	INC     -1,S    		
2210	6E13	30	1C	AD3   	LEAX    -4,X    		
2211	6E15	32	7E	      	LEAS    -2,S    		
2212	6E17	C6	04	      	LDB     #4      		
2213	6E19	A6	E0	AD4   	LDA     ,S+     		
2214	6E1B	A7	80	      	STA     ,X+     		
2215	6E1D	5A		      	DECB    			
2216	6E1E	26	F9	      	BNE     AD4     		
2217	6E20	35	36	      	PULS    A,B,X,Y 		
2218	6E22	39		      	RTS     			
2219				
2220				*--------------------
2221				* pstring
2222	6E23			PSTRNG	EQU     *       		
2223	6E23	34	02	      	PSHS    A       		
2224	6E25	A6	80	PSLOP 	LDA     ,X+     		
2225	6E27	81	04	      	CMPA    #4      		
2226	6E29	27	05	      	BEQ     PSEND   		
2227	6E2B	BD	FBBB	      	JSR     OUTCHA  		
2228	6E2E	20	F5	      	BRA     PSLOP   		
2229	6E30	35	02	PSEND 	PULS    A       		
2230	6E32	39		      	RTS     			
2231				
2232				*--------------------
2233				*disp MM-DD-YY
2234				*indata A(Low),B(High)
2235	6E33			DSPYMD	EQU     *       		
2236	6E33	1E	89	      	EXG     A,B     		
2237	6E35	34	10	      	PSHS    X       		
2238	6E37	34	06	      	PSHS    A,B     		
2239	6E39	C4	E0	      	ANDB    #$E0    		
2240	6E3B	54		      	LSRB    			
2241	6E3C	54		      	LSRB    			
2242	6E3D	54		      	LSRB    			
2243	6E3E	54		      	LSRB    			
2244	6E3F	54		      	LSRB    			
2245	6E40	47		      	ASRA    			
2246	6E41	24	02	      	BCC     DYMD1   		
2247	6E43	CB	08	      	ADDB    #8      		
2248	6E45	F7	603F	DYMD1 	STB     WMDY    		MM
2249	6E48	35	06	      	PULS    A,B     		
2250	6E4A	34	04	      	PSHS    B       		
2251	6E4C	C4	1F	      	ANDB    #$1F    		
2252	6E4E	F7	6040	      	STB     WMDY+1  		DD
2253	6E51	35	04	      	PULS    B       		
2254				 
2255	6E53	44		      	LSRA    			
2256				* ASLB
2257				* BCC DYMD2
2258				* INCA
2259	6E54			DYMD2 				
2260	6E54	80	14	      	SUBA    #20     		A+1980-2000
2261	6E56	B7	6041	      	STA     WMDY+2  		YY
2262				 
2263				*disp MM-DD-YY
2264	6E59	BD	6D73	      	JSR     OUTSPC  		
2265	6E5C	8E	603F	      	LDX     #WMDY   		
2266	6E5F	A6	80	      	LDA     ,X+     		
2267	6E61	8D	14	      	BSR     DB2ASC  		MM
2268	6E63	86	2D	      	LDA     #'-     		
2269	6E65	BD	FBBB	      	JSR     OUTCHA  		
2270	6E68	A6	80	      	LDA     ,X+     		
2271	6E6A	8D	0B	      	BSR     DB2ASC  		DD
2272	6E6C	86	2D	      	LDA     #'-     		
2273	6E6E	BD	FBBB	      	JSR     OUTCHA  		
2274	6E71	A6	80	      	LDA     ,X+     		
2275	6E73	8D	02	      	BSR     DB2ASC  		YY
2276	6E75	35	90	      	PULS    X,PC    		
2277				*
2278				*----------
2279				*convert decimal value to ascii code
2280				*(A:BIN)->ASCII
2281	6E77			DB2ASC	EQU     *       		
2282	6E77	34	06	      	PSHS    A,B     		
2283	6E79	1F	89	      	TFR     A,B     		
2284	6E7B	86	30	      	LDA     #$30    		
2285	6E7D	C1	0A	DBLOP 	CMPB    #10     		
2286	6E7F	25	05	      	BLO     DB2     		
2287	6E81	C0	0A	      	SUBB    #10     		
2288	6E83	4C		      	INCA    			
2289	6E84	20	F7	      	BRA     DBLOP   		
2290	6E86	BD	FBBB	DB2   	JSR     OUTCHA  		
2291	6E89	1F	98	      	TFR     B,A     		
2292	6E8B	8B	30	      	ADDA    #$30    		
2293	6E8D	BD	FBBB	      	JSR     OUTCHA  		
2294	6E90	35	86	      	PULS    A,B,PC  		
2295				
2296				*disp FILE size
2297	6E92			DSPSIZ	EQU     *       		
2298	6E92	34	10	      	PSHS    X       		
2299	6E94	BE	6042	      	LDX     WFSIZ   		
2300	6E97	27	07	      	BEQ     DSS1    		if 64k over?
2301	6E99	8E	7157	      	LDX     #MSOVR  		
2302	6E9C	8D	85	      	BSR     PSTRNG  		
2303	6E9E	20	3E	      	BRA     DSEND   		
2304				 
2305	6EA0			DSS1  				
2306				* /1024(400h)
2307	6EA0	B6	6044	      	LDA     WFSIZ+2 		under 64k
2308	6EA3	44		      	LSRA    			
2309	6EA4	44		      	LSRA    			
2310				*disp dec
2311	6EA5	1F	89	      	TFR     A,B     		
2312	6EA7	81	64	      	CMPA    #100    		
2313	6EA9	23	10	      	BLS     DSS13   		
2314	6EAB	86	30	      	LDA     #'0     		
2315	6EAD	C1	64	DSLOP1	CMPB    #100    		
2316	6EAF	25	05	      	BLO     DSS12   		
2317	6EB1	C0	64	      	SUBB    #100    		
2318	6EB3	4C		      	INCA    			
2319	6EB4	20	F7	      	BRA     DSLOP1  		
2320	6EB6	BD	FBBB	DSS12 	JSR     OUTCHA  		
2321	6EB9	20	09	      	BRA     DSS14   		
2322				 
2323				*under 100
2324	6EBB	BD	6D73	DSS13 	JSR     OUTSPC  		
2325	6EBE	86	20	      	LDA     #SPC    		
2326	6EC0	C1	0A	      	CMPB    #10     		
2327	6EC2	25	0B	      	BLO     DSS2    		
2328				 
2329	6EC4	86	30	DSS14 	LDA     #'0     		
2330	6EC6	C1	0A	DSLOP2	CMPB    #10     		
2331	6EC8	25	05	      	BLO     DSS2    		
2332	6ECA	C0	0A	      	SUBB    #10     		
2333	6ECC	4C		      	INCA    			
2334	6ECD	20	F7	      	BRA     DSLOP2  		
2335				 
2336	6ECF	BD	FBBB	DSS2  	JSR     OUTCHA  		10's place
2337				*under 10
2338	6ED2	1F	98	DSS21 	TFR     B,A     		
2339	6ED4	8B	31	      	ADDA    #$31    		'1
2340	6ED6	BD	FBBB	DSS3  	JSR     OUTCHA  		1's place
2341	6ED9	86	6B	      	LDA     #'k     		
2342	6EDB	BD	FBBB	      	JSR     OUTCHA  		
2343	6EDE	BD	6D73	DSEND 	JSR     OUTSPC  		
2344	6EE1	35	90	      	PULS    X,PC    		
2345				
2346				*----------
2347				*disp cluster
2348				*return:clusterL
2349	6EE3			DSPCLS	EQU     *       		
2350	6EE3	34	10	      	PSHS    X       		
2351	6EE5	BD	6D73	      	JSR     OUTSPC  		
2352	6EE8	8E	604A	      	LDX     #CLSTL  		
2353	6EEB	C6	02	      	LDB     #2      		
2354	6EED	A6	80	DCLOP1	LDA     ,X+     		
2355	6EEF	8D	86	      	BSR     DB2ASC  		
2356	6EF1	5A		      	DECB    			
2357	6EF2	26	F9	      	BNE     DCLOP1  		
2358	6EF4	35	90	      	PULS    X,PC    		
2359				
2360				*----------
2361	6EF6			FNMIN 	EQU     *       		
2362				*clr buf
2363	6EF6	8E	605A	      	LDX     #FNAME+11		
2364	6EF9	C6	0B	      	LDB     #8+3    		
2365	6EFB	86	20	      	LDA     #SPC    		
2366	6EFD	A7	82	FNIN0 	STA     ,-X     		
2367	6EFF	5A		      	DECB    			
2368	6F00	26	FB	      	BNE     FNIN0   		
2369				
2370				*fname in
2371	6F02	34	24	      	PSHS    B,Y     		
2372	6F04	108E	604F	      	LDY     #FNAME  		
2373	6F08	C6	08	      	LDB     #8      		
2374	6F0A	8D	0D	      	BSR     LININ   		
2375	6F0C	86	20	      	LDA     #$20    		
2376	6F0E	A7	3F	      	STA     -1,Y    		
2377	6F10	35	A4	      	PULS    B,Y,PC  		
2378				*
2379				*--------------------
2380				*
2381	6F12	BD	FBB8	INOUTC	JSR     INCHA   		
2382	6F15	BD	FBBB	      	JSR     OUTCHA  		
2383	6F18	39		      	RTS     			
2384				*
2385				*--------------------
2386				* line input
2387				* input: B:count, Y:buf
2388				* output: FILBUF (terminate $00)
2389				* temp buf $043D - $053C
2390	6F19			LININ 	EQU     *       		
2391	6F19	0F	BF	      	CLR     $BF     		
2392	6F1B	BD	D807	      	JSR     LININP  		
2393				 
2394	6F1E	8E	043D	      	LDX     #$043D  		
2395	6F21	A6	80	LINLOP	LDA     ,X+     		
2396	6F23	A7	A0	      	STA     ,Y+     		
2397	6F25	5A		      	DECB    			
2398	6F26	27	03	      	BEQ     LEND    		
2399	6F28	4D		      	TSTA    			
2400	6F29	26	F6	      	BNE     LINLOP  		
2401	6F2B	39		LEND  	RTS     			
2402				
2403				*
2404				**************************************************
2405				*========== parameter ==========
2406	6F2C	40		CMD0  	FCB     $40,$00,$00,$00,$00,$95	'@		
2407	6F32	41		CMD1  	FCB     $41,$00,$00,$00,$00,$FF	'A		
2408	6F38	51		CMD17 	FCB     $51,$00,$00,$00,$00,$FF	'Q		
2409	6F3E	58		CMD24 	FCB     $58,$00,$00,$00,$00,$FF	'X		
2410	6F44	48		CMD8  	FCB     $48,$00,$00,$01,$AA,$87	'H		
2411	6F4A	7A		CMD58 	FCB     $7A,$00,$00,$00,$00,$FF	'z		
2412	6F50	77		CMD55 	FCB     $77,$00,$00,$00,$00,$FF	'w		
2413	6F56	69		ACMD41	FCB     $69,$40,$FF,$80,$00,$FF	'i		
2414	6F5C	49		CMD9  	FCB     $49,$00,$00,$00,$00,$FF	'I		
2415				*
2416	6F62	43  		MCMD0 	FCC     /CMD0/,CR,LF		
2417	6F68	04		      	FCB     4       		
2418	6F69	43  		MCMD8 	FCC     /CMD8/,CR,LF		
2419	6F6F	04		      	FCB     4       		
2420	6F70	43  		MCMD58	FCC     /CMD58/,CR,LF		
2421	6F77	04		      	FCB     4       		
2422	6F78	43  		MCMD55	FCC     /CMD55/,CR,LF		
2423	6F7F	04		      	FCB     4       		
2424	6F80	41  		MCMD41	FCC     /ACMD41/,CR,LF		
2425	6F88	04		      	FCB     4       		
2426	6F89	43  		MCMD9 	FCC     /CMD9/,CR,LF		
2427	6F8F	04		      	FCB     4       		
2428				*
2429	6F90	0D  		MSMENU1	FCC     CR,LF,CR,LF,/Main MENU/		
2430	6F9D	0D  		      	FCC     CR,LF,/F)iles, L)oad, saveB)asic, saveM)code,  K)ill, reS)etSD, O)ption, Q)uit: /		
2431	6FE8	04		      	FCB     4       		
2432	6FE9	0D  		MSMENU2	FCC     CR,LF,CR,LF,/Option  MENU/		
2433	6FF9	0D  		      	FCC     CR,LF,/1:Read Sct, 2:Disp SD data, 3:Disp MBR, 4:Disp BPB, 5:Disp FAT, 0:Return: /		
2434	7045	04		      	FCB     4       		
2435	7046	53  		MSSCT 	FCC     /SctNo: /		
2436	704D	04		      	FCB     4       		
2437	704E	0D  		MSSD0 	FCC     CR,LF,/SD Card/		
2438	7057	04		      	FCB     4       		
2439	7058	0D  		MSSD1 	FCC     CR,LF,/SDHC Card/		
2440	7063	04		      	FCB     4       		
2441	7064	0D  		MSINIT	FCC     CR,LF,CR,LF,/SD Card setting.../		
2442	707A	04		      	FCB     4       		
2443	707B	53  		MERR  	FCC     /Setting error!/,CR,LF		
2444	708B	04		      	FCB     4       		
2445	708C	49  		MSERR 	FCC     /Input error!/,CR,LF		
2446	709A	04		      	FCB     4       		
2447	709B	0D  		MSOFS 	FCC     CR,LF,/Sector no is:/		
2448	70AA	04		      	FCB     4       		
2449	70AB	0D  		MSBPB 	FCC     CR,LF,/ BPB: /		
2450	70B3	04		      	FCB     4       		
2451	70B4	0D  		MSFAT 	FCC     CR,LF,/ FAT: /		
2452	70BC	04		      	FCB     4       		
2453	70BD	0D  		MSDIR 	FCC     CR,LF,/ DIR: /		
2454	70C5	04		      	FCB     4       		
2455	70C6	0D  		MSCL2 	FCC     CR,LF,/ 1stCLUSTER: /		
2456	70D5	04		      	FCB     4       		
2457	70D6	0D  		MSINFN	FCC     CR,LF,CR,LF,/ FileName: /		
2458	70E5	04		      	FCB     4       		
2459	70E6	0D  		MSMSV 	FCC     CR,LF,CR,LF,/ FileName & Param: /		
2460	70FD	04		      	FCB     4       		
2461	70FE	0D  		MSLDNG	FCC     CR,LF,/ Loading /		
2462	7109	04		      	FCB     4       		
2463	710A	0D  		MSWTNG	FCC     CR,LF,/ Writing /		
2464	7115	04		      	FCB     4       		
2465	7116	0D  		MSLDED	FCC     CR,LF,/ Load end./		
2466	7122	04		      	FCB     4       		
2467	7123	0D  		MSWTED	FCC     CR,LF,/ Write end./		
2468	7130	04		      	FCB     4       		
2469	7131	0D  		MSNOFL	FCC     CR,LF,/ Not exist!/		
2470	713E	04		      	FCB     4       		
2471	713F	0D  		MSNXTP	FCC     CR,LF,"Next page (SP:Next): "		
2472	7156	04		      	FCB     4       		
2473	7157	3E  		MSOVR 	FCC     />64k/  		
2474	715B	04		      	FCB     4       		
2475	715C	0D  		MSKILL	FCC     CR,LF," Kill OK?(Y/N): "		
2476	716E	04		      	FCB     4       		
2477	716F	0D  		MSEXST	FCC     CR,LF," Exist! Over Write?(Y/N): "		
2478	718B	04		      	FCB     4       		
2479	718C	0D  		MSMCOF	FCC     CR,LF," Offset -$2000?(Y/N): "		
2480	71A4	04		      	FCB     4       		
2481	71A5	0D  		MSMCAS	FCC     CR,LF," Store ADR,SIZE: "		
2482	71B8	04		      	FCB     4       		
2483				**************************************************
2484				
2485					END   	START   		

0 error(s),  0 warning(s) is detected.

Label	address
ABLOP 	69D3	ACMD41	6F56	AD1   	6DF8	AD2   	6E09	AD3   	6E13
AD4   	6E19	ADD0  	6C3E	ADD1  	6C4C	ADD2  	6C54	ADD3  	6C5C
ADD40H	6C3C	ADD42 	6DF2	ADX0  	6C2D	ADX1  	6C33	ADX2  	6C37
ADX3  	6C3B	APLUSB	6A07	ASC2BIN	6896	ASC411	6218	ASCMD41	620B
BASADP	0033	BASAEP	0035	BASEXP	605D	BI21  	6D4F	BI22  	6D55
BUSY  	6BA5	CALCHC	6D15	CALCSD	6D0A	CALLOP	6A3D	CEND  	66D0
CKRS  	6B9B	CL1   	6D9F	CLEND 	6DAF	CLLOP 	6DAA	CLOP  	6D7D
CLRDIR	6821	CLSTH 	6048	CLSTL 	604A	CMD0  	6F2C	CMD1  	6F32
CMD17 	6F38	CMD24 	6F3E	CMD55 	6F50	CMD58 	6F4A	CMD8  	6F44
CMD9  	6F5C	CMPEND	66EC	CMPFN 	66D1	CMPLOP	66D9	CNT   	604C
CNV1  	68E6	CNV2  	68F2	CNVBUF	607F	CNVINT	6631	CNVLOP	6631
CNVSUB	68DE	CR    	000D	CSRON 	FBF7	CVBEND	6DEC	CVBIN 	6DDA
CVERR 	6DEF	CVT1  	6DB8	CVTLEN	6067	DB2   	6E86	DB2ASC	6E77
DBLOP 	6E7D	DCLOP1	6EED	DELMK 	00E5	DIRENT	601F	DIRGET	698A
DIROFS	605B	DLOP1 	696C	DPGNO 	605A	DSEND 	6EDE	DSLOP1	6EAD
DSLOP2	6EC6	DSPB1 	6CA1	DSPB2 	6CA3	DSPB3 	6CB4	DSPBI0	6D3B
DSPBI2	6D5F	DSPBIN	6D35	DSPBPB	63E2	DSPBUF	6C97	DSPC1 	6473
DSPCKE	6433	DSPCLS	6EE3	DSPDIR	6406	DSPED 	6989	DSPEND	64A9
DSPFAT	63F4	DSPFL0	6412	DSPFL1	6423	DSPFL2	643D	DSPFL3	643F
DSPFL4	644E	DSPFL5	6491	DSPFL6	649D	DSPMBR	638E	DSPSDDAT	62FE
DSPSIZ	6E92	DSPYMD	6E33	DSS1  	6EA0	DSS12 	6EB6	DSS13 	6EBB
DSS14 	6EC4	DSS2  	6ECF	DSS21 	6ED2	DSS3  	6ED6	DYMD1 	6E45
DYMD2 	6E54	EEND  	6DD9	EREND0	6DD2	EREND1	6DD4	ESC   	001B
EXIST 	694B	EXSTFL	6065	FILBUF	6083	FILL  	6C24	FILOP 	6C26
FILSIZ	6046	FIXPTR	C730	FMDAT 	02FA	FNAME 	604F	FNIN0 	6EFD
FNMIN 	6EF6	GET1  	6399	GET2  	639B	GET8CH	6D79	GETBPB	63C9
GETD1 	6CD5	GETDAT	6CD1	GETFDT	66EE	GETMBR	63AC	GR00  	6185
GR2580	6245	GR2581	625C	GR2582	625E	GR410 	6220	GR550 	6201
GR580 	61D7	GR581 	61E1	GR582 	61E3	GR80  	61A7	GR81  	61B9
GR90  	6311	GR91  	631D	GTBLOP	63D4	GTF1  	670D	GTF2  	6710
ILOP1 	6281	INCHA 	FBB8	INCX4 	6C2D	INEND 	6D8B	INIT  	60C7
INL10 	6647	INL11 	666B	INL12 	66B2	INL2  	6677	INLOP 	6638
INOUTC	6F12	INPBUF	6077	INPFLDAT	687C	INSCT 	6CEB	ISTT  	616B
KILEND	67B8	KILFILE	6764	KILSUB	677D	KL1   	67A2	KL2   	67B0
LD1   	6740	LD10  	65AC	LD2   	6754	LD3   	64CF	LD41  	64F4
LD5   	650D	LD8   	654F	LD80  	6594	LD81  	6598	LD82  	65A1
LD9   	65AA	LDE0  	65CF	LDE1  	65D5	LDEND 	65BC	LDFILE	64AA
LDFL0 	671C	LDFL1 	6728	LDFL5 	674C	LDFLE 	6763	LDLOP 	651D
LDNEND	65D9	LEND  	6F2B	LF    	000A	LINBUF	043D	LININ 	6F19
LININP	D807	LININT	FBF1	LINLOP	6F21	LINO1 	004B	LINO2 	033A
MAIN  	60A3	MATCH 	66E6	MCADP 	605F	MCAEP 	6061	MCEXP 	6063
MCFLG 	604D	MCMD0 	6F62	MCMD41	6F80	MCMD55	6F78	MCMD58	6F70
MCMD8 	6F69	MCMD9 	6F89	MEM2ED	6626	MEMSET	65E1	MEMSET2	6611
MENU  	60CA	MENU1 	60E4	MENU2 	60ED	MENU3 	60F6	MENU4 	60FF
MENU5 	6108	MENU6 	6110	MENU7 	6118	MERR  	707B	MKF1  	69A9
MKF2  	69AD	MKFLDT	6990	MM21  	6621	MS0   	65F8	MS1   	65FC
MS3   	660B	MSBPB 	70AB	MSCL2 	70C6	MSDIR 	70BD	MSERR 	708C
MSEXST	716F	MSFAT 	70B4	MSINFN	70D6	MSINIT	7064	MSKILL	715C
MSLDED	7116	MSLDNG	70FE	MSLOP 	65FE	MSMCAS	71A5	MSMCOF	718C
MSMENU1	6F90	MSMENU2	6FE9	MSMSV 	70E6	MSNOFL	7131	MSNXTP	713F
MSOFS 	709B	MSOVR 	7157	MSSCT 	7046	MSSD0 	704E	MSSD1 	7058
MSWTED	7123	MSWTNG	710A	NOEXST	694E	NOFEND	67C6	NOTM  	66EA
OPMEN10	614F	OPMEN6	612F	OPMEN7	6137	OPMEN8	613F	OPMEN9	6147
OPMENU	6120	OUTCHA	FBBB	OUTSPC	6D73	PBCTL 	FD9F	PBDAT 	FD9E
PCRLF 	6D68	PSEND 	6E30	PSLOP 	6E25	PSTRNG	6E23	RD1   	6C74
RD1SCT	6C61	RD2   	6C7B	RD3   	6C8B	RDLINO	9162	RDSCT 	637B
RDTOP 	6069	RESDAT	6008	RPT41 	61EC	RWBUF 	5E00	SC01  	617C
SC2581	623D	SC551 	61F9	SC581 	61CF	SC80  	619F	SC91  	6309
SCMD0 	6174	SCMD258	6230	SCMD55	61EC	SCMD58	61C2	SCMD8 	6192
SCTBPB	600A	SCTCLT	601A	SCTDIR	6012	SCTDSV	6016	SCTFAT	600E
SCTN0 	6004	SCTN1 	6005	SCTN2 	6006	SCTN3 	6007	SCTPCL	601E
SD1   	6272	SDERR 	6157	SDHC  	6009	SDINIT	615E	SDW1  	6B67
SDW2  	6B6F	SETCKH	6D2C	SETCKL	6D23	SETCL 	6936	SETFNM	6805
SETSCT	6CF4	SETSNO	63BC	SETX  	6925	SFATED	6941	SFLOP 	6D98
SKP1  	62B8	SKP2  	62F5	SNDD1 	6CBC	SNDDAT	6CB5	SNDDT1	6B8A
SPC   	0020	SRC0  	6905	SRC00 	6942	SRCDIR	6951	SRCDLM	6889
SRCFAT	68F9	SRCFL0	6960	SRCFL1	6963	SRCFL5	697E	SRCLOP	690E
SRDLM1	688B	SRLOP1	68A7	SRLOP2	68BF	START 	6000	STDATE	69CA
STTADR	6000	SVTOP 	606B	TPGFLG	604E	TRANS 	6C19	TRLOP 	6C1B
TXTADR	2000	TXTBUF	033C	VN    	6003	WFSIZ 	6042	WK0   	6075
WK1   	606D	WK2   	606F	WK3   	6071	WK4   	6073	WMDY  	603F
WR2   	6A78	WR3   	6AA2	WR4   	6AD8	WR5   	6ADA	WR6   	6ADC
WRB0  	67CD	WRB1  	67EB	WRBEND	6804	WRBFILE	67B9	WRDLOP	6BC3
WRDSET	6B47	WRDSKP	6BC8	WREND 	6AE7	WRF1  	6BFC	WRF2  	6BFF
WRF3  	6C15	WRFL1 	6812	WRFL11	681C	WRFL2 	6820	WRFLP2	680D
WRLOP 	6A88	WRM1  	6849	WRMEND	687B	WRMFILE	682F	WRS01 	6B1E
WRS1  	6B3F	WRS2  	6B27	WRS21 	6B30	WRS211	6B30	WRS3  	6B3E
WRSUB 	6AEE	WRTDIR	6BB0	WRTF0 	6A25	WRTF1 	6A2A	WRTF2 	6A2D
WRTF3 	6A54	WRTF4 	6A56	WRTFAT	6BDD	WRTFIL	6A19	WRTSD 	6B50
WRTSD1	6B53	WSPFL0	6BBB	WWCLOP	6AF8	

<-temp -1="" 008d="" 0093="" 00b4="" 00b6="" 00ce="" 011a="" 011d="" 0126="" 0129="" 012b="" 0133="" 01="" 0200="" 02="" 03="" 04="" 05="" 06="" 08="" 0:sd="" 0f="" 108e="" 10be="" 12="" 16="" 1774="" 1775="" 1776="" 1777="" 1778="" 1779="" 1780="" 1781="" 1782="" 1783="" 1784="" 1785="" 1786="" 1787="" 1788="" 1789="" 1790="" 1791="" 1792="" 1793="" 1794="" 1795="" 1796="" 1797="" 1798="" 1799="" 17="" 1800="" 1801="" 1802="" 1803="" 1804="" 1805="" 1806="" 1807="" 1808="" 1809="" 1810="" 1811="" 1812="" 1813="" 1814="" 1815="" 1816="" 1817="" 1818="" 1819="" 1820="" 1821="" 1822="" 1823="" 1824="" 1825="" 1826="" 1827="" 1828="" 1829="" 1830="" 1831="" 1832="" 1833="" 1834="" 1835="" 1836="" 1837="" 1838="" 1839="" 1840="" 1841="" 1842="" 1843="" 1844="" 1845="" 1846="" 1847="" 1848="" 1849="" 1850="" 1851="" 1852="" 1853="" 1854="" 1855="" 1856="" 1857="" 1858="" 1859="" 1860="" 1861="" 1862="" 1863="" 1864="" 1865="" 1866="" 1867="" 1868="" 1869="" 1870="" 1871="" 1872="" 1873="" 1874="" 1875="" 1876="" 1877="" 1878="" 1879="" 1880="" 1881="" 1882="" 1883="" 1884="" 1885="" 1886="" 1887="" 1888="" 1889="" 1890="" 1891="" 1892="" 1893="" 1894="" 1895="" 1896="" 1897="" 1898="" 1899="" 1900="" 1901="" 1902="" 1903="" 1904="" 1905="" 1906="" 1907="" 1908="" 1909="" 1910="" 1911="" 1912="" 1913="" 1914="" 1915="" 1916="" 1917="" 1918="" 1919="" 1920="" 1921="" 1922="" 1923="" 1924="" 1925="" 1926="" 1927="" 1928="" 1929="" 1930="" 1931="" 1932="" 1933="" 1934="" 1935="" 1936="" 1937="" 1938="" 1939="" 1940="" 1941="" 1942="" 1943="" 1944="" 1945="" 1946="" 1947="" 1948="" 1949="" 1950="" 1951="" 1952="" 1953="" 1954="" 1955="" 1956="" 1957="" 1958="" 1959="" 1960="" 1961="" 1962="" 1963="" 1964="" 1965="" 1966="" 1967="" 1968="" 1969="" 1970="" 1971="" 1972="" 1973="" 1974="" 1975="" 1976="" 1977="" 1978="" 1979="" 1980="" 1981="" 1982="" 1983="" 1984="" 1985="" 1986="" 1987="" 1988="" 1989="" 1990="" 1991="" 1992="" 1993="" 1994="" 1995="" 1996="" 1997="" 1998="" 1="" 1a="" 1e="" 1f="" 20="" 24="" 26="" 27="" 2="" 31="" 34="" 35="" 36="" 39="" 3="" 3a="" 3d="" 3f="" 40="" 44="" 48="" 4c="" 50="" 54="" 5a="" 5c="" 5e00="" 5e="" 6004="" 6008="" 6009="" 600e="" 6012="" 6016="" 601f="" 605a="" 605b="" 60="" 68="" 6b81="" 6b85="" 6b87="" 6b8a="" 6b8c="" 6b8f="" 6b91="" 6b93="" 6b95="" 6b98="" 6b9b="" 6b9e="" 6ba1="" 6ba3="" 6ba5="" 6ba8="" 6bab="" 6bad="" 6baf="" 6bb0="" 6bb3="" 6bb7="" 6bb9="" 6bbb="" 6bbe="" 6bc1="" 6bc3="" 6bc5="" 6bc6="" 6bc8="" 6bcb="" 6bce="" 6bd1="" 6bd5="" 6bd7="" 6bd9="" 6bdc="" 6bdd="" 6be0="" 6be3="" 6be5="" 6be7="" 6be9="" 6bec="" 6bef="" 6bf1="" 6bf3="" 6bf5="" 6bf8="" 6bfa="" 6bfc="" 6bff="" 6c00="" 6c02="" 6c04="" 6c06="" 6c08="" 6c0a="" 6c0d="" 6c0f="" 6c11="" 6c13="" 6c15="" 6c18="" 6c19="" 6c1b="" 6c1d="" 6c1f="" 6c20="" 6c22="" 6c24="" 6c26="" 6c28="" 6c29="" 6c2b="" 6c2d="" 6c2f="" 6c31="" 6c33="" 6c35="" 6c37="" 6c39="" 6c3b="" 6c3c="" 6c3e="" 6c40="" 6c42="" 6c44="" 6c46="" 6c48="" 6c4a="" 6c4c="" 6c4e="" 6c50="" 6c52="" 6c54="" 6c56="" 6c58="" 6c5a="" 6c5c="" 6c5d="" 6c5f="" 6c61="" 6c64="" 6c68="" 6c6a="" 6c6c="" 6c6f="" 6c71="" 6c74="" 6c76="" 6c78="" 6c79="" 6c7b="" 6c7d="" 6c80="" 6c82="" 6c84="" 6c87="" 6c8b="" 6c8d="" 6c90="" 6c92="" 6c94="" 6c96="" 6c97="" 6c9a="" 6c9d="" 6c="" 6ca1="" 6ca3="" 6ca5="" 6ca8="" 6caa="" 6cac="" 6cad="" 6caf="" 6cb2="" 6cb4="" 6cb5="" 6cb7="" 6cba="" 6cbc="" 6cbe="" 6cc0="" 6cc2="" 6cc5="" 6cc7="" 6cc9="" 6cca="" 6ccc="" 6ccd="" 6ccf="" 6cd1="" 6cd3="" 6cd5="" 6cd7="" 6cd8="" 6cd9="" 6cda="" 6cdc="" 6cdf="" 6ce0="" 6f38="" 6f39="" 70="" 7d="" 7f="" 80="" 81="" 84="" 86="" 88="" 89="" 8a="" 8b="" 8d="" 8e="" 96="" a0="" a6="" a7="" a:fill="" a="" abx="" ad="" add0="" add1="" add2="" add3="" add40h="" adda="" addb="" adr="" adx0="" adx1="" adx2="" adx3="" anda="" b1-="" b6="" b7="" b:cnt="" bcc="" beq="" bne="" bra="" bsr="" buf="" busy="" c6="" cb="" ckrs="" clr="" cluster="" cmd="" cmpa="" copy="" crch="" crcl="" cs:b0="L" d="" data="" decb="" df="" dir="" dirofs="" disp="" dpgno="" dspb1="" dspb2="" dspb3="" dspbin="" dspbuf="" e5="" ec="" ed="" equ="" exg="" f4="" f5="" f6="" f7="" f7cd="" f7f1="" f9="" fb="" fc="" fd9e="" fe="" ff3b="" ff77="" ff="" fill="" filop="" get="" getd1="" getdat="" inc="" incx4="" lbsr="" lda="" ldb="" ldd="" ldx="" ldy="" leay="" lsla="" lsra="" miso:b1="H(for" no="" nop="" of="" ora="" param="" pbdat="" pcrlf="" pia="" pshs="" puls="" rd1="" rd1sct="" rd2="" rd3="" read="" resdat="" response="" return="" rts="" save="" sct="" sd:2="" sdhc:4="" sdhc="" send="" setckh="" setckl="" setsno="" sndd1="" snddat="" snddt1="" src="" sta="" temp="" tfr="" to="" token="" trans="" trlop="" tst="" until="" wait="" wrdlop="" wrdskp="" wrf1="" wrf2="" wrf3="" wrtdir="" wrtfat="" wrtsd1="" wspfl0="" x40h="" y:dst="" y="">


私はこのカードを、FM-7用のプログラムを使い慣れたWindowsPC上のエディタで作成してFM-7に転送したり、逆に、FM-7上で動作しているプログラムをWindowsPCに保存したりするのに利用していますが、それなりに使えるツールではないかと感じています。
また、テストしてくださった知人のアイディアですが、SD上にフォルダがあってもFM-7では見えないのですが、逆にそれを利用して、フォルダ中にFM-7用のファイルを複数入れて(隠して)おき、必要な時にその中から必要なフィルをフォルダの外に出してFM-7で使用するという使い方も便利そうです。

使用法についての文章も修正しましたので、それらをまとめてOneDriveに上げておきます。


0 件のコメント:

コメントを投稿