0100 ;SAVE#D:DMPT3.M65 0110 ;-------------------- 0120 ; 0130 ;Memory disassembler 0140 ; 0150 ; by: Bryan Schappel 0160 ; 0170 ;-------------------- 0180 ; 0190 DISAMEM LDY #0 ;zero Y 0200 STY HXDC ;in hex 0210 STY BYTES 0220 JSR GETBYT ;get opcode 0230 BPL D.1 ;error? 0240 JMP D_OVER ;yes! 0250 ; 0260 D.1 STA OP ;save op 0270 LDY #0 ;zero Y 0280 FNDOP CMP OPCODE,Y ;is op in 0290 BEQ HAVOP ;the opcode 0300 INY ;table? 0310 CPY #151 ;151 yet? 0320 BNE FNDOP ;no. 0330 ; 0340 HAVOP STY Y2 ;save Y 0350 JSR ZBUF ;clear buffer 0360 LDA ADDR ;copy addr 0370 STA FR0 ;to FP 0380 LDA ADDR+1 0390 STA FR0+1 0400 LDX #23 ;pos. 23 0410 JSR COPYNUM ;copy it 0420 JSR ZFR ;clear FP 0430 LDA OP ;get op 0440 STA FR0 ;in FP 0450 LDX #28 ;pos 28 0460 JSR COPYNUM ;copy it 0470 LDA #'; 0480 STA IBUF+22 0490 LDY Y2 ;get Y 0500 CPY #151 ;legal instr? 0510 BNE N151 ;yes. 0520 ; 0530 LDY #7 ;copy 8 chars 0540 CP.B LDA POINTB,Y ;get char 0550 STA IBUF,Y ;put in buffer 0560 DEY ;decrease index 0570 BPL CP.B ;and loop 0580 JSR ZFR ;zap FR0 0590 LDY OP ;get the byte 0600 STY FR0 ;put in FR0 0610 JSR BIN2HEX ;make it hex 0620 LDA #1 ;force 1 byte 0630 STA NBYTE 0640 LDX #8 ;posit 8 0650 JSR SOME ;copy number 0660 JMP AEOL1 ;and add EOL. 0670 ; 0680 N151 LDX OFFSET,Y ;MNE offset 0690 LDY #0 ;copy out the 0700 ADMNE LDA MNE,X ;Mnemonic and 0710 STA IBUF+1,Y ;put in 0720 INX ;buffer. 0730 INY 0740 CPY #3 ;3 chars? 0750 BNE ADMNE ;no. 0760 STA NBYTE 0770 LDY Y2 ;restore Y 0780 LDA ITYPE,Y ;get Itype 0790 TAY ;transfer to Y 0800 LDA NBTAB,Y ;get # bytes for 0810 STA NBYTE ;this instr. 0820 TYA ;restore Acc. 0830 ASL A ;times 2 0840 TAY ;in Y 0850 LDA DCOMT,Y ;look up the 0860 STA DJSR+1 ;routine addr 0870 LDA DCOMT+1,Y ;an put in 0880 STA DJSR+2 ;JSR 0890 LDX NBYTE ;get # bytes 0900 DEX ;sub 1. 0910 BEQ DJSR ;if 0, skip! 0920 JSR GETBYT ;get next one 0930 BMI D_OVER ;oops, error. 0940 STA DTEMP ;save byte 0950 LDX NBYTE ;get count again 0960 DEX ;sub 2. 0970 DEX 0980 BEQ DJSR ;if 0, skip 0990 JSR GETBYT ;get 3rd byte 1000 BMI D_OVER ;oops, error. 1010 STA DTEMP+1 ;save this byte 1020 ; 1030 DJSR JSR $FFFF ;go command! 1040 AEOL1 LDY #39 ;now insert 1050 AEOL3 LDA IBUF,Y ;the EOL 1060 CMP #32 ;character 1070 BNE AEOL2 1080 DEY 1090 BPL AEOL3 1100 AEOL2 LDA #EOL 1110 STA IBUF+1,Y 1120 LDA #0 1130 STA IBUF+2,Y 1140 LDA ADDR ;now add the 1150 CLC ;number of 1160 ADC NBYTE ;byte to the 1170 STA ADDR ;adr pointer 1180 BCC AE1 ;to get next 1190 INC ADDR+1 ;instr addr. 1200 AE1 RTS ;bye. 1210 ; 1220 ;Disassembly Over 1230 ; 1240 D_OVER JSR ANY_LEFT ;send extra. 1250 INC SFLAG ;set swap flag 1260 JSR SEND_OUT ;write buffer 1270 LDX #$10 ;slam IOCB #1 1280 JSR CLOSE 1290 LDX #$20 ;slam IOCB #2 1300 JSR CLOSE 1310 PRINT ALL.DONE ;done mess. 1320 JSR GET_RET ;get a return 1330 JMP INTRO ;goto intro. 1340 ; 1350 ;Immediate Mode 1360 ; 1370 IMMED JSR LOBYTE ;insert LSB 1380 LDA #'# ;a '#' 1390 STA IBUF+5 ;in buffer 1400 JSR ZFR ;zap FR0 1410 LDA DTEMP ;get byte 1420 STA FR0 ;into FR0 1430 LDX #6 ;and add to the 1440 JMP COPYNUM ;output. 1450 ; 1460 NUMBR LDA #0 ;zero MSB 1470 STA DTEMP+1 1480 NUMBR2 LDA DTEMP ;put in FR0 1490 STA FR0 1500 LDA DTEMP+1 1510 STA FR0+1 1520 NUMBR3 LDX #6 ;# in pos. 6 1530 LDA # LAB 1560 STA INDR+1 1570 LDA LABELS? ;want labels? 1580 BNE GO_OUT ;nope. 1590 ; 1600 ;This is the Location Label 1610 ;search algorithm. The label 1620 ;data are stored as follows: 1630 ; 1640 ;hi nybble-byte 1 loc length 1650 ;lo nybble-byte 1 label length 1660 ;location hi,location lo, and 1670 ;the label name. 1680 ; 1690 LAB_SRCH LDY #0 ;zero index 1700 LDA (INDR),Y ;get a byte. 1710 BNE N_FF ;<>0 then cont. 1720 GO_OUT JMP COPYNUM ;just number 1730 ; 1740 N_FF PHA ;save byte 1750 AND #$0F ;get label len 1760 STA TMP1 ;save it. 1770 PLA ;get byte back 1780 LSR A ;shift it down 1790 LSR A 1800 LSR A 1810 LSR A 1820 STA ADD_ON ;save it 1830 INC ADD_ON ;add one. 1840 INY ;move up 2 1850 INY ;bytes. 1860 LDA (INDR),Y ;get addr lo 1870 STA LOC_S ;save it. 1880 CLC ;add on location 1890 ADC ADD_ON ;length & save. 1900 STA LOC_E 1910 DEY ;down index 1920 LDA (INDR),Y ;get addr hi 1930 STA LOC_S+1 ;save 1940 ADC #0 ;add carry 1950 STA LOC_E+1 ;and store. 1960 ; 1970 LDA DTEMP+1 ;instr hi 1980 CMP LOC_S+1 ;equal to lochi? 1990 BNE N.TST ;no. 2000 LDA DTEMP ;test lo 2010 CMP LOC_S 2020 BEQ D_CP ;exact match! 2030 ; 2040 N.TST LDA DTEMP+1 ;now we see if 2050 CMP LOC_E+1 ;the instr addr 2060 BEQ TST.L ;is in the range 2070 BCS GO_UP ;of the location 2080 TST.L LDA DTEMP 2090 CMP LOC_E 2100 BCS GO_UP 2110 ; 2120 LDA DTEMP+1 ;test hi 2130 CMP LOC_S+1 2140 BCC GO_OUT ;not in range 2150 LDA DTEMP ;test lo 2160 CMP LOC_S 2170 BCC GO_OUT ;not in range 2180 D_CP SEC ;calc actual 2190 SBC LOC_S ;offset for the 2200 STA ADD_ON ;+x add on. 2210 ; 2220 DEX ;posit 5 2230 LDY #2 ;start at pos 2 2240 C_CP INY ;up Y 2250 INX ;up X 2260 LDA (INDR),Y ;get label name 2270 STA IBUF,X ;from the table 2280 BPL C_CP ;and insert into 2290 AND #$7F ;disa line. 2300 STA IBUF,X 2310 LDA ADD_ON ;exact match? 2320 BNE PLUS ;no. 2330 RTS ;so long. 2340 ; 2350 PLUS LDA #'+ ;put in a '+' 2360 STA IBUF+1,X 2370 INX 2380 INX 2390 JSR ZFR ;zap FR0 2400 LDA ADD_ON ;make offset to 2410 STA FR0 ;a decimal # 2420 INC HXDC 2430 JSR COPYNUM ;insert number 2440 DEC HXDC ;force hex 2450 RTS ;and leave. 2460 ; 2470 GO_UP LDA INDR ;get the label 2480 CLC ;pointer and 2490 ADC TMP1 ;add on the len 2500 STA INDR ;of the label so 2510 LDA INDR+1 ;we can search 2520 ADC #0 ;more. 2530 STA INDR+1 2540 JMP LAB_SRCH ;loop! 2550 ; 2560 ;Zero page 2570 ; 2580 ZPAG JSR LOBYTE ;do LSB 2590 JMP NUMBR ;add arg 2600 ; 2610 ;Zero page,X 2620 ; 2630 ZPAGX JSR LOBYTE ;LSB 2640 JSR NUMBR ;add arg 2650 ADDX2 LDY #1 ;just ,X 2660 ADDX INX ;up X 2670 ADDX3 LDA COMMAX,Y ;copy the 2680 STA IBUF+1,X ;,X into 2690 DEX ;the buffer 2700 DEY 2710 BPL ADDX3 2720 RTS ;done. 2730 ; 2740 ;Absolute 2750 ; 2760 ABSOL JSR LOBYTE ;LSB 2770 JSR HIBYTE ;MSB 2780 JMP NUMBR2 ;add arg 2790 ; 2800 ;Absolute ,X 2810 ; 2820 ABSOLX JSR ABSOL ;set up absol 2830 JMP ADDX2 ;copy in ,X 2840 ; 2850 ;Absolute ,Y 2860 ; 2870 ABSOLY JSR ABSOL ;do absol 2880 ACY LDA #$2C ;a comma 2890 STA IBUF+1,X ;in buf 2900 LDA #'Y ;a Y 2910 STA IBUF+2,X ;in buf 2920 RTS ;done 2930 ; 2940 ;Indirect X 2950 ; 2960 INDX LDA #0 ;no MSB 2970 STA DTEMP+1 2980 JSR LOBYTE ;do LSB 2990 JSR OPENP ;add open '(' 3000 INX ;up X 3010 LDY #2 ;3 bytes 3020 BNE ADDX ;copy ',X)' 3030 ; 3040 ;Indirect Y 3050 ; 3060 INDY LDA #0 ;no MSB 3070 STA DTEMP+1 3080 JSR LOBYTE ;do LSB 3090 JSR OPENP ;left ( 3100 LDY #2 ;copy in the 3110 ADDY LDA COMMAY,Y ;'),Y' 3120 STA IBUF+1,X 3130 INX 3140 DEY 3150 BPL ADDY 3160 RTS ;done 3170 ; 3180 ;Accumulator Mode 3190 ; 3200 ACCUM LDA #'A ;an 'A' 3210 STA IBUF+5 ;in buffer 3220 RTS ;done 3230 ; 3240 ;Branch instructions 3250 ; 3260 RELA JSR LOBYTE ;put LSB 3270 INC NBYTE ;make 3 byte 3280 JSR ZFR ;zero FR0 3290 LDA DTEMP ;get operand 3300 BPL NOBACK ;not inverse 3310 AND #$7F ;mask inverse 3320 EOR #$7F ;flip it 3330 CLC ;add a 1 3340 ADC #1 3350 STA DINS+1 ;save it 3360 JMP TOFP ;done 3370 NOBACK STA DINS+1 3380 TOFP LDA DTEMP ;operand 3390 BPL FORWARD ;bran forward 3400 LDA ADDR ;now subtract 3410 SEC ;from addr 3420 SBC DINS+1 ;to find out 3430 STA FR0 ;where this 3440 LDA ADDR+1 ;branch goes. 3450 SBC #0 3460 STA FR0+1 3470 JMP BACK ;done. 3480 FORWARD CLC ;add # to 3490 ADC ADDR ;addr to calc 3500 STA FR0 ;forward branch 3510 LDA ADDR+1 3520 ADC #0 3530 STA FR0+1 3540 BACK LDA #2 ;now add a 2 3550 CLC ;to skip the 3560 ADC FR0 ;instruction 3570 STA DTEMP ;address 3580 STA FR0 3590 LDA FR0+1 3600 ADC #0 3610 STA DTEMP+1 3620 STA FR0+1 3630 JSR NUMBR3 ;add number 3640 DEC NBYTE ;make 2 bytes 3650 ; 3660 ;Implied Mode 3670 ; 3680 IMP RTS ;do nothing 3690 ; 3700 ;Indirect instructions 3710 ; 3720 INDI JSR LOBYTE ;copy in LSB 3730 JSR HIBYTE ;and MSB 3740 JSR OPENP ;do open ( 3750 LDA #') ;and add 3760 STA IBUF+1,X ;closing one 3770 RTS ;leave. 3780 ; 3790 ;Zero page ,Y 3800 ; 3810 ZPAGY JSR LOBYTE ;do LSB 3820 JSR NUMBR ;add arg 3830 JMP ACY ;copy ,Y 3840 ; 3850 ;Insert LSB 3860 ; 3870 LOBYTE JSR ZFR ;zero FR0 3880 LDA DTEMP ;do lobyte 3890 STA FR0 3900 LDX #31 ;at pos. 10 3910 JMP COPYNUM ;do it! 3920 ; 3930 ;Insert MSB 3940 ; 3950 HIBYTE JSR ZFR ;no FR0 3960 LDA DTEMP+1 ;hibyte 3970 STA FR0 ;in FP 3980 LDX #34 ;at pos. 14 3990 JMP COPYNUM ;copy it. 4000 ; 4010 ;Add Open ( 4020 ; 4030 OPENP LDA #'( ;open ( 4040 STA IBUF+5 ;in buffer 4050 JMP NUMBR2 ;add number 4060 ; 4070 ;Copy number to string 4080 ; 4090 COPYNUM DEX 4100 STX CNTLO ;save X 4110 LDA HXDC ;hex/dec? 4120 BEQ INHEX ;have Hex. 4130 JSR IFP ;to FP 4140 JSR FASC ;to ASC 4150 LDX CNTLO ;get index 4160 LDY #$FF ;and copy 4170 CNLOOP INY ;the number 4180 INX 4190 LDA (INBUFF),Y 4200 STA IBUF,X 4210 BPL CNLOOP 4220 AND #$7F ;mask bit 7 4230 STA IBUF,X 4240 RTS ;leave 4250 ; 4260 INHEX JSR BIN2HEX ;make hex 4270 LDX CNTLO ;get pos 4280 INX ;up it. 4290 CPX #23 4300 BEQ ALL ;if 25 do all 4310 CPX #21 ;is X => 30? 4320 BCC ARG ;yes. 4330 SOME LDA LBUFF+2 ;no. just copy 4340 STA IBUF,X ;the LSB part 4350 INX ;of the Hex 4360 LDA LBUFF+3 ;number. 4370 STA IBUF,X 4380 RTS ;bye. 4390 ARG LDA #'$ ;install a '$' 4400 STA IBUF,X 4410 INX ;up X 4420 LDA NBYTE ;Get # of bytes 4430 CMP #2 ;is it 2? 4440 BEQ SOME ;no. 4450 ALL LDY #0 ;no. copy it 4460 ALOOP LDA LBUFF,Y ;all to buf 4470 STA IBUF,X 4480 INX 4490 INY 4500 CPY #4 ;done yet? 4510 BNE ALOOP ;nope. 4520 DEX ;dec X 4530 RTS ;so long. 4540 ; 4550 ;Binary to hexadecimal 4560 ; 4570 BIN2HEX LDY #0 ;buf indx=0 4580 LDX #1 ;do 2 nums 4590 NXTBYT STX X1 ;save it 4600 LDA #240 ;get HI bits 4610 AND FR0,X 4620 LSR A ;divide by 16 4630 LSR A 4640 LSR A 4650 LSR A 4660 TAX ;to index 4670 LDA HXTAB,X ;get char 4680 STA LBUFF,Y ;and save 4690 INY ;up buf index 4700 LDX X1 ;get X back 4710 LDA #15 ;now LO bits 4720 AND FR0,X 4730 TAX 4740 LDA HXTAB,X ;get char and 4750 STA LBUFF,Y ;put in buffer 4760 INY ;up buf indx 4770 LDX X1 ;get X 4780 DEX ;down by one 4790 BPL NXTBYT ;done? 4800 RTS ;yes. bye. 4810 ; 4820 ;Fill buffer with blanks 4830 ; 4840 ZBUF LDA #32 ;space 4850 LDX #39 ;do 40 spaces 4860 ZLOOP STA IBUF,X ;in buf 4870 DEX ;down count 4880 BPL ZLOOP ;go again 4890 RTS ;bye. 4900 ; 4910 ;Zero FR0 4920 ; 4930 ZFR LDA #0 4940 STA FR0 4950 STA FR0+1 4960 RTS 4970 ; 4980 ;Open Input File 4990 ; 5000 OPENIN LDX #$10 ;slam IOCB #1 5010 JSR CLOSE 5020 LDA TYPE ;get disa type 5030 BEQ O_FILE ;if 0, then file 5040 JSR UP.READ ;read 1st sector 5050 PHP ;save status 5060 LDA #$80 ;default size 5070 STA SECBYTES 5080 LDA S.SIZE ;get actual 5090 CMP #$80 ;is 128 bytes? 5100 BEQ O.SO ;yes. 5110 LDA DSBUF+127 ;get data byte 5120 STA SECBYTES ;count. 5130 O.SO PLP ;pull status 5140 BMI INERR ;oops, error. 5150 RTS ;so long. 5160 O_FILE LDX #$10 ;IOCB #1 5170 LDA #3 ;open command 5180 STA ICCOM,X 5190 LDA # SRCFILE ;name. 5220 STA ICBAH,X 5230 LDA #4 ;read only. 5240 STA AUX1,X 5250 LDA #0 5260 STA AUX2,X 5270 STA BYTCNT ;zero byte cnt 5280 STA BYTCNT+1 5290 JSR CIOV ;open it! 5300 BMI INERR ;oops. 5310 JSR GET.TWO ;get file header 5320 BMI INERR ;empty file! 5330 JSR CHKFF ;is it binary? 5340 BNE CIO.B ;no! 5350 LDY #1 ;signal good 5360 RTS 5370 CIO.B LDY #152 ;not binary file 5380 ; 5390 ;Input error 5400 ; 5410 INERR CPY #136 ;EOF? 5420 BNE PI ;no, show error 5430 LDA #0 ;kill instr 5440 STA BYTES 5450 JMP D_OVER ;and exit. 5460 PI JSR F_ERR 5470 PRINT IN_P ;print INPUT 5480 PRINT IBUF 5490 PRINT ALL.DONE+10 5500 JSR GET_RET 5510 JMP D_OVER 5520 ; 5530 ;Open Output file 5540 ; 5550 OPENOUT LDX #$20 ;close #2 5560 JSR CLOSE 5570 LDX #$20 5580 LDA #3 ;open command 5590 STA ICCOM,X 5600 LDA # DSTFILE ;filename. 5630 STA ICBAH,X 5640 LDA #8 ;write only 5650 STA AUX1,X 5660 LDA #0 ;no lines. 5670 STA LINES 5680 STA AUX2,X 5690 LDA # BIGBUF ;buffer. 5720 STA BUFPNT+1 5730 LDA DSTFILE ;is destn to 5740 CMP #'E ;the screen? 5750 BNE C.CIO ;no, call cio 5760 LDY #1 ;show good. 5770 RTS 5780 C.CIO JMP CIOV ;open it! 5790 ; 5800 ;Close IOCB 5810 ; 5820 CLOSE LDA #12 ;close command 5830 STA ICCOM,X 5840 JMP CIOV ;slam! 5850 ; 5860 ;CIO get byte routine 5870 ; 5880 CIOGET LDX #$10 ;on ch #1 5890 LDA #7 ;get bytes 5900 STA ICCOM,X 5910 LDA #0 ;no length says 5920 STA ICBLL,X ;put byte in the 5930 STA ICBLH,X ;accumulator. 5940 JMP CIOV ;get it! 5950 ; 5960 ;Get byte routine 5970 ; 5980 GETBYT LDA TYPE ;get type. 5990 BEQ G_FILE ;if 0, from file 6000 LDX GETPTR ;get index 6010 CPX SECBYTES ;at end? 6020 BEQ NX.SEC ;yes. 6030 LDA DSBUF,X ;get byte. 6040 INC GETPTR ;bump pointer. 6050 LDY #1 ;signal good. 6060 RTS ;bye. 6070 ; 6080 NX.SEC LDA #1 ;start on byte 1 6090 STA GETPTR 6100 LDA S.SIZE ;trace links? 6110 CMP #125 6120 BNE F.SEC ;no. 6130 LDA DSBUF+125 ;get the link 6140 AND #3 ;hi 6150 STA SECH ;get the link 6160 LDA DSBUF+126 ;lo 6170 STA SECL ;at EOF? 6180 ORA SECH 6190 BNE C.READ ;no. 6200 S.EOF LDY #136 ;signal error. 6210 RTS 6220 C.READ JSR UP.READ ;grab sector 6230 PHP ;save status 6240 LDA DSBUF+127 ;get # data 6250 STA SECBYTES ;bytes. 6260 LDA DSBUF ;get data byte 6270 PLP ;pull status 6280 RTS ;and leave. 6290 ; 6300 F.SEC INC SECL ;sec=sec+1 6310 BNE FS.1 6320 INC SECH 6330 FS.1 JSR UP.READ ;grab sector 6340 PHP ;save status 6350 LDA DSBUF ;get data 6360 PLP ;pull status 6370 RTS ;and leave. 6380 ; 6390 UP.READ LDA SECCNT ;any sectors 6400 ORA SECCNT+1 ;left? 6410 BEQ S.EOF ;no! Done. 6420 LDA SECCNT ;subtract 1 6430 SEC ;from the sector 6440 SBC #1 ;count. 6450 STA SECCNT 6460 LDA SECCNT+1 6470 SBC #0 6480 STA SECCNT+1 6490 JMP READIT ;read sector. 6500 ; 6510 G_FILE LDA BYTCNT ;any bytes 6520 ORA BYTCNT+1 ;left? 6530 BEQ HEADERS ;no, get more 6540 LDA BYTCNT ;subtract 1 6550 SEC ;from the count 6560 SBC #1 6570 STA BYTCNT 6580 LDA BYTCNT+1 6590 SBC #0 6600 STA BYTCNT+1 6610 INC BYTES ;up byte count 6620 JMP CIOGET ;get the byte 6630 ; 6640 ;Send remaining instr bytes 6650 ; 6660 ANY_LEFT LDA BYTES ;any extra? 6670 BEQ N.LF ;no. 6680 LDY #151 ;bad opcode. 6690 JSR HAVOP ;format .BYTE 6700 JSR PRINT.IT ;send it out. 6710 LDA DTEMP ;prepare next 6720 STA OP 6730 DEC BYTES ;down count 6740 BNE ANY_LEFT ;and loop 6750 N.LF RTS ;bye. 6760 H_ERR JMP INERR ;input error 6770 ; 6780 ;Pull file headers 6790 ; 6800 HEADERS JSR ANY_LEFT ;send extra 6810 JSR GET.TWO ;grab 2 more 6820 BMI H_ERR ;oops. 6830 LDY #29 ;copy message 6840 C.ST LDA STEN,Y ;to buffer 6850 STA IBUF,Y 6860 DEY 6870 BPL C.ST 6880 JSR CHKFF ;are they $FF's? 6890 BNE NOT.FF ;no. 6900 JSR GET.TWO ;get 2 more 6910 BMI H_ERR ;oops. 6920 NOT.FF LDA HXL ;save the load 6930 STA ADDR ;address and 6940 STA FR0 ;convert it to 6950 LDA HXH ;hex for the 6960 STA ADDR+1 ;output file. 6970 STA FR0+1 6980 JSR BIN2HEX ;make hex. 6990 LDX #4 ;copy it in 7000 JSR ALL 7010 JSR GET.TWO ;grab 2 more 7020 BMI H_ERR ;oops. 7030 LDA HXL ;make this # 7040 STA FR0 ;into hex for 7050 SEC ;output also. 7060 SBC ADDR ;We also calc 7070 STA BYTCNT ;the length of 7080 LDA HXH ;the segment. 7090 STA FR0+1 7100 SBC ADDR+1 7110 STA BYTCNT+1 7120 INC BYTCNT ;add 1 to the 7130 BNE N.OV ;segment len. 7140 INC BYTCNT+1 7150 N.OV JSR BIN2HEX ;make hex 7160 LDX #16 ;pos 16 7170 JSR ALL ;copy it 7180 JSR PUTCR ;line feed 7190 PLA ;pull return 7200 PLA 7210 JSR PRINT.IT ;print it 7220 JMP DISAMEM ;go again. 7230 ; 7240 ;Grab two file bytes 7250 ; 7260 GET.TWO JSR CIOGET 7270 BMI G2ERR 7280 STA HXL 7290 JSR CIOGET 7300 STA HXH 7310 G2ERR RTS 7320 ; 7330 ;Print The output 7340 ; 7350 PRINT.IT PRINT IBUF ;to E: 7360 LDY #0 ;wait 5 jiffies 7370 STY RTCLOK 7380 WT_LP LDA RTCLOK 7390 CMP #5 7400 BCC WT_LP 7410 LDA DSTFILE ;to E: only? 7420 CMP #'E 7430 BNE PR.LP ;no. 7440 RTS ;yes. 7450 PR.LP LDA IBUF,Y ;move iobuf to 7460 STA (BUFPNT),Y ;big buffer 7470 CMP #EOL 7480 BEQ PR.DN 7490 INY 7500 BNE PR.LP 7510 PR.DN INY ;now we add Y+1 7520 TYA ;to the pointer 7530 CLC ;so we are ready 7540 ADC BUFPNT ;next time 7550 STA BUFPNT 7560 LDA BUFPNT+1 7570 ADC #0 7580 STA BUFPNT+1 7590 INC LINES 7600 LDA LINES ;get line count 7610 CMP #200 ;200 lines? 7620 BNE SND.LV ;no. 7630 ; 7640 ;Send the buffer out 7650 ; 7660 SEND_OUT LDA LINES ;any lines? 7670 BNE SND.IT ;yes. 7680 SND.LV RTS ;so long. 7690 SND.IT LDA #11 ;put bytes 7700 LDX #$20 7710 STA ICCOM,X 7720 LDA # BIGBUF 7750 STA ICBAH,X 7760 LDA BUFPNT ;calc the len 7770 SEC ;of the buffer 7780 SBC # BIGBUF 7820 STA ICBLH,X 7830 LDA # BIGBUF 7870 STA BUFPNT+1 7880 JSR TEST_DRV ;test drives 7890 BNE SND.OUT ;not equal 7900 PRINT INS_DST ;ask for 7910 JSR GET_RET ;disk swap. 7920 LDX #$20 7930 SND.OUT JSR CIOV ;write out 7940 BMI OUT_ERR ;oops. 7950 JSR TEST_DRV ;swap again? 7960 BNE SND.OV ;no. 7970 LDA SFLAG ;test flag 7980 BNE SND.OV ;no swap! 7990 PRINT INS_SRC ;prompt it 8000 JSR GET_RET 8010 SND.OV LDY #1 ;signal good. 8020 RTS 8030 ; 8040 ;Test srcdrv vs. dstdrv 8050 ; 8060 TEST_DRV LDA DESDRV ;get dest 8070 CMP SRCDRV ;is = source? 8080 RTS ;bye. 8090 ; 8100 ;Output error handler 8110 ; 8120 OUT_ERR JSR F_ERR ;format err# 8130 PRINT OUTP ;print OUTPUT 8140 LDX #$20 ;close #2 8150 JSR CLOSE 8160 PRINT IBUF ;print err# 8170 PRINT ALL.DONE+10 8180 JSR GET_RET ;get return 8190 JMP INTRO ;so long. 8200 ; 8210 ;Get a RETURN 8220 ; 8230 GET_RET JSR GETKEY ;get key 8240 CMP #EOL ;is it EOL? 8250 BNE GET_RET ;no. 8260 LDX #$20 8270 RTS 8280 ; 8290 ;Check if HXL/HXH=$FF 8300 ; 8310 CHKFF LDA HXL ;get byte 1 8320 CMP #$FF ;is it $FF? 8330 BNE CHKLV ;no. 8340 CMP HXH ;is #2=#1? 8350 CHKLV RTS