Home » CEEFAX disks » telesoftware5.adl » 26-02-88/T\SWR18
26-02-88/T\SWR18
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
Tape/disk: | Home » CEEFAX disks » telesoftware5.adl |
Filename: | 26-02-88/T\SWR18 |
Read OK: | ✔ |
File size: | 3823 bytes |
Load address: | 0000 |
Exec address: | FFFFFFFF |
Duplicates
There is 1 duplicate copy of this file in the archive:
- CEEFAX disks » telesoftware10.adl » 04-11-88/T\SWR18
- CEEFAX disks » telesoftware5.adl » 26-02-88/T\SWR18
File contents
Mastering Sideways ROM & RAM - Module 18 - Rom Filing System ------------------------------------------------------------ The rom filing system (RFS) is available on all BBC microcomputers with 1.0 operating system, or later. The RFS is selected by typing *ROM and uses data stored in paged roms or in serially accessed roms associated with the Acorn speech system. The RFS is similar to a read-only tape filing system but with the data stored in SWR instead of on cassettes. Programs stored in the RFS can only be run by loading them from the filing system into the user memory of the computer. There are two service calls, &0D and &0E, associated with the RFS. Service call &0D can be demonstrated with the service call trace program introduced in Module 2. The RFS initialisation call (&0D) is issued by the MOS when the RFS is active and a filing system command has been used. It gives an active rom the opportunity to inform the MOS that it contains RFS files, and the start address of those files. On entry, the Y register contains 15 minus the rom number of the next rom to be scanned. If this so called adjusted rom number is less that the number of the rom receiving the call, the call should be ignored because it has been processed earlier. Otherwise, the adjusted rom number for the current rom should be stored in &F5, the start address of the RFS data should be stored in the RFS address vector at locations &F6 and &F7, and the accumulator should be reset to zero before returning control to the MOS. This rather complicated response to service call &0D is summarised in figure 18.1 in which "file" marks the address at which the RFS formatted files start. PHA \ save accumulator CMP #13 \ is it service call &0D? BNE fourteen \ branch if not &0D TYA \ Y stores adjusted rom number EOR #&0F \ calculate (15-adjusted rom number) CMP &F4 \ compare with this rom number BCC out \ return if less LDA #file MOD 256 \ low byte of first RFS file STA &F6 \ store in RFS vector LDA #file DIV 256 \ high byte of first RFS file STA &F7 \ store in RFS vector LDA &F4 \ load this rom number EOR #&0F \ calculate adjusted rom number STA &F5 \ and store in &F5 .exit PLA \ balance stack LDA #0 \ flag service provided RTS \ and return to MOS .out PLA \ restore accumulator RTS \ and return to MOS .fourteen Figure 18.1 The service call &0D interpreter. ----------- --------------------------------- The RFS byte get call (&0E) is issued after initialising the rom with service call &0D. It is used to retrieve one byte pointed to by the RFS address vector. A rom must only respond to this call if the number stored in &F5 is 15 minus the number stored in &F4. The byte should be returned in the Y register with the accumulator reset to zero and the RFS address vector incremented to point to the next byte. The necessary coding is shown in figure 18.2 PHA \ save accumulator CMP #13 \ is it service call &0D? BNE fourteen \ branch if not &0D . . \ service call &0D goes in here . .exit PLA \ restore accumulator LDA #0 \ flag service provided RTS \ and return to MOS .fourteen CMP #14 \ is it service call &0E? BNE out \ branch if not &0E LDA &F5 \ get adjusted rom number EOR #&0F \ restore to current value CMP &F4 \ compare with this rom's number BNE out \ branch if its another rom LDY #0 \ reset Y LDA (&F6),Y \ load vectored byte TAY \ transfer byte to Y register INC &F6 \ increment low byte of vector BNE exit \ branch if not page boundary INC &F7 \ increment high byte of vector JMP exit \ and exit with A = 0 .out PLA \ restore accumulator RTS \ and retrun to MOS Figure 18.2 The service call &0E interpreter. ----------- --------------------------------- The coding in figures 18.1 and 18.2 will be used in the interpreters of all the programs used in the RFS modules of this course. The programs which illustrate this part of the course use a modular design in which the rom header and interpreter are created in a first program which then chains a second program containing the RFS formatting software. The second program reads files from the current filing system, formats them for the RFS and stores them in memory starting at the end of the header created in the first program. When all the required files are formatted the RFS rom image is stored on disc or tape. The program RFSHEAD demonstrates a simple service rom header and RFS interpreter. It uses the routines in figures 18.1 and 18.2 to create the RFS interpreter and then chains the program RFSGEN which does the RFS formatting. RFSHEAD stores the address of the first byte available for RFS data in the resident integer variable O%. RFSGEN uses the address in O% as the start address for RFS data. The program RFSGEN will be used in every RFS module of this course. It will be chained by programs, such as RFSHEAD, which use different headers and interpreters to achieve different objectives, but all the RFS rom images need to store their data in the format created by RFSGEN. The rom image created by RFSGEN stores data in a block structure similar to the format used by the tape filing system, with the following exceptions. 1. The ASCII character "+" (&2B) is used as an end of rom marker. This is not an end of data marker and does not mean that files larger than 16k cannot be stored. If, for example, a 30k file is stored in two roms the first 15k would be in one rom and terminated with and end of rom marker. The second 15k of the file must be in the next rom scanned by the RFS and again followed by an end of rom marker. The RFS formatting program RFSGEN only formats up to 16k RFS rom images but it can be modified to run in a second processor and format 32k RFS rom images. 2. The block header (not the rom header) is replaced by the "#" (hash) continuation character (&23) for all except the first and last blocks. If a continuation character is used in this way it means that the header is unchanged from the previous block, except for the block number. 3. The four spare bytes in the cassette header block are used to store the address of the byte after the end of the file, enabling the RFS default fast file searching. The RFS data produced by RFSGEN must be preceded by a rom header, such as the one generated by the program RFSHEAD. The two programs RFSHEAD and RFSGEN can be used with either the disc filing system or the tape filing system to create the RFS rom image. If the DFS is used both these two programs and the files to be formatted must be on the same disc. If the tape filing system is used you will need to know in advance the load and execute addresses and the length of all the files to be formatted. The formatting programs can be used to create RFS rom images by programmers who have no idea why the programs work. Such beginners will find figures 18.3 and 18.4 helpful. Figure 18.3 shows the formatting programs being used with the DFS and figure 18.4 shows the same programs being used with the tape filing system. In both cases they are used to format the supplied program DEMO into an RFS rom image and to store the rom image in a file called TEST. To use the rom image load the file TEST into SWR and press the Break key. Then type *ROM and press Return. If you have used the DEMO program supplied with the course you can then either *RUN "DEMO" or CHAIN "DEMO" from the RFS into user memory in either the I/O processor or a 6502 second processor. The BASIC program DEMO has been modified so that it can be *RUN. If you want to know how this was done then disassemble it from &2194 to see the machine code embedded in the REM statement in line 360. >CHAIN "RFSHEAD" <Return> SRW SOFTWARE (96) Drive 0 Option 0 (off) Dir. :0.$ Lib. :0.$ DEMO RFSGEN RFSHEAD Press <RETURN> to end Enter file name = DEMO <Return> Enter file name = <Return> Save filename = TEST <Return> $.TEST FF8000 FF8000 000980 16E > Figure 18.3 Using the RFS formatter with the DFS. ----------- ------------------------------------- >CHAIN "RFSHEAD" <Return> Searching Loading RFSHEAD 04 0442 Searching Loading RFSGEN 08 08BA Press <RETURN> to end Enter file name = DEMO <Return> Load address = &1900 <Return> Exec address = &2194 <Return> File length = &8D2 <Return> Searching Loading DEMO 08 08D2 FFFF1900 FFFF802 Enter file name: <Return> Save filename = TEST <Return> RECORD then RETURN TEST 09 0980 FFFF8000 FFFF8000 > Figure 18.4 Using the RFS formatter with the TFS. ----------- ------------------------------------- 10 REM: RFSHEAD 20 MODE7 30 HIMEM=&3C00 40 diff=&8000-HIMEM 50 H%=HIMEM 60 romnumber=&F4 70 phrom=&F5 80 rompoint=&F6 90 FOR pass = 0 TO 2 STEP 2 100 P%=HIMEM 110 [ OPT pass 120 BRK 130 BRK 140 BRK 150 JMP service+diff 160 OPT FNequb(&82) 170 OPT FNequb((copyright+diff) MOD 256) 180 BRK 190 OPT FNequs("RFS") 200 .copyright 210 BRK 220 OPT FNequs("(C) Gordon Horsington 1986") 230 BRK 240 .service 250 PHA 260 CMP #13 270 BNE fourteen 280 TYA 290 EOR #&F 300 CMP romnumber 310 BCC out 320 LDA #(lastbyte+diff) MOD 256 330 STA rompoint 340 LDA #(lastbyte+diff) DIV 256 350 STA rompoint+1 360 LDA romnumber 370 EOR #&F 380 STA phrom 390 .exit 400 PLA 410 LDA #0 420 RTS 430 .fourteen 440 CMP #14 450 BNE out 460 LDA phrom 470 EOR #&F 480 CMP romnumber 490 BNE out 500 LDY #0 510 LDA (rompoint),Y 520 TAY 530 INC rompoint 540 BNE exit 550 INC rompoint+1 560 JMP exit+diff 570 .out 580 PLA 590 RTS 600 .lastbyte 610 ] 620 NEXT 630 O%=lastbyte 640 CHAIN"RFSGEN" 650 DEFFNequb(byte) 660 ?P%=byte 670 P%=P%+1 680 =pass 690 DEFFNequw(word) 700 ?P%=word MOD 256 710 P%?1=word DIV 256 720 P%=P%+2 730 =pass 740 DEFFNequd(double) 750 !P%=double 760 P%=P%+4 770 =pass 780 DEFFNequs(string$) 790 $P%=string$ 800 P%=P%+LEN(string$) 810 =pass 10 REM: RFSGEN 20 IFH%<>HIMEM END 30 DIM pblock 20,name 20,mcode 50 40 osargs=&FFDA 50 osfile=&FFDD 60 oscli=&FFF7 70 address=&70 80 high=&72 90 low=&73 100 last=&74 110 finish=FALSE 120 A%=0 130 X%=0 140 Y%=0 150 disc=USR(osargs)AND &000000FF 160 IFdisc=1 OR disc=2 disc=FALSE ELSE disc=TRUE 170 FORpass=0 TO 2 STEP 2 180 P%=mcode 190 [ OPT pass 200 LDA #0 210 STA high 220 STA low 230 TAY 240 .nextbyte 250 LDA high 260 EOR (address),Y 270 STA high 280 LDX #8 290 .loop 300 LDA high 310 ROL A 320 BCC rotate 330 LDA high 340 EOR #8 350 STA high 360 LDA low 370 EOR #&10 380 STA low 390 .rotate 400 ROL low 410 ROL high 420 DEX 430 BNE loop 440 INY 450 CPY last 460 BNE nextbyte 470 RTS 480 ] 490 NEXT 500 IF disc : *CAT 510 PRINT'"Press <RETURN> to end"' 520 REPEAT 530 INPUTLINE"Enter file name = "$name 540 IF $name="" finish=TRUE 550 IF NOT disc PROCtape 560 IF NOT finish PROCfile 570 UNTIL finish 580 ?O%=ASC("+") 590 INPUT'"Save filename = "filename$ 600 IF filename$="" END 610 $mcode="SAVE "+filename$+" "+STR$~(HIMEM)+" "+STR$~(O% +1)+" FFFF8000 FFFF8000" 620 X%=mcode MOD 256 630 Y%=mcode DIV 256 640 *OPT1,2 650 CALL oscli 660 *OPT1,0 670 END 680 DEFPROCfile 690 channel=OPENUP($name) 700 IFchannel=0 PRINT"File not found" : CLOSE#channel : ENDPROC 710 !pblock=name 720 IF disc PROCdisc 730 lename=LEN($name)+23 740 nextfile=&8000+O%-HIMEM+lename-lename*(fsize>256)-3* (fsize>512)*(((fsize-1)DIV256)-1) + fsize 750 IF nextfile > &BFFE PRINT"File too big" : CLOSE#channel : ENDPROC 760 block=0 770 IFfsize>256 PROCfirst 780 PROCheader(128,fsize) 790 CLOSE#channel 800 ENDPROC 810 DEFPROCheader(flag,length) 820 lename=LEN($name) 830 ?O%=ASC("*") 840 O%=O%+1 850 $O%=$name 860 O%=lename+O% 870 ?O%=0 880 O%!1=load 890 O%!5=exec 900 O%!9=block 910 O%!11=length 920 O%?13=flag 930 O%!14=nextfile 940 ?last=lename+18 950 !address=O%-lename 960 CALL mcode 970 O%!18=!high 980 O%=O%+20 990 PROCread(length) 1000 block=block+1 1010 ENDPROC 1020 DEFPROCread(length) 1030 J%=length-1 1040 FORI%=0TOJ% 1050 O%?I%=BGET#channel 1060 NEXT 1070 !address=O% 1080 ?last=length 1090 CALL mcode 1100 O%!length=!high 1110 fsize=fsize-length 1120 O%=O%+length+2 1130 ENDPROC 1140 DEFPROCfirst 1150 PROCheader(0,256) 1160 IFfsize<=256 ENDPROC 1170 REPEAT 1180 ?O%=ASC("#") 1190 O%=O%+1 1200 PROCread(256) 1210 block=block+1 1220 UNTIL fsize<=256 1230 ENDPROC 1240 DEFPROCtape 1250 IF finish ENDPROC 1260 INPUT'"Load address = &"l$ 1270 load=EVAL("&"+l$) 1280 INPUT"Exec address = &"l$ 1290 exec=EVAL("&"+l$) 1300 INPUT"File length = &"l$ 1310 fsize=EVAL("&"+l$) 1320 *OPT1,2 1330 ENDPROC 1340 DEFPROCdisc 1350 A%=5 1360 X%=pblock MOD 256 1370 Y%=pblock DIV 256 1380 CALL osfile 1390 load=pblock!2 1400 exec=pblock!6 1410 fsize=pblock!10 1420 ENDPROC
00000000 4d 61 73 74 65 72 69 6e 67 20 53 69 64 65 77 61 |Mastering Sidewa| 00000010 79 73 20 52 4f 4d 20 26 20 52 41 4d 20 2d 20 4d |ys ROM & RAM - M| 00000020 6f 64 75 6c 65 20 31 38 20 2d 20 52 6f 6d 20 46 |odule 18 - Rom F| 00000030 69 6c 69 6e 67 20 53 79 73 74 65 6d 0d 2d 2d 2d |iling System.---| 00000040 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 00000070 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0d 20 20 54 68 65 |---------.. The| 00000080 20 72 6f 6d 20 66 69 6c 69 6e 67 20 73 79 73 74 | rom filing syst| 00000090 65 6d 20 28 52 46 53 29 20 69 73 20 61 76 61 69 |em (RFS) is avai| 000000a0 6c 61 62 6c 65 20 6f 6e 20 61 6c 6c 20 42 42 43 |lable on all BBC| 000000b0 20 6d 69 63 72 6f 63 6f 6d 70 75 74 65 72 73 0d | microcomputers.| 000000c0 77 69 74 68 20 31 2e 30 20 6f 70 65 72 61 74 69 |with 1.0 operati| 000000d0 6e 67 20 73 79 73 74 65 6d 2c 20 6f 72 20 6c 61 |ng system, or la| 000000e0 74 65 72 2e 20 54 68 65 20 52 46 53 20 69 73 20 |ter. The RFS is | 000000f0 73 65 6c 65 63 74 65 64 20 62 79 20 74 79 70 69 |selected by typi| 00000100 6e 67 0d 2a 52 4f 4d 20 61 6e 64 20 75 73 65 73 |ng.*ROM and uses| 00000110 20 64 61 74 61 20 73 74 6f 72 65 64 20 69 6e 20 | data stored in | 00000120 70 61 67 65 64 20 72 6f 6d 73 20 6f 72 20 69 6e |paged roms or in| 00000130 20 73 65 72 69 61 6c 6c 79 20 61 63 63 65 73 73 | serially access| 00000140 65 64 20 72 6f 6d 73 0d 61 73 73 6f 63 69 61 74 |ed roms.associat| 00000150 65 64 20 77 69 74 68 20 74 68 65 20 41 63 6f 72 |ed with the Acor| 00000160 6e 20 73 70 65 65 63 68 20 73 79 73 74 65 6d 2e |n speech system.| 00000170 20 54 68 65 20 52 46 53 20 69 73 20 73 69 6d 69 | The RFS is simi| 00000180 6c 61 72 20 74 6f 20 61 0d 72 65 61 64 2d 6f 6e |lar to a.read-on| 00000190 6c 79 20 74 61 70 65 20 66 69 6c 69 6e 67 20 73 |ly tape filing s| 000001a0 79 73 74 65 6d 20 62 75 74 20 77 69 74 68 20 74 |ystem but with t| 000001b0 68 65 20 64 61 74 61 20 73 74 6f 72 65 64 20 69 |he data stored i| 000001c0 6e 20 53 57 52 20 69 6e 73 74 65 61 64 0d 6f 66 |n SWR instead.of| 000001d0 20 6f 6e 20 63 61 73 73 65 74 74 65 73 2e 20 50 | on cassettes. P| 000001e0 72 6f 67 72 61 6d 73 20 73 74 6f 72 65 64 20 69 |rograms stored i| 000001f0 6e 20 74 68 65 20 52 46 53 20 63 61 6e 20 6f 6e |n the RFS can on| 00000200 6c 79 20 62 65 20 72 75 6e 20 62 79 20 6c 6f 61 |ly be run by loa| 00000210 64 69 6e 67 0d 74 68 65 6d 20 66 72 6f 6d 20 74 |ding.them from t| 00000220 68 65 20 66 69 6c 69 6e 67 20 73 79 73 74 65 6d |he filing system| 00000230 20 69 6e 74 6f 20 74 68 65 20 75 73 65 72 20 6d | into the user m| 00000240 65 6d 6f 72 79 20 6f 66 20 74 68 65 20 63 6f 6d |emory of the com| 00000250 70 75 74 65 72 2e 0d 0d 20 20 54 68 65 72 65 20 |puter... There | 00000260 61 72 65 20 74 77 6f 20 73 65 72 76 69 63 65 20 |are two service | 00000270 63 61 6c 6c 73 2c 20 26 30 44 20 61 6e 64 20 26 |calls, &0D and &| 00000280 30 45 2c 20 61 73 73 6f 63 69 61 74 65 64 20 77 |0E, associated w| 00000290 69 74 68 20 74 68 65 20 52 46 53 2e 0d 53 65 72 |ith the RFS..Ser| 000002a0 76 69 63 65 20 63 61 6c 6c 20 26 30 44 20 63 61 |vice call &0D ca| 000002b0 6e 20 62 65 20 64 65 6d 6f 6e 73 74 72 61 74 65 |n be demonstrate| 000002c0 64 20 77 69 74 68 20 74 68 65 20 73 65 72 76 69 |d with the servi| 000002d0 63 65 20 63 61 6c 6c 20 74 72 61 63 65 0d 70 72 |ce call trace.pr| 000002e0 6f 67 72 61 6d 20 69 6e 74 72 6f 64 75 63 65 64 |ogram introduced| 000002f0 20 69 6e 20 4d 6f 64 75 6c 65 20 32 2e 0d 0d 20 | in Module 2... | 00000300 20 54 68 65 20 52 46 53 20 69 6e 69 74 69 61 6c | The RFS initial| 00000310 69 73 61 74 69 6f 6e 20 63 61 6c 6c 20 28 26 30 |isation call (&0| 00000320 44 29 20 69 73 20 69 73 73 75 65 64 20 62 79 20 |D) is issued by | 00000330 74 68 65 20 4d 4f 53 20 77 68 65 6e 20 74 68 65 |the MOS when the| 00000340 20 52 46 53 0d 69 73 20 61 63 74 69 76 65 20 61 | RFS.is active a| 00000350 6e 64 20 61 20 66 69 6c 69 6e 67 20 73 79 73 74 |nd a filing syst| 00000360 65 6d 20 63 6f 6d 6d 61 6e 64 20 68 61 73 20 62 |em command has b| 00000370 65 65 6e 20 75 73 65 64 2e 20 49 74 20 67 69 76 |een used. It giv| 00000380 65 73 20 61 6e 0d 61 63 74 69 76 65 20 72 6f 6d |es an.active rom| 00000390 20 74 68 65 20 6f 70 70 6f 72 74 75 6e 69 74 79 | the opportunity| 000003a0 20 74 6f 20 69 6e 66 6f 72 6d 20 74 68 65 20 4d | to inform the M| 000003b0 4f 53 20 74 68 61 74 20 69 74 20 63 6f 6e 74 61 |OS that it conta| 000003c0 69 6e 73 20 52 46 53 0d 66 69 6c 65 73 2c 20 61 |ins RFS.files, a| 000003d0 6e 64 20 74 68 65 20 73 74 61 72 74 20 61 64 64 |nd the start add| 000003e0 72 65 73 73 20 6f 66 20 74 68 6f 73 65 20 66 69 |ress of those fi| 000003f0 6c 65 73 2e 20 4f 6e 20 65 6e 74 72 79 2c 20 74 |les. On entry, t| 00000400 68 65 20 59 20 72 65 67 69 73 74 65 72 0d 63 6f |he Y register.co| 00000410 6e 74 61 69 6e 73 20 31 35 20 6d 69 6e 75 73 20 |ntains 15 minus | 00000420 74 68 65 20 72 6f 6d 20 6e 75 6d 62 65 72 20 6f |the rom number o| 00000430 66 20 74 68 65 20 6e 65 78 74 20 72 6f 6d 20 74 |f the next rom t| 00000440 6f 20 62 65 20 73 63 61 6e 6e 65 64 2e 20 49 66 |o be scanned. If| 00000450 0d 74 68 69 73 20 73 6f 20 63 61 6c 6c 65 64 20 |.this so called | 00000460 61 64 6a 75 73 74 65 64 20 72 6f 6d 20 6e 75 6d |adjusted rom num| 00000470 62 65 72 20 69 73 20 6c 65 73 73 20 74 68 61 74 |ber is less that| 00000480 20 74 68 65 20 6e 75 6d 62 65 72 20 6f 66 20 74 | the number of t| 00000490 68 65 20 72 6f 6d 0d 72 65 63 65 69 76 69 6e 67 |he rom.receiving| 000004a0 20 74 68 65 20 63 61 6c 6c 2c 20 74 68 65 20 63 | the call, the c| 000004b0 61 6c 6c 20 73 68 6f 75 6c 64 20 62 65 20 69 67 |all should be ig| 000004c0 6e 6f 72 65 64 20 62 65 63 61 75 73 65 20 69 74 |nored because it| 000004d0 20 68 61 73 20 62 65 65 6e 0d 70 72 6f 63 65 73 | has been.proces| 000004e0 73 65 64 20 65 61 72 6c 69 65 72 2e 20 4f 74 68 |sed earlier. Oth| 000004f0 65 72 77 69 73 65 2c 20 74 68 65 20 61 64 6a 75 |erwise, the adju| 00000500 73 74 65 64 20 72 6f 6d 20 6e 75 6d 62 65 72 20 |sted rom number | 00000510 66 6f 72 20 74 68 65 20 63 75 72 72 65 6e 74 0d |for the current.| 00000520 72 6f 6d 20 73 68 6f 75 6c 64 20 62 65 20 73 74 |rom should be st| 00000530 6f 72 65 64 20 69 6e 20 26 46 35 2c 20 74 68 65 |ored in &F5, the| 00000540 20 73 74 61 72 74 20 61 64 64 72 65 73 73 20 6f | start address o| 00000550 66 20 74 68 65 20 52 46 53 20 64 61 74 61 20 73 |f the RFS data s| 00000560 68 6f 75 6c 64 0d 62 65 20 73 74 6f 72 65 64 20 |hould.be stored | 00000570 69 6e 20 74 68 65 20 52 46 53 20 61 64 64 72 65 |in the RFS addre| 00000580 73 73 20 76 65 63 74 6f 72 20 61 74 20 6c 6f 63 |ss vector at loc| 00000590 61 74 69 6f 6e 73 20 26 46 36 20 61 6e 64 20 26 |ations &F6 and &| 000005a0 46 37 2c 20 61 6e 64 20 74 68 65 0d 61 63 63 75 |F7, and the.accu| 000005b0 6d 75 6c 61 74 6f 72 20 73 68 6f 75 6c 64 20 62 |mulator should b| 000005c0 65 20 72 65 73 65 74 20 74 6f 20 7a 65 72 6f 20 |e reset to zero | 000005d0 62 65 66 6f 72 65 20 72 65 74 75 72 6e 69 6e 67 |before returning| 000005e0 20 63 6f 6e 74 72 6f 6c 20 74 6f 20 74 68 65 0d | control to the.| 000005f0 4d 4f 53 2e 0d 0d 20 20 54 68 69 73 20 72 61 74 |MOS... This rat| 00000600 68 65 72 20 63 6f 6d 70 6c 69 63 61 74 65 64 20 |her complicated | 00000610 72 65 73 70 6f 6e 73 65 20 74 6f 20 73 65 72 76 |response to serv| 00000620 69 63 65 20 63 61 6c 6c 20 26 30 44 20 69 73 20 |ice call &0D is | 00000630 73 75 6d 6d 61 72 69 73 65 64 0d 69 6e 20 66 69 |summarised.in fi| 00000640 67 75 72 65 20 31 38 2e 31 20 69 6e 20 77 68 69 |gure 18.1 in whi| 00000650 63 68 20 22 66 69 6c 65 22 20 6d 61 72 6b 73 20 |ch "file" marks | 00000660 74 68 65 20 61 64 64 72 65 73 73 20 61 74 20 77 |the address at w| 00000670 68 69 63 68 20 74 68 65 20 52 46 53 0d 66 6f 72 |hich the RFS.for| 00000680 6d 61 74 74 65 64 20 66 69 6c 65 73 20 73 74 61 |matted files sta| 00000690 72 74 2e 0d 0d 0d 0d 0d 20 20 20 20 20 20 20 20 |rt...... | 000006a0 50 48 41 20 20 20 20 20 20 20 20 20 20 20 20 20 |PHA | 000006b0 20 20 20 5c 20 73 61 76 65 20 61 63 63 75 6d 75 | \ save accumu| 000006c0 6c 61 74 6f 72 0d 20 20 20 20 20 20 20 20 43 4d |lator. CM| 000006d0 50 20 23 31 33 20 20 20 20 20 20 20 20 20 20 20 |P #13 | 000006e0 20 5c 20 69 73 20 69 74 20 73 65 72 76 69 63 65 | \ is it service| 000006f0 20 63 61 6c 6c 20 26 30 44 3f 0d 20 20 20 20 20 | call &0D?. | 00000700 20 20 20 42 4e 45 20 66 6f 75 72 74 65 65 6e 20 | BNE fourteen | 00000710 20 20 20 20 20 20 5c 20 62 72 61 6e 63 68 20 69 | \ branch i| 00000720 66 20 6e 6f 74 20 26 30 44 0d 20 20 20 20 20 20 |f not &0D. | 00000730 20 20 54 59 41 20 20 20 20 20 20 20 20 20 20 20 | TYA | 00000740 20 20 20 20 20 5c 20 59 20 73 74 6f 72 65 73 20 | \ Y stores | 00000750 61 64 6a 75 73 74 65 64 20 72 6f 6d 20 6e 75 6d |adjusted rom num| 00000760 62 65 72 0d 20 20 20 20 20 20 20 20 45 4f 52 20 |ber. EOR | 00000770 23 26 30 46 20 20 20 20 20 20 20 20 20 20 20 5c |#&0F \| 00000780 20 63 61 6c 63 75 6c 61 74 65 20 28 31 35 2d 61 | calculate (15-a| 00000790 64 6a 75 73 74 65 64 20 72 6f 6d 20 6e 75 6d 62 |djusted rom numb| 000007a0 65 72 29 0d 20 20 20 20 20 20 20 20 43 4d 50 20 |er). CMP | 000007b0 26 46 34 20 20 20 20 20 20 20 20 20 20 20 20 5c |&F4 \| 000007c0 20 63 6f 6d 70 61 72 65 20 77 69 74 68 20 74 68 | compare with th| 000007d0 69 73 20 72 6f 6d 20 6e 75 6d 62 65 72 0d 20 20 |is rom number. | 000007e0 20 20 20 20 20 20 42 43 43 20 6f 75 74 20 20 20 | BCC out | 000007f0 20 20 20 20 20 20 20 20 20 5c 20 72 65 74 75 72 | \ retur| 00000800 6e 20 69 66 20 6c 65 73 73 0d 20 20 20 20 20 20 |n if less. | 00000810 20 20 4c 44 41 20 23 66 69 6c 65 20 4d 4f 44 20 | LDA #file MOD | 00000820 32 35 36 20 20 5c 20 6c 6f 77 20 62 79 74 65 20 |256 \ low byte | 00000830 6f 66 20 66 69 72 73 74 20 52 46 53 20 66 69 6c |of first RFS fil| 00000840 65 0d 20 20 20 20 20 20 20 20 53 54 41 20 26 46 |e. STA &F| 00000850 36 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 73 |6 \ s| 00000860 74 6f 72 65 20 69 6e 20 52 46 53 20 76 65 63 74 |tore in RFS vect| 00000870 6f 72 0d 20 20 20 20 20 20 20 20 4c 44 41 20 23 |or. LDA #| 00000880 66 69 6c 65 20 44 49 56 20 32 35 36 20 20 5c 20 |file DIV 256 \ | 00000890 68 69 67 68 20 62 79 74 65 20 6f 66 20 66 69 72 |high byte of fir| 000008a0 73 74 20 52 46 53 20 66 69 6c 65 0d 20 20 20 20 |st RFS file. | 000008b0 20 20 20 20 53 54 41 20 26 46 37 20 20 20 20 20 | STA &F7 | 000008c0 20 20 20 20 20 20 20 5c 20 73 74 6f 72 65 20 69 | \ store i| 000008d0 6e 20 52 46 53 20 76 65 63 74 6f 72 0d 20 20 20 |n RFS vector. | 000008e0 20 20 20 20 20 4c 44 41 20 26 46 34 20 20 20 20 | LDA &F4 | 000008f0 20 20 20 20 20 20 20 20 5c 20 6c 6f 61 64 20 74 | \ load t| 00000900 68 69 73 20 72 6f 6d 20 6e 75 6d 62 65 72 0d 20 |his rom number. | 00000910 20 20 20 20 20 20 20 45 4f 52 20 23 26 30 46 20 | EOR #&0F | 00000920 20 20 20 20 20 20 20 20 20 20 5c 20 63 61 6c 63 | \ calc| 00000930 75 6c 61 74 65 20 61 64 6a 75 73 74 65 64 20 72 |ulate adjusted r| 00000940 6f 6d 20 6e 75 6d 62 65 72 0d 20 20 20 20 20 20 |om number. | 00000950 20 20 53 54 41 20 26 46 35 20 20 20 20 20 20 20 | STA &F5 | 00000960 20 20 20 20 20 5c 20 61 6e 64 20 73 74 6f 72 65 | \ and store| 00000970 20 69 6e 20 26 46 35 0d 2e 65 78 69 74 0d 20 20 | in &F5..exit. | 00000980 20 20 20 20 20 20 50 4c 41 20 20 20 20 20 20 20 | PLA | 00000990 20 20 20 20 20 20 20 20 20 5c 20 62 61 6c 61 6e | \ balan| 000009a0 63 65 20 73 74 61 63 6b 0d 20 20 20 20 20 20 20 |ce stack. | 000009b0 20 4c 44 41 20 23 30 20 20 20 20 20 20 20 20 20 | LDA #0 | 000009c0 20 20 20 20 5c 20 66 6c 61 67 20 73 65 72 76 69 | \ flag servi| 000009d0 63 65 20 70 72 6f 76 69 64 65 64 0d 20 20 20 20 |ce provided. | 000009e0 20 20 20 20 52 54 53 20 20 20 20 20 20 20 20 20 | RTS | 000009f0 20 20 20 20 20 20 20 5c 20 61 6e 64 20 72 65 74 | \ and ret| 00000a00 75 72 6e 20 74 6f 20 4d 4f 53 0d 2e 6f 75 74 0d |urn to MOS..out.| 00000a10 20 20 20 20 20 20 20 20 50 4c 41 20 20 20 20 20 | PLA | 00000a20 20 20 20 20 20 20 20 20 20 20 20 5c 20 72 65 73 | \ res| 00000a30 74 6f 72 65 20 61 63 63 75 6d 75 6c 61 74 6f 72 |tore accumulator| 00000a40 0d 20 20 20 20 20 20 20 20 52 54 53 20 20 20 20 |. RTS | 00000a50 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 61 6e | \ an| 00000a60 64 20 72 65 74 75 72 6e 20 74 6f 20 4d 4f 53 0d |d return to MOS.| 00000a70 2e 66 6f 75 72 74 65 65 6e 0d 0d 46 69 67 75 72 |.fourteen..Figur| 00000a80 65 20 31 38 2e 31 20 20 54 68 65 20 73 65 72 76 |e 18.1 The serv| 00000a90 69 63 65 20 63 61 6c 6c 20 26 30 44 20 69 6e 74 |ice call &0D int| 00000aa0 65 72 70 72 65 74 65 72 2e 0d 2d 2d 2d 2d 2d 2d |erpreter..------| 00000ab0 2d 2d 2d 2d 2d 20 20 2d 2d 2d 2d 2d 2d 2d 2d 2d |----- ---------| 00000ac0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00000ad0 2d 2d 2d 2d 2d 2d 2d 2d 0d 0d 0d 0d 0d 20 20 54 |--------..... T| 00000ae0 68 65 20 52 46 53 20 62 79 74 65 20 67 65 74 20 |he RFS byte get | 00000af0 63 61 6c 6c 20 28 26 30 45 29 20 69 73 20 69 73 |call (&0E) is is| 00000b00 73 75 65 64 20 61 66 74 65 72 20 69 6e 69 74 69 |sued after initi| 00000b10 61 6c 69 73 69 6e 67 20 74 68 65 20 72 6f 6d 0d |alising the rom.| 00000b20 77 69 74 68 20 73 65 72 76 69 63 65 20 63 61 6c |with service cal| 00000b30 6c 20 26 30 44 2e 20 49 74 20 69 73 20 75 73 65 |l &0D. It is use| 00000b40 64 20 74 6f 20 72 65 74 72 69 65 76 65 20 6f 6e |d to retrieve on| 00000b50 65 20 62 79 74 65 20 70 6f 69 6e 74 65 64 20 74 |e byte pointed t| 00000b60 6f 20 62 79 0d 74 68 65 20 52 46 53 20 61 64 64 |o by.the RFS add| 00000b70 72 65 73 73 20 76 65 63 74 6f 72 2e 20 41 20 72 |ress vector. A r| 00000b80 6f 6d 20 6d 75 73 74 20 6f 6e 6c 79 20 72 65 73 |om must only res| 00000b90 70 6f 6e 64 20 74 6f 20 74 68 69 73 20 63 61 6c |pond to this cal| 00000ba0 6c 20 69 66 20 74 68 65 0d 6e 75 6d 62 65 72 20 |l if the.number | 00000bb0 73 74 6f 72 65 64 20 69 6e 20 26 46 35 20 69 73 |stored in &F5 is| 00000bc0 20 31 35 20 6d 69 6e 75 73 20 74 68 65 20 6e 75 | 15 minus the nu| 00000bd0 6d 62 65 72 20 73 74 6f 72 65 64 20 69 6e 20 26 |mber stored in &| 00000be0 46 34 2e 20 54 68 65 20 62 79 74 65 0d 73 68 6f |F4. The byte.sho| 00000bf0 75 6c 64 20 62 65 20 72 65 74 75 72 6e 65 64 20 |uld be returned | 00000c00 69 6e 20 74 68 65 20 59 20 72 65 67 69 73 74 65 |in the Y registe| 00000c10 72 20 77 69 74 68 20 74 68 65 20 61 63 63 75 6d |r with the accum| 00000c20 75 6c 61 74 6f 72 20 72 65 73 65 74 20 74 6f 0d |ulator reset to.| 00000c30 7a 65 72 6f 20 61 6e 64 20 74 68 65 20 52 46 53 |zero and the RFS| 00000c40 20 61 64 64 72 65 73 73 20 76 65 63 74 6f 72 20 | address vector | 00000c50 69 6e 63 72 65 6d 65 6e 74 65 64 20 74 6f 20 70 |incremented to p| 00000c60 6f 69 6e 74 20 74 6f 20 74 68 65 20 6e 65 78 74 |oint to the next| 00000c70 20 62 79 74 65 2e 0d 54 68 65 20 6e 65 63 65 73 | byte..The neces| 00000c80 73 61 72 79 20 63 6f 64 69 6e 67 20 69 73 20 73 |sary coding is s| 00000c90 68 6f 77 6e 20 69 6e 20 66 69 67 75 72 65 20 31 |hown in figure 1| 00000ca0 38 2e 32 0d 0d 0d 0d 0d 20 20 20 20 20 20 20 20 |8.2..... | 00000cb0 50 48 41 20 20 20 20 20 20 20 20 20 20 20 20 20 |PHA | 00000cc0 20 20 20 5c 20 73 61 76 65 20 61 63 63 75 6d 75 | \ save accumu| 00000cd0 6c 61 74 6f 72 0d 20 20 20 20 20 20 20 20 43 4d |lator. CM| 00000ce0 50 20 23 31 33 20 20 20 20 20 20 20 20 20 20 20 |P #13 | 00000cf0 20 5c 20 69 73 20 69 74 20 73 65 72 76 69 63 65 | \ is it service| 00000d00 20 63 61 6c 6c 20 26 30 44 3f 0d 20 20 20 20 20 | call &0D?. | 00000d10 20 20 20 42 4e 45 20 66 6f 75 72 74 65 65 6e 20 | BNE fourteen | 00000d20 20 20 20 20 20 20 5c 20 62 72 61 6e 63 68 20 69 | \ branch i| 00000d30 66 20 6e 6f 74 20 26 30 44 0d 20 20 20 20 20 20 |f not &0D. | 00000d40 20 20 20 2e 0d 20 20 20 20 20 20 20 20 20 2e 20 | .. . | 00000d50 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000d60 5c 20 73 65 72 76 69 63 65 20 63 61 6c 6c 20 26 |\ service call &| 00000d70 30 44 20 67 6f 65 73 20 69 6e 20 68 65 72 65 0d |0D goes in here.| 00000d80 20 20 20 20 20 20 20 20 20 2e 0d 2e 65 78 69 74 | ...exit| 00000d90 0d 20 20 20 20 20 20 20 20 50 4c 41 20 20 20 20 |. PLA | 00000da0 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 72 65 | \ re| 00000db0 73 74 6f 72 65 20 61 63 63 75 6d 75 6c 61 74 6f |store accumulato| 00000dc0 72 0d 20 20 20 20 20 20 20 20 4c 44 41 20 23 30 |r. LDA #0| 00000dd0 20 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 66 | \ f| 00000de0 6c 61 67 20 73 65 72 76 69 63 65 20 70 72 6f 76 |lag service prov| 00000df0 69 64 65 64 0d 20 20 20 20 20 20 20 20 52 54 53 |ided. RTS| 00000e00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000e10 5c 20 61 6e 64 20 72 65 74 75 72 6e 20 74 6f 20 |\ and return to | 00000e20 4d 4f 53 0d 2e 66 6f 75 72 74 65 65 6e 0d 20 20 |MOS..fourteen. | 00000e30 20 20 20 20 20 20 43 4d 50 20 23 31 34 20 20 20 | CMP #14 | 00000e40 20 20 20 20 20 20 20 20 20 5c 20 69 73 20 69 74 | \ is it| 00000e50 20 73 65 72 76 69 63 65 20 63 61 6c 6c 20 26 30 | service call &0| 00000e60 45 3f 0d 20 20 20 20 20 20 20 20 42 4e 45 20 6f |E?. BNE o| 00000e70 75 74 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 |ut \ | 00000e80 62 72 61 6e 63 68 20 69 66 20 6e 6f 74 20 26 30 |branch if not &0| 00000e90 45 0d 20 20 20 20 20 20 20 20 4c 44 41 20 26 46 |E. LDA &F| 00000ea0 35 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 67 |5 \ g| 00000eb0 65 74 20 61 64 6a 75 73 74 65 64 20 72 6f 6d 20 |et adjusted rom | 00000ec0 6e 75 6d 62 65 72 0d 20 20 20 20 20 20 20 20 45 |number. E| 00000ed0 4f 52 20 23 26 30 46 20 20 20 20 20 20 20 20 20 |OR #&0F | 00000ee0 20 20 5c 20 72 65 73 74 6f 72 65 20 74 6f 20 63 | \ restore to c| 00000ef0 75 72 72 65 6e 74 20 76 61 6c 75 65 0d 20 20 20 |urrent value. | 00000f00 20 20 20 20 20 43 4d 50 20 26 46 34 20 20 20 20 | CMP &F4 | 00000f10 20 20 20 20 20 20 20 20 5c 20 63 6f 6d 70 61 72 | \ compar| 00000f20 65 20 77 69 74 68 20 74 68 69 73 20 72 6f 6d 27 |e with this rom'| 00000f30 73 20 6e 75 6d 62 65 72 0d 20 20 20 20 20 20 20 |s number. | 00000f40 20 42 4e 45 20 6f 75 74 20 20 20 20 20 20 20 20 | BNE out | 00000f50 20 20 20 20 5c 20 62 72 61 6e 63 68 20 69 66 20 | \ branch if | 00000f60 69 74 73 20 61 6e 6f 74 68 65 72 20 72 6f 6d 0d |its another rom.| 00000f70 20 20 20 20 20 20 20 20 4c 44 59 20 23 30 20 20 | LDY #0 | 00000f80 20 20 20 20 20 20 20 20 20 20 20 5c 20 72 65 73 | \ res| 00000f90 65 74 20 59 0d 20 20 20 20 20 20 20 20 4c 44 41 |et Y. LDA| 00000fa0 20 28 26 46 36 29 2c 59 20 20 20 20 20 20 20 20 | (&F6),Y | 00000fb0 5c 20 6c 6f 61 64 20 76 65 63 74 6f 72 65 64 20 |\ load vectored | 00000fc0 62 79 74 65 0d 20 20 20 20 20 20 20 20 54 41 59 |byte. TAY| 00000fd0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000fe0 5c 20 74 72 61 6e 73 66 65 72 20 62 79 74 65 20 |\ transfer byte | 00000ff0 74 6f 20 59 20 72 65 67 69 73 74 65 72 0d 20 20 |to Y register. | 00001000 20 20 20 20 20 20 49 4e 43 20 26 46 36 20 20 20 | INC &F6 | 00001010 20 20 20 20 20 20 20 20 20 5c 20 69 6e 63 72 65 | \ incre| 00001020 6d 65 6e 74 20 6c 6f 77 20 62 79 74 65 20 6f 66 |ment low byte of| 00001030 20 76 65 63 74 6f 72 0d 20 20 20 20 20 20 20 20 | vector. | 00001040 42 4e 45 20 65 78 69 74 20 20 20 20 20 20 20 20 |BNE exit | 00001050 20 20 20 5c 20 62 72 61 6e 63 68 20 69 66 20 6e | \ branch if n| 00001060 6f 74 20 70 61 67 65 20 62 6f 75 6e 64 61 72 79 |ot page boundary| 00001070 0d 20 20 20 20 20 20 20 20 49 4e 43 20 26 46 37 |. INC &F7| 00001080 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 69 6e | \ in| 00001090 63 72 65 6d 65 6e 74 20 68 69 67 68 20 62 79 74 |crement high byt| 000010a0 65 20 6f 66 20 76 65 63 74 6f 72 0d 20 20 20 20 |e of vector. | 000010b0 20 20 20 20 4a 4d 50 20 65 78 69 74 20 20 20 20 | JMP exit | 000010c0 20 20 20 20 20 20 20 5c 20 61 6e 64 20 65 78 69 | \ and exi| 000010d0 74 20 77 69 74 68 20 41 20 3d 20 30 0d 2e 6f 75 |t with A = 0..ou| 000010e0 74 0d 20 20 20 20 20 20 20 20 50 4c 41 20 20 20 |t. PLA | 000010f0 20 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 72 | \ r| 00001100 65 73 74 6f 72 65 20 61 63 63 75 6d 75 6c 61 74 |estore accumulat| 00001110 6f 72 0d 20 20 20 20 20 20 20 20 52 54 53 20 20 |or. RTS | 00001120 20 20 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 | \ | 00001130 61 6e 64 20 72 65 74 72 75 6e 20 74 6f 20 4d 4f |and retrun to MO| 00001140 53 0d 0d 46 69 67 75 72 65 20 31 38 2e 32 20 20 |S..Figure 18.2 | 00001150 54 68 65 20 73 65 72 76 69 63 65 20 63 61 6c 6c |The service call| 00001160 20 26 30 45 20 69 6e 74 65 72 70 72 65 74 65 72 | &0E interpreter| 00001170 2e 0d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 20 20 2d |..----------- -| 00001180 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 000011a0 0d 0d 0d 0d 20 20 54 68 65 20 63 6f 64 69 6e 67 |.... The coding| 000011b0 20 69 6e 20 66 69 67 75 72 65 73 20 31 38 2e 31 | in figures 18.1| 000011c0 20 61 6e 64 20 31 38 2e 32 20 77 69 6c 6c 20 62 | and 18.2 will b| 000011d0 65 20 75 73 65 64 20 69 6e 20 74 68 65 20 69 6e |e used in the in| 000011e0 74 65 72 70 72 65 74 65 72 73 0d 6f 66 20 61 6c |terpreters.of al| 000011f0 6c 20 74 68 65 20 70 72 6f 67 72 61 6d 73 20 75 |l the programs u| 00001200 73 65 64 20 69 6e 20 74 68 65 20 52 46 53 20 6d |sed in the RFS m| 00001210 6f 64 75 6c 65 73 20 6f 66 20 74 68 69 73 20 63 |odules of this c| 00001220 6f 75 72 73 65 2e 20 54 68 65 0d 70 72 6f 67 72 |ourse. The.progr| 00001230 61 6d 73 20 77 68 69 63 68 20 69 6c 6c 75 73 74 |ams which illust| 00001240 72 61 74 65 20 74 68 69 73 20 70 61 72 74 20 6f |rate this part o| 00001250 66 20 74 68 65 20 63 6f 75 72 73 65 20 75 73 65 |f the course use| 00001260 20 61 20 6d 6f 64 75 6c 61 72 20 64 65 73 69 67 | a modular desig| 00001270 6e 0d 69 6e 20 77 68 69 63 68 20 74 68 65 20 72 |n.in which the r| 00001280 6f 6d 20 68 65 61 64 65 72 20 61 6e 64 20 69 6e |om header and in| 00001290 74 65 72 70 72 65 74 65 72 20 61 72 65 20 63 72 |terpreter are cr| 000012a0 65 61 74 65 64 20 69 6e 20 61 20 66 69 72 73 74 |eated in a first| 000012b0 20 70 72 6f 67 72 61 6d 0d 77 68 69 63 68 20 74 | program.which t| 000012c0 68 65 6e 20 63 68 61 69 6e 73 20 61 20 73 65 63 |hen chains a sec| 000012d0 6f 6e 64 20 70 72 6f 67 72 61 6d 20 63 6f 6e 74 |ond program cont| 000012e0 61 69 6e 69 6e 67 20 74 68 65 20 52 46 53 20 66 |aining the RFS f| 000012f0 6f 72 6d 61 74 74 69 6e 67 0d 73 6f 66 74 77 61 |ormatting.softwa| 00001300 72 65 2e 20 54 68 65 20 73 65 63 6f 6e 64 20 70 |re. The second p| 00001310 72 6f 67 72 61 6d 20 72 65 61 64 73 20 66 69 6c |rogram reads fil| 00001320 65 73 20 66 72 6f 6d 20 74 68 65 20 63 75 72 72 |es from the curr| 00001330 65 6e 74 20 66 69 6c 69 6e 67 0d 73 79 73 74 65 |ent filing.syste| 00001340 6d 2c 20 66 6f 72 6d 61 74 73 20 74 68 65 6d 20 |m, formats them | 00001350 66 6f 72 20 74 68 65 20 52 46 53 20 61 6e 64 20 |for the RFS and | 00001360 73 74 6f 72 65 73 20 74 68 65 6d 20 69 6e 20 6d |stores them in m| 00001370 65 6d 6f 72 79 20 73 74 61 72 74 69 6e 67 20 61 |emory starting a| 00001380 74 0d 74 68 65 20 65 6e 64 20 6f 66 20 74 68 65 |t.the end of the| 00001390 20 68 65 61 64 65 72 20 63 72 65 61 74 65 64 20 | header created | 000013a0 69 6e 20 74 68 65 20 66 69 72 73 74 20 70 72 6f |in the first pro| 000013b0 67 72 61 6d 2e 20 57 68 65 6e 20 61 6c 6c 20 74 |gram. When all t| 000013c0 68 65 0d 72 65 71 75 69 72 65 64 20 66 69 6c 65 |he.required file| 000013d0 73 20 61 72 65 20 66 6f 72 6d 61 74 74 65 64 20 |s are formatted | 000013e0 74 68 65 20 52 46 53 20 72 6f 6d 20 69 6d 61 67 |the RFS rom imag| 000013f0 65 20 69 73 20 73 74 6f 72 65 64 20 6f 6e 20 64 |e is stored on d| 00001400 69 73 63 20 6f 72 0d 74 61 70 65 2e 0d 0d 20 20 |isc or.tape... | 00001410 54 68 65 20 70 72 6f 67 72 61 6d 20 52 46 53 48 |The program RFSH| 00001420 45 41 44 20 64 65 6d 6f 6e 73 74 72 61 74 65 73 |EAD demonstrates| 00001430 20 61 20 73 69 6d 70 6c 65 20 73 65 72 76 69 63 | a simple servic| 00001440 65 20 72 6f 6d 20 68 65 61 64 65 72 20 61 6e 64 |e rom header and| 00001450 20 52 46 53 0d 69 6e 74 65 72 70 72 65 74 65 72 | RFS.interpreter| 00001460 2e 20 49 74 20 75 73 65 73 20 74 68 65 20 72 6f |. It uses the ro| 00001470 75 74 69 6e 65 73 20 69 6e 20 66 69 67 75 72 65 |utines in figure| 00001480 73 20 31 38 2e 31 20 61 6e 64 20 31 38 2e 32 20 |s 18.1 and 18.2 | 00001490 74 6f 20 63 72 65 61 74 65 0d 74 68 65 20 52 46 |to create.the RF| 000014a0 53 20 69 6e 74 65 72 70 72 65 74 65 72 20 61 6e |S interpreter an| 000014b0 64 20 74 68 65 6e 20 63 68 61 69 6e 73 20 74 68 |d then chains th| 000014c0 65 20 70 72 6f 67 72 61 6d 20 52 46 53 47 45 4e |e program RFSGEN| 000014d0 20 77 68 69 63 68 20 64 6f 65 73 20 74 68 65 0d | which does the.| 000014e0 52 46 53 20 66 6f 72 6d 61 74 74 69 6e 67 2e 20 |RFS formatting. | 000014f0 52 46 53 48 45 41 44 20 73 74 6f 72 65 73 20 74 |RFSHEAD stores t| 00001500 68 65 20 61 64 64 72 65 73 73 20 6f 66 20 74 68 |he address of th| 00001510 65 20 66 69 72 73 74 20 62 79 74 65 20 61 76 61 |e first byte ava| 00001520 69 6c 61 62 6c 65 0d 66 6f 72 20 52 46 53 20 64 |ilable.for RFS d| 00001530 61 74 61 20 69 6e 20 74 68 65 20 72 65 73 69 64 |ata in the resid| 00001540 65 6e 74 20 69 6e 74 65 67 65 72 20 76 61 72 69 |ent integer vari| 00001550 61 62 6c 65 20 4f 25 2e 20 52 46 53 47 45 4e 20 |able O%. RFSGEN | 00001560 75 73 65 73 20 74 68 65 0d 61 64 64 72 65 73 73 |uses the.address| 00001570 20 69 6e 20 4f 25 20 61 73 20 74 68 65 20 73 74 | in O% as the st| 00001580 61 72 74 20 61 64 64 72 65 73 73 20 66 6f 72 20 |art address for | 00001590 52 46 53 20 64 61 74 61 2e 0d 0d 20 20 54 68 65 |RFS data... The| 000015a0 20 70 72 6f 67 72 61 6d 20 52 46 53 47 45 4e 20 | program RFSGEN | 000015b0 77 69 6c 6c 20 62 65 20 75 73 65 64 20 69 6e 20 |will be used in | 000015c0 65 76 65 72 79 20 52 46 53 20 6d 6f 64 75 6c 65 |every RFS module| 000015d0 20 6f 66 20 74 68 69 73 20 63 6f 75 72 73 65 2e | of this course.| 000015e0 0d 49 74 20 77 69 6c 6c 20 62 65 20 63 68 61 69 |.It will be chai| 000015f0 6e 65 64 20 62 79 20 70 72 6f 67 72 61 6d 73 2c |ned by programs,| 00001600 20 73 75 63 68 20 61 73 20 52 46 53 48 45 41 44 | such as RFSHEAD| 00001610 2c 20 77 68 69 63 68 20 75 73 65 20 64 69 66 66 |, which use diff| 00001620 65 72 65 6e 74 0d 68 65 61 64 65 72 73 20 61 6e |erent.headers an| 00001630 64 20 69 6e 74 65 72 70 72 65 74 65 72 73 20 74 |d interpreters t| 00001640 6f 20 61 63 68 69 65 76 65 20 64 69 66 66 65 72 |o achieve differ| 00001650 65 6e 74 20 6f 62 6a 65 63 74 69 76 65 73 2c 20 |ent objectives, | 00001660 62 75 74 20 61 6c 6c 20 74 68 65 0d 52 46 53 20 |but all the.RFS | 00001670 72 6f 6d 20 69 6d 61 67 65 73 20 6e 65 65 64 20 |rom images need | 00001680 74 6f 20 73 74 6f 72 65 20 74 68 65 69 72 20 64 |to store their d| 00001690 61 74 61 20 69 6e 20 74 68 65 20 66 6f 72 6d 61 |ata in the forma| 000016a0 74 20 63 72 65 61 74 65 64 20 62 79 0d 52 46 53 |t created by.RFS| 000016b0 47 45 4e 2e 0d 0d 20 20 54 68 65 20 72 6f 6d 20 |GEN... The rom | 000016c0 69 6d 61 67 65 20 63 72 65 61 74 65 64 20 62 79 |image created by| 000016d0 20 52 46 53 47 45 4e 20 73 74 6f 72 65 73 20 64 | RFSGEN stores d| 000016e0 61 74 61 20 69 6e 20 61 20 62 6c 6f 63 6b 20 73 |ata in a block s| 000016f0 74 72 75 63 74 75 72 65 0d 73 69 6d 69 6c 61 72 |tructure.similar| 00001700 20 74 6f 20 74 68 65 20 66 6f 72 6d 61 74 20 75 | to the format u| 00001710 73 65 64 20 62 79 20 74 68 65 20 74 61 70 65 20 |sed by the tape | 00001720 66 69 6c 69 6e 67 20 73 79 73 74 65 6d 2c 20 77 |filing system, w| 00001730 69 74 68 20 74 68 65 0d 66 6f 6c 6c 6f 77 69 6e |ith the.followin| 00001740 67 20 65 78 63 65 70 74 69 6f 6e 73 2e 0d 0d 31 |g exceptions...1| 00001750 2e 20 54 68 65 20 41 53 43 49 49 20 63 68 61 72 |. The ASCII char| 00001760 61 63 74 65 72 20 22 2b 22 20 28 26 32 42 29 20 |acter "+" (&2B) | 00001770 69 73 20 75 73 65 64 20 61 73 20 61 6e 20 65 6e |is used as an en| 00001780 64 20 6f 66 20 72 6f 6d 20 6d 61 72 6b 65 72 2e |d of rom marker.| 00001790 20 54 68 69 73 0d 69 73 20 6e 6f 74 20 61 6e 20 | This.is not an | 000017a0 65 6e 64 20 6f 66 20 64 61 74 61 20 6d 61 72 6b |end of data mark| 000017b0 65 72 20 61 6e 64 20 64 6f 65 73 20 6e 6f 74 20 |er and does not | 000017c0 6d 65 61 6e 20 74 68 61 74 20 66 69 6c 65 73 20 |mean that files | 000017d0 6c 61 72 67 65 72 20 74 68 61 6e 0d 31 36 6b 20 |larger than.16k | 000017e0 63 61 6e 6e 6f 74 20 62 65 20 73 74 6f 72 65 64 |cannot be stored| 000017f0 2e 20 49 66 2c 20 66 6f 72 20 65 78 61 6d 70 6c |. If, for exampl| 00001800 65 2c 20 61 20 33 30 6b 20 66 69 6c 65 20 69 73 |e, a 30k file is| 00001810 20 73 74 6f 72 65 64 20 69 6e 20 74 77 6f 0d 72 | stored in two.r| 00001820 6f 6d 73 20 74 68 65 20 66 69 72 73 74 20 31 35 |oms the first 15| 00001830 6b 20 77 6f 75 6c 64 20 62 65 20 69 6e 20 6f 6e |k would be in on| 00001840 65 20 72 6f 6d 20 61 6e 64 20 74 65 72 6d 69 6e |e rom and termin| 00001850 61 74 65 64 20 77 69 74 68 20 61 6e 64 20 65 6e |ated with and en| 00001860 64 20 6f 66 0d 72 6f 6d 20 6d 61 72 6b 65 72 2e |d of.rom marker.| 00001870 20 54 68 65 20 73 65 63 6f 6e 64 20 31 35 6b 20 | The second 15k | 00001880 6f 66 20 74 68 65 20 66 69 6c 65 20 6d 75 73 74 |of the file must| 00001890 20 62 65 20 69 6e 20 74 68 65 20 6e 65 78 74 20 | be in the next | 000018a0 72 6f 6d 20 73 63 61 6e 6e 65 64 0d 62 79 20 74 |rom scanned.by t| 000018b0 68 65 20 52 46 53 20 61 6e 64 20 61 67 61 69 6e |he RFS and again| 000018c0 20 66 6f 6c 6c 6f 77 65 64 20 62 79 20 61 6e 20 | followed by an | 000018d0 65 6e 64 20 6f 66 20 72 6f 6d 20 6d 61 72 6b 65 |end of rom marke| 000018e0 72 2e 20 54 68 65 20 52 46 53 0d 66 6f 72 6d 61 |r. The RFS.forma| 000018f0 74 74 69 6e 67 20 70 72 6f 67 72 61 6d 20 52 46 |tting program RF| 00001900 53 47 45 4e 20 6f 6e 6c 79 20 66 6f 72 6d 61 74 |SGEN only format| 00001910 73 20 75 70 20 74 6f 20 31 36 6b 20 52 46 53 20 |s up to 16k RFS | 00001920 72 6f 6d 20 69 6d 61 67 65 73 20 62 75 74 20 69 |rom images but i| 00001930 74 0d 63 61 6e 20 62 65 20 6d 6f 64 69 66 69 65 |t.can be modifie| 00001940 64 20 74 6f 20 72 75 6e 20 69 6e 20 61 20 73 65 |d to run in a se| 00001950 63 6f 6e 64 20 70 72 6f 63 65 73 73 6f 72 20 61 |cond processor a| 00001960 6e 64 20 66 6f 72 6d 61 74 20 33 32 6b 20 52 46 |nd format 32k RF| 00001970 53 20 72 6f 6d 0d 69 6d 61 67 65 73 2e 0d 0d 32 |S rom.images...2| 00001980 2e 20 54 68 65 20 62 6c 6f 63 6b 20 68 65 61 64 |. The block head| 00001990 65 72 20 28 6e 6f 74 20 74 68 65 20 72 6f 6d 20 |er (not the rom | 000019a0 68 65 61 64 65 72 29 20 69 73 20 72 65 70 6c 61 |header) is repla| 000019b0 63 65 64 20 62 79 20 74 68 65 20 22 23 22 20 28 |ced by the "#" (| 000019c0 68 61 73 68 29 0d 63 6f 6e 74 69 6e 75 61 74 69 |hash).continuati| 000019d0 6f 6e 20 63 68 61 72 61 63 74 65 72 20 28 26 32 |on character (&2| 000019e0 33 29 20 66 6f 72 20 61 6c 6c 20 65 78 63 65 70 |3) for all excep| 000019f0 74 20 74 68 65 20 66 69 72 73 74 20 61 6e 64 20 |t the first and | 00001a00 6c 61 73 74 20 62 6c 6f 63 6b 73 2e 0d 49 66 20 |last blocks..If | 00001a10 61 20 63 6f 6e 74 69 6e 75 61 74 69 6f 6e 20 63 |a continuation c| 00001a20 68 61 72 61 63 74 65 72 20 69 73 20 75 73 65 64 |haracter is used| 00001a30 20 69 6e 20 74 68 69 73 20 77 61 79 20 69 74 20 | in this way it | 00001a40 6d 65 61 6e 73 20 74 68 61 74 20 74 68 65 0d 68 |means that the.h| 00001a50 65 61 64 65 72 20 69 73 20 75 6e 63 68 61 6e 67 |eader is unchang| 00001a60 65 64 20 66 72 6f 6d 20 74 68 65 20 70 72 65 76 |ed from the prev| 00001a70 69 6f 75 73 20 62 6c 6f 63 6b 2c 20 65 78 63 65 |ious block, exce| 00001a80 70 74 20 66 6f 72 20 74 68 65 20 62 6c 6f 63 6b |pt for the block| 00001a90 0d 6e 75 6d 62 65 72 2e 0d 0d 33 2e 20 54 68 65 |.number...3. The| 00001aa0 20 66 6f 75 72 20 73 70 61 72 65 20 62 79 74 65 | four spare byte| 00001ab0 73 20 69 6e 20 74 68 65 20 63 61 73 73 65 74 74 |s in the cassett| 00001ac0 65 20 68 65 61 64 65 72 20 62 6c 6f 63 6b 20 61 |e header block a| 00001ad0 72 65 20 75 73 65 64 20 74 6f 20 73 74 6f 72 65 |re used to store| 00001ae0 0d 74 68 65 20 61 64 64 72 65 73 73 20 6f 66 20 |.the address of | 00001af0 74 68 65 20 62 79 74 65 20 61 66 74 65 72 20 74 |the byte after t| 00001b00 68 65 20 65 6e 64 20 6f 66 20 74 68 65 20 66 69 |he end of the fi| 00001b10 6c 65 2c 20 65 6e 61 62 6c 69 6e 67 20 74 68 65 |le, enabling the| 00001b20 20 52 46 53 0d 64 65 66 61 75 6c 74 20 66 61 73 | RFS.default fas| 00001b30 74 20 66 69 6c 65 20 73 65 61 72 63 68 69 6e 67 |t file searching| 00001b40 2e 0d 0d 20 54 68 65 20 52 46 53 20 64 61 74 61 |... The RFS data| 00001b50 20 70 72 6f 64 75 63 65 64 20 62 79 20 52 46 53 | produced by RFS| 00001b60 47 45 4e 20 6d 75 73 74 20 62 65 20 70 72 65 63 |GEN must be prec| 00001b70 65 64 65 64 20 62 79 20 61 20 72 6f 6d 20 68 65 |eded by a rom he| 00001b80 61 64 65 72 2c 0d 73 75 63 68 20 61 73 20 74 68 |ader,.such as th| 00001b90 65 20 6f 6e 65 20 67 65 6e 65 72 61 74 65 64 20 |e one generated | 00001ba0 62 79 20 74 68 65 20 70 72 6f 67 72 61 6d 20 52 |by the program R| 00001bb0 46 53 48 45 41 44 2e 0d 0d 20 20 54 68 65 20 74 |FSHEAD... The t| 00001bc0 77 6f 20 70 72 6f 67 72 61 6d 73 20 52 46 53 48 |wo programs RFSH| 00001bd0 45 41 44 20 61 6e 64 20 52 46 53 47 45 4e 20 63 |EAD and RFSGEN c| 00001be0 61 6e 20 62 65 20 75 73 65 64 20 77 69 74 68 20 |an be used with | 00001bf0 65 69 74 68 65 72 20 74 68 65 20 64 69 73 63 0d |either the disc.| 00001c00 66 69 6c 69 6e 67 20 73 79 73 74 65 6d 20 6f 72 |filing system or| 00001c10 20 74 68 65 20 74 61 70 65 20 66 69 6c 69 6e 67 | the tape filing| 00001c20 20 73 79 73 74 65 6d 20 74 6f 20 63 72 65 61 74 | system to creat| 00001c30 65 20 74 68 65 20 52 46 53 20 72 6f 6d 20 69 6d |e the RFS rom im| 00001c40 61 67 65 2e 0d 49 66 20 74 68 65 20 44 46 53 20 |age..If the DFS | 00001c50 69 73 20 75 73 65 64 20 62 6f 74 68 20 74 68 65 |is used both the| 00001c60 73 65 20 74 77 6f 20 70 72 6f 67 72 61 6d 73 20 |se two programs | 00001c70 61 6e 64 20 74 68 65 20 66 69 6c 65 73 20 74 6f |and the files to| 00001c80 20 62 65 0d 66 6f 72 6d 61 74 74 65 64 20 6d 75 | be.formatted mu| 00001c90 73 74 20 62 65 20 6f 6e 20 74 68 65 20 73 61 6d |st be on the sam| 00001ca0 65 20 64 69 73 63 2e 20 49 66 20 74 68 65 20 74 |e disc. If the t| 00001cb0 61 70 65 20 66 69 6c 69 6e 67 20 73 79 73 74 65 |ape filing syste| 00001cc0 6d 20 69 73 20 75 73 65 64 0d 79 6f 75 20 77 69 |m is used.you wi| 00001cd0 6c 6c 20 6e 65 65 64 20 74 6f 20 6b 6e 6f 77 20 |ll need to know | 00001ce0 69 6e 20 61 64 76 61 6e 63 65 20 74 68 65 20 6c |in advance the l| 00001cf0 6f 61 64 20 61 6e 64 20 65 78 65 63 75 74 65 20 |oad and execute | 00001d00 61 64 64 72 65 73 73 65 73 20 61 6e 64 0d 74 68 |addresses and.th| 00001d10 65 20 6c 65 6e 67 74 68 20 6f 66 20 61 6c 6c 20 |e length of all | 00001d20 74 68 65 20 66 69 6c 65 73 20 74 6f 20 62 65 20 |the files to be | 00001d30 66 6f 72 6d 61 74 74 65 64 2e 0d 0d 20 20 54 68 |formatted... Th| 00001d40 65 20 66 6f 72 6d 61 74 74 69 6e 67 20 70 72 6f |e formatting pro| 00001d50 67 72 61 6d 73 20 63 61 6e 20 62 65 20 75 73 65 |grams can be use| 00001d60 64 20 74 6f 20 63 72 65 61 74 65 20 52 46 53 20 |d to create RFS | 00001d70 72 6f 6d 20 69 6d 61 67 65 73 20 62 79 0d 70 72 |rom images by.pr| 00001d80 6f 67 72 61 6d 6d 65 72 73 20 77 68 6f 20 68 61 |ogrammers who ha| 00001d90 76 65 20 6e 6f 20 69 64 65 61 20 77 68 79 20 74 |ve no idea why t| 00001da0 68 65 20 70 72 6f 67 72 61 6d 73 20 77 6f 72 6b |he programs work| 00001db0 2e 20 53 75 63 68 20 62 65 67 69 6e 6e 65 72 73 |. Such beginners| 00001dc0 0d 77 69 6c 6c 20 66 69 6e 64 20 66 69 67 75 72 |.will find figur| 00001dd0 65 73 20 31 38 2e 33 20 61 6e 64 20 31 38 2e 34 |es 18.3 and 18.4| 00001de0 20 68 65 6c 70 66 75 6c 2e 20 46 69 67 75 72 65 | helpful. Figure| 00001df0 20 31 38 2e 33 20 73 68 6f 77 73 20 74 68 65 0d | 18.3 shows the.| 00001e00 66 6f 72 6d 61 74 74 69 6e 67 20 70 72 6f 67 72 |formatting progr| 00001e10 61 6d 73 20 62 65 69 6e 67 20 75 73 65 64 20 77 |ams being used w| 00001e20 69 74 68 20 74 68 65 20 44 46 53 20 61 6e 64 20 |ith the DFS and | 00001e30 66 69 67 75 72 65 20 31 38 2e 34 20 73 68 6f 77 |figure 18.4 show| 00001e40 73 20 74 68 65 0d 73 61 6d 65 20 70 72 6f 67 72 |s the.same progr| 00001e50 61 6d 73 20 62 65 69 6e 67 20 75 73 65 64 20 77 |ams being used w| 00001e60 69 74 68 20 74 68 65 20 74 61 70 65 20 66 69 6c |ith the tape fil| 00001e70 69 6e 67 20 73 79 73 74 65 6d 2e 20 49 6e 20 62 |ing system. In b| 00001e80 6f 74 68 20 63 61 73 65 73 0d 74 68 65 79 20 61 |oth cases.they a| 00001e90 72 65 20 75 73 65 64 20 74 6f 20 66 6f 72 6d 61 |re used to forma| 00001ea0 74 20 74 68 65 20 73 75 70 70 6c 69 65 64 20 70 |t the supplied p| 00001eb0 72 6f 67 72 61 6d 20 44 45 4d 4f 20 69 6e 74 6f |rogram DEMO into| 00001ec0 20 61 6e 20 52 46 53 20 72 6f 6d 0d 69 6d 61 67 | an RFS rom.imag| 00001ed0 65 20 61 6e 64 20 74 6f 20 73 74 6f 72 65 20 74 |e and to store t| 00001ee0 68 65 20 72 6f 6d 20 69 6d 61 67 65 20 69 6e 20 |he rom image in | 00001ef0 61 20 66 69 6c 65 20 63 61 6c 6c 65 64 20 54 45 |a file called TE| 00001f00 53 54 2e 20 54 6f 20 75 73 65 20 74 68 65 20 72 |ST. To use the r| 00001f10 6f 6d 0d 69 6d 61 67 65 20 6c 6f 61 64 20 74 68 |om.image load th| 00001f20 65 20 66 69 6c 65 20 54 45 53 54 20 69 6e 74 6f |e file TEST into| 00001f30 20 53 57 52 20 61 6e 64 20 70 72 65 73 73 20 74 | SWR and press t| 00001f40 68 65 20 42 72 65 61 6b 20 6b 65 79 2e 20 54 68 |he Break key. Th| 00001f50 65 6e 20 74 79 70 65 0d 2a 52 4f 4d 20 61 6e 64 |en type.*ROM and| 00001f60 20 70 72 65 73 73 20 52 65 74 75 72 6e 2e 20 49 | press Return. I| 00001f70 66 20 79 6f 75 20 68 61 76 65 20 75 73 65 64 20 |f you have used | 00001f80 74 68 65 20 44 45 4d 4f 20 70 72 6f 67 72 61 6d |the DEMO program| 00001f90 20 73 75 70 70 6c 69 65 64 20 77 69 74 68 0d 74 | supplied with.t| 00001fa0 68 65 20 63 6f 75 72 73 65 20 79 6f 75 20 63 61 |he course you ca| 00001fb0 6e 20 74 68 65 6e 20 65 69 74 68 65 72 20 2a 52 |n then either *R| 00001fc0 55 4e 20 22 44 45 4d 4f 22 20 6f 72 20 43 48 41 |UN "DEMO" or CHA| 00001fd0 49 4e 20 22 44 45 4d 4f 22 20 66 72 6f 6d 20 74 |IN "DEMO" from t| 00001fe0 68 65 0d 52 46 53 20 69 6e 74 6f 20 75 73 65 72 |he.RFS into user| 00001ff0 20 6d 65 6d 6f 72 79 20 69 6e 20 65 69 74 68 65 | memory in eithe| 00002000 72 20 74 68 65 20 49 2f 4f 20 70 72 6f 63 65 73 |r the I/O proces| 00002010 73 6f 72 20 6f 72 20 61 20 36 35 30 32 20 73 65 |sor or a 6502 se| 00002020 63 6f 6e 64 0d 70 72 6f 63 65 73 73 6f 72 2e 0d |cond.processor..| 00002030 0d 20 20 54 68 65 20 42 41 53 49 43 20 70 72 6f |. The BASIC pro| 00002040 67 72 61 6d 20 44 45 4d 4f 20 68 61 73 20 62 65 |gram DEMO has be| 00002050 65 6e 20 6d 6f 64 69 66 69 65 64 20 73 6f 20 74 |en modified so t| 00002060 68 61 74 20 69 74 20 63 61 6e 20 62 65 20 2a 52 |hat it can be *R| 00002070 55 4e 2e 20 49 66 0d 79 6f 75 20 77 61 6e 74 20 |UN. If.you want | 00002080 74 6f 20 6b 6e 6f 77 20 68 6f 77 20 74 68 69 73 |to know how this| 00002090 20 77 61 73 20 64 6f 6e 65 20 74 68 65 6e 20 64 | was done then d| 000020a0 69 73 61 73 73 65 6d 62 6c 65 20 69 74 20 66 72 |isassemble it fr| 000020b0 6f 6d 20 26 32 31 39 34 20 74 6f 0d 73 65 65 20 |om &2194 to.see | 000020c0 74 68 65 20 6d 61 63 68 69 6e 65 20 63 6f 64 65 |the machine code| 000020d0 20 65 6d 62 65 64 64 65 64 20 69 6e 20 74 68 65 | embedded in the| 000020e0 20 52 45 4d 20 73 74 61 74 65 6d 65 6e 74 20 69 | REM statement i| 000020f0 6e 20 6c 69 6e 65 20 33 36 30 2e 0d 0d 0d 0d 3e |n line 360.....>| 00002100 43 48 41 49 4e 20 22 52 46 53 48 45 41 44 22 20 |CHAIN "RFSHEAD" | 00002110 3c 52 65 74 75 72 6e 3e 0d 0d 53 52 57 20 53 4f |<Return>..SRW SO| 00002120 46 54 57 41 52 45 0d 20 28 39 36 29 0d 44 72 69 |FTWARE. (96).Dri| 00002130 76 65 20 30 20 20 20 20 20 20 20 20 20 20 20 20 |ve 0 | 00002140 20 4f 70 74 69 6f 6e 20 30 20 28 6f 66 66 29 0d | Option 0 (off).| 00002150 44 69 72 2e 20 3a 30 2e 24 20 20 20 20 20 20 20 |Dir. :0.$ | 00002160 20 20 20 20 4c 69 62 2e 20 3a 30 2e 24 0d 0d 20 | Lib. :0.$.. | 00002170 20 20 20 44 45 4d 4f 20 20 20 20 20 20 20 20 20 | DEMO | 00002180 20 20 20 20 20 20 20 52 46 53 47 45 4e 0d 20 20 | RFSGEN. | 00002190 20 20 52 46 53 48 45 41 44 0d 0d 50 72 65 73 73 | RFSHEAD..Press| 000021a0 20 3c 52 45 54 55 52 4e 3e 20 74 6f 20 65 6e 64 | <RETURN> to end| 000021b0 0d 0d 45 6e 74 65 72 20 66 69 6c 65 20 6e 61 6d |..Enter file nam| 000021c0 65 20 3d 20 44 45 4d 4f 20 3c 52 65 74 75 72 6e |e = DEMO <Return| 000021d0 3e 0d 45 6e 74 65 72 20 66 69 6c 65 20 6e 61 6d |>.Enter file nam| 000021e0 65 20 3d 20 3c 52 65 74 75 72 6e 3e 0d 0d 53 61 |e = <Return>..Sa| 000021f0 76 65 20 66 69 6c 65 6e 61 6d 65 20 3d 20 54 45 |ve filename = TE| 00002200 53 54 20 3c 52 65 74 75 72 6e 3e 0d 24 2e 54 45 |ST <Return>.$.TE| 00002210 53 54 20 20 20 20 20 20 20 20 46 46 38 30 30 30 |ST FF8000| 00002220 20 46 46 38 30 30 30 20 30 30 30 39 38 30 20 31 | FF8000 000980 1| 00002230 36 45 0d 3e 0d 0d 46 69 67 75 72 65 20 31 38 2e |6E.>..Figure 18.| 00002240 33 20 20 55 73 69 6e 67 20 74 68 65 20 52 46 53 |3 Using the RFS| 00002250 20 66 6f 72 6d 61 74 74 65 72 20 77 69 74 68 20 | formatter with | 00002260 74 68 65 20 44 46 53 2e 0d 2d 2d 2d 2d 2d 2d 2d |the DFS..-------| 00002270 2d 2d 2d 2d 20 20 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |---- ----------| 00002280 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00002290 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0d 0d 0d 3e |-----------....>| 000022a0 43 48 41 49 4e 20 22 52 46 53 48 45 41 44 22 20 |CHAIN "RFSHEAD" | 000022b0 3c 52 65 74 75 72 6e 3e 0d 53 65 61 72 63 68 69 |<Return>.Searchi| 000022c0 6e 67 0d 0d 4c 6f 61 64 69 6e 67 0d 0d 52 46 53 |ng..Loading..RFS| 000022d0 48 45 41 44 20 20 20 20 20 30 34 20 30 34 34 32 |HEAD 04 0442| 000022e0 0d 53 65 61 72 63 68 69 6e 67 0d 0d 4c 6f 61 64 |.Searching..Load| 000022f0 69 6e 67 0d 0d 52 46 53 47 45 4e 20 20 20 20 20 |ing..RFSGEN | 00002300 20 30 38 20 30 38 42 41 0d 0d 50 72 65 73 73 20 | 08 08BA..Press | 00002310 3c 52 45 54 55 52 4e 3e 20 74 6f 20 65 6e 64 0d |<RETURN> to end.| 00002320 0d 45 6e 74 65 72 20 66 69 6c 65 20 6e 61 6d 65 |.Enter file name| 00002330 20 3d 20 44 45 4d 4f 20 3c 52 65 74 75 72 6e 3e | = DEMO <Return>| 00002340 0d 0d 4c 6f 61 64 20 61 64 64 72 65 73 73 20 3d |..Load address =| 00002350 20 26 31 39 30 30 20 3c 52 65 74 75 72 6e 3e 0d | &1900 <Return>.| 00002360 45 78 65 63 20 61 64 64 72 65 73 73 20 3d 20 26 |Exec address = &| 00002370 32 31 39 34 20 3c 52 65 74 75 72 6e 3e 0d 46 69 |2194 <Return>.Fi| 00002380 6c 65 20 6c 65 6e 67 74 68 20 20 3d 20 26 38 44 |le length = &8D| 00002390 32 20 3c 52 65 74 75 72 6e 3e 0d 53 65 61 72 63 |2 <Return>.Searc| 000023a0 68 69 6e 67 0d 0d 4c 6f 61 64 69 6e 67 0d 44 45 |hing..Loading.DE| 000023b0 4d 4f 20 20 20 20 20 20 20 20 30 38 20 30 38 44 |MO 08 08D| 000023c0 32 20 20 20 20 46 46 46 46 31 39 30 30 20 46 46 |2 FFFF1900 FF| 000023d0 46 46 38 30 32 0d 45 6e 74 65 72 20 66 69 6c 65 |FF802.Enter file| 000023e0 20 6e 61 6d 65 3a 20 3c 52 65 74 75 72 6e 3e 0d | name: <Return>.| 000023f0 0d 53 61 76 65 20 66 69 6c 65 6e 61 6d 65 20 3d |.Save filename =| 00002400 20 54 45 53 54 20 3c 52 65 74 75 72 6e 3e 0d 52 | TEST <Return>.R| 00002410 45 43 4f 52 44 20 74 68 65 6e 20 52 45 54 55 52 |ECORD then RETUR| 00002420 4e 0d 54 45 53 54 20 20 20 20 20 20 20 20 30 39 |N.TEST 09| 00002430 20 30 39 38 30 20 20 20 20 46 46 46 46 38 30 30 | 0980 FFFF800| 00002440 30 20 46 46 46 46 38 30 30 30 0d 3e 0d 0d 46 69 |0 FFFF8000.>..Fi| 00002450 67 75 72 65 20 31 38 2e 34 20 20 55 73 69 6e 67 |gure 18.4 Using| 00002460 20 74 68 65 20 52 46 53 20 66 6f 72 6d 61 74 74 | the RFS formatt| 00002470 65 72 20 77 69 74 68 20 74 68 65 20 54 46 53 2e |er with the TFS.| 00002480 0d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 20 20 2d 2d |.----------- --| 00002490 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 000024b0 2d 2d 2d 0d 0d 0d 0d 0d 20 20 20 31 30 20 52 45 |---..... 10 RE| 000024c0 4d 3a 20 52 46 53 48 45 41 44 0d 20 20 20 32 30 |M: RFSHEAD. 20| 000024d0 20 4d 4f 44 45 37 0d 20 20 20 33 30 20 48 49 4d | MODE7. 30 HIM| 000024e0 45 4d 3d 26 33 43 30 30 0d 20 20 20 34 30 20 64 |EM=&3C00. 40 d| 000024f0 69 66 66 3d 26 38 30 30 30 2d 48 49 4d 45 4d 0d |iff=&8000-HIMEM.| 00002500 20 20 20 35 30 20 48 25 3d 48 49 4d 45 4d 0d 20 | 50 H%=HIMEM. | 00002510 20 20 36 30 20 72 6f 6d 6e 75 6d 62 65 72 3d 26 | 60 romnumber=&| 00002520 46 34 0d 20 20 20 37 30 20 70 68 72 6f 6d 3d 26 |F4. 70 phrom=&| 00002530 46 35 0d 20 20 20 38 30 20 72 6f 6d 70 6f 69 6e |F5. 80 rompoin| 00002540 74 3d 26 46 36 0d 20 20 20 39 30 20 46 4f 52 20 |t=&F6. 90 FOR | 00002550 70 61 73 73 20 3d 20 30 20 54 4f 20 32 20 53 54 |pass = 0 TO 2 ST| 00002560 45 50 20 32 0d 20 20 31 30 30 20 50 25 3d 48 49 |EP 2. 100 P%=HI| 00002570 4d 45 4d 0d 20 20 31 31 30 20 5b 20 20 20 20 20 |MEM. 110 [ | 00002580 20 20 4f 50 54 20 70 61 73 73 0d 20 20 31 32 30 | OPT pass. 120| 00002590 20 20 20 20 20 20 20 20 20 42 52 4b 0d 20 20 31 | BRK. 1| 000025a0 33 30 20 20 20 20 20 20 20 20 20 42 52 4b 0d 20 |30 BRK. | 000025b0 20 31 34 30 20 20 20 20 20 20 20 20 20 42 52 4b | 140 BRK| 000025c0 0d 20 20 31 35 30 20 20 20 20 20 20 20 20 20 4a |. 150 J| 000025d0 4d 50 20 73 65 72 76 69 63 65 2b 64 69 66 66 0d |MP service+diff.| 000025e0 20 20 31 36 30 20 20 20 20 20 20 20 20 20 4f 50 | 160 OP| 000025f0 54 20 46 4e 65 71 75 62 28 26 38 32 29 0d 20 20 |T FNequb(&82). | 00002600 31 37 30 20 20 20 20 20 20 20 20 20 4f 50 54 20 |170 OPT | 00002610 46 4e 65 71 75 62 28 28 63 6f 70 79 72 69 67 68 |FNequb((copyrigh| 00002620 74 2b 64 69 66 66 29 20 4d 4f 44 20 32 35 36 29 |t+diff) MOD 256)| 00002630 0d 20 20 31 38 30 20 20 20 20 20 20 20 20 20 42 |. 180 B| 00002640 52 4b 0d 20 20 31 39 30 20 20 20 20 20 20 20 20 |RK. 190 | 00002650 20 4f 50 54 20 46 4e 65 71 75 73 28 22 52 46 53 | OPT FNequs("RFS| 00002660 22 29 0d 20 20 32 30 30 20 2e 63 6f 70 79 72 69 |"). 200 .copyri| 00002670 67 68 74 0d 20 20 32 31 30 20 20 20 20 20 20 20 |ght. 210 | 00002680 20 20 42 52 4b 0d 20 20 32 32 30 20 20 20 20 20 | BRK. 220 | 00002690 20 20 20 20 4f 50 54 20 46 4e 65 71 75 73 28 22 | OPT FNequs("| 000026a0 28 43 29 20 47 6f 72 64 6f 6e 20 48 6f 72 73 69 |(C) Gordon Horsi| 000026b0 6e 67 74 6f 6e 20 31 39 38 36 22 29 0d 20 20 32 |ngton 1986"). 2| 000026c0 33 30 20 20 20 20 20 20 20 20 20 42 52 4b 0d 20 |30 BRK. | 000026d0 20 32 34 30 20 2e 73 65 72 76 69 63 65 0d 20 20 | 240 .service. | 000026e0 32 35 30 20 20 20 20 20 20 20 20 20 50 48 41 0d |250 PHA.| 000026f0 20 20 32 36 30 20 20 20 20 20 20 20 20 20 43 4d | 260 CM| 00002700 50 20 23 31 33 0d 20 20 32 37 30 20 20 20 20 20 |P #13. 270 | 00002710 20 20 20 20 42 4e 45 20 66 6f 75 72 74 65 65 6e | BNE fourteen| 00002720 0d 20 20 32 38 30 20 20 20 20 20 20 20 20 20 54 |. 280 T| 00002730 59 41 0d 20 20 32 39 30 20 20 20 20 20 20 20 20 |YA. 290 | 00002740 20 45 4f 52 20 23 26 46 0d 20 20 33 30 30 20 20 | EOR #&F. 300 | 00002750 20 20 20 20 20 20 20 43 4d 50 20 72 6f 6d 6e 75 | CMP romnu| 00002760 6d 62 65 72 0d 20 20 33 31 30 20 20 20 20 20 20 |mber. 310 | 00002770 20 20 20 42 43 43 20 6f 75 74 0d 20 20 33 32 30 | BCC out. 320| 00002780 20 20 20 20 20 20 20 20 20 4c 44 41 20 23 28 6c | LDA #(l| 00002790 61 73 74 62 79 74 65 2b 64 69 66 66 29 20 4d 4f |astbyte+diff) MO| 000027a0 44 20 32 35 36 0d 20 20 33 33 30 20 20 20 20 20 |D 256. 330 | 000027b0 20 20 20 20 53 54 41 20 72 6f 6d 70 6f 69 6e 74 | STA rompoint| 000027c0 0d 20 20 33 34 30 20 20 20 20 20 20 20 20 20 4c |. 340 L| 000027d0 44 41 20 23 28 6c 61 73 74 62 79 74 65 2b 64 69 |DA #(lastbyte+di| 000027e0 66 66 29 20 44 49 56 20 32 35 36 0d 20 20 33 35 |ff) DIV 256. 35| 000027f0 30 20 20 20 20 20 20 20 20 20 53 54 41 20 72 6f |0 STA ro| 00002800 6d 70 6f 69 6e 74 2b 31 0d 20 20 33 36 30 20 20 |mpoint+1. 360 | 00002810 20 20 20 20 20 20 20 4c 44 41 20 72 6f 6d 6e 75 | LDA romnu| 00002820 6d 62 65 72 0d 20 20 33 37 30 20 20 20 20 20 20 |mber. 370 | 00002830 20 20 20 45 4f 52 20 23 26 46 0d 20 20 33 38 30 | EOR #&F. 380| 00002840 20 20 20 20 20 20 20 20 20 53 54 41 20 70 68 72 | STA phr| 00002850 6f 6d 0d 20 20 33 39 30 20 2e 65 78 69 74 0d 20 |om. 390 .exit. | 00002860 20 34 30 30 20 20 20 20 20 20 20 20 20 50 4c 41 | 400 PLA| 00002870 0d 20 20 34 31 30 20 20 20 20 20 20 20 20 20 4c |. 410 L| 00002880 44 41 20 23 30 0d 20 20 34 32 30 20 20 20 20 20 |DA #0. 420 | 00002890 20 20 20 20 52 54 53 0d 20 20 34 33 30 20 2e 66 | RTS. 430 .f| 000028a0 6f 75 72 74 65 65 6e 0d 20 20 34 34 30 20 20 20 |ourteen. 440 | 000028b0 20 20 20 20 20 20 43 4d 50 20 23 31 34 0d 20 20 | CMP #14. | 000028c0 34 35 30 20 20 20 20 20 20 20 20 20 42 4e 45 20 |450 BNE | 000028d0 6f 75 74 0d 20 20 34 36 30 20 20 20 20 20 20 20 |out. 460 | 000028e0 20 20 4c 44 41 20 70 68 72 6f 6d 0d 20 20 34 37 | LDA phrom. 47| 000028f0 30 20 20 20 20 20 20 20 20 20 45 4f 52 20 23 26 |0 EOR #&| 00002900 46 0d 20 20 34 38 30 20 20 20 20 20 20 20 20 20 |F. 480 | 00002910 43 4d 50 20 72 6f 6d 6e 75 6d 62 65 72 0d 20 20 |CMP romnumber. | 00002920 34 39 30 20 20 20 20 20 20 20 20 20 42 4e 45 20 |490 BNE | 00002930 6f 75 74 0d 20 20 35 30 30 20 20 20 20 20 20 20 |out. 500 | 00002940 20 20 4c 44 59 20 23 30 0d 20 20 35 31 30 20 20 | LDY #0. 510 | 00002950 20 20 20 20 20 20 20 4c 44 41 20 28 72 6f 6d 70 | LDA (romp| 00002960 6f 69 6e 74 29 2c 59 0d 20 20 35 32 30 20 20 20 |oint),Y. 520 | 00002970 20 20 20 20 20 20 54 41 59 0d 20 20 35 33 30 20 | TAY. 530 | 00002980 20 20 20 20 20 20 20 20 49 4e 43 20 72 6f 6d 70 | INC romp| 00002990 6f 69 6e 74 0d 20 20 35 34 30 20 20 20 20 20 20 |oint. 540 | 000029a0 20 20 20 42 4e 45 20 65 78 69 74 0d 20 20 35 35 | BNE exit. 55| 000029b0 30 20 20 20 20 20 20 20 20 20 49 4e 43 20 72 6f |0 INC ro| 000029c0 6d 70 6f 69 6e 74 2b 31 0d 20 20 35 36 30 20 20 |mpoint+1. 560 | 000029d0 20 20 20 20 20 20 20 4a 4d 50 20 65 78 69 74 2b | JMP exit+| 000029e0 64 69 66 66 0d 20 20 35 37 30 20 2e 6f 75 74 0d |diff. 570 .out.| 000029f0 20 20 35 38 30 20 20 20 20 20 20 20 20 20 50 4c | 580 PL| 00002a00 41 0d 20 20 35 39 30 20 20 20 20 20 20 20 20 20 |A. 590 | 00002a10 52 54 53 0d 20 20 36 30 30 20 2e 6c 61 73 74 62 |RTS. 600 .lastb| 00002a20 79 74 65 0d 20 20 36 31 30 20 5d 0d 20 20 36 32 |yte. 610 ]. 62| 00002a30 30 20 4e 45 58 54 0d 20 20 36 33 30 20 4f 25 3d |0 NEXT. 630 O%=| 00002a40 6c 61 73 74 62 79 74 65 0d 20 20 36 34 30 20 43 |lastbyte. 640 C| 00002a50 48 41 49 4e 22 52 46 53 47 45 4e 22 0d 20 20 36 |HAIN"RFSGEN". 6| 00002a60 35 30 20 44 45 46 46 4e 65 71 75 62 28 62 79 74 |50 DEFFNequb(byt| 00002a70 65 29 0d 20 20 36 36 30 20 3f 50 25 3d 62 79 74 |e). 660 ?P%=byt| 00002a80 65 0d 20 20 36 37 30 20 50 25 3d 50 25 2b 31 0d |e. 670 P%=P%+1.| 00002a90 20 20 36 38 30 20 3d 70 61 73 73 0d 20 20 36 39 | 680 =pass. 69| 00002aa0 30 20 44 45 46 46 4e 65 71 75 77 28 77 6f 72 64 |0 DEFFNequw(word| 00002ab0 29 0d 20 20 37 30 30 20 3f 50 25 3d 77 6f 72 64 |). 700 ?P%=word| 00002ac0 20 4d 4f 44 20 32 35 36 0d 20 20 37 31 30 20 50 | MOD 256. 710 P| 00002ad0 25 3f 31 3d 77 6f 72 64 20 44 49 56 20 32 35 36 |%?1=word DIV 256| 00002ae0 0d 20 20 37 32 30 20 50 25 3d 50 25 2b 32 0d 20 |. 720 P%=P%+2. | 00002af0 20 37 33 30 20 3d 70 61 73 73 0d 20 20 37 34 30 | 730 =pass. 740| 00002b00 20 44 45 46 46 4e 65 71 75 64 28 64 6f 75 62 6c | DEFFNequd(doubl| 00002b10 65 29 0d 20 20 37 35 30 20 21 50 25 3d 64 6f 75 |e). 750 !P%=dou| 00002b20 62 6c 65 0d 20 20 37 36 30 20 50 25 3d 50 25 2b |ble. 760 P%=P%+| 00002b30 34 0d 20 20 37 37 30 20 3d 70 61 73 73 0d 20 20 |4. 770 =pass. | 00002b40 37 38 30 20 44 45 46 46 4e 65 71 75 73 28 73 74 |780 DEFFNequs(st| 00002b50 72 69 6e 67 24 29 0d 20 20 37 39 30 20 24 50 25 |ring$). 790 $P%| 00002b60 3d 73 74 72 69 6e 67 24 0d 20 20 38 30 30 20 50 |=string$. 800 P| 00002b70 25 3d 50 25 2b 4c 45 4e 28 73 74 72 69 6e 67 24 |%=P%+LEN(string$| 00002b80 29 0d 20 20 38 31 30 20 3d 70 61 73 73 0d 0d 0d |). 810 =pass...| 00002b90 0d 0d 0d 20 20 20 31 30 20 52 45 4d 3a 20 52 46 |... 10 REM: RF| 00002ba0 53 47 45 4e 0d 20 20 20 32 30 20 49 46 48 25 3c |SGEN. 20 IFH%<| 00002bb0 3e 48 49 4d 45 4d 20 45 4e 44 0d 20 20 20 33 30 |>HIMEM END. 30| 00002bc0 20 44 49 4d 20 70 62 6c 6f 63 6b 20 32 30 2c 6e | DIM pblock 20,n| 00002bd0 61 6d 65 20 32 30 2c 6d 63 6f 64 65 20 35 30 0d |ame 20,mcode 50.| 00002be0 20 20 20 34 30 20 6f 73 61 72 67 73 3d 26 46 46 | 40 osargs=&FF| 00002bf0 44 41 0d 20 20 20 35 30 20 6f 73 66 69 6c 65 3d |DA. 50 osfile=| 00002c00 26 46 46 44 44 0d 20 20 20 36 30 20 6f 73 63 6c |&FFDD. 60 oscl| 00002c10 69 3d 26 46 46 46 37 0d 20 20 20 37 30 20 61 64 |i=&FFF7. 70 ad| 00002c20 64 72 65 73 73 3d 26 37 30 0d 20 20 20 38 30 20 |dress=&70. 80 | 00002c30 68 69 67 68 3d 26 37 32 0d 20 20 20 39 30 20 6c |high=&72. 90 l| 00002c40 6f 77 3d 26 37 33 0d 20 20 31 30 30 20 6c 61 73 |ow=&73. 100 las| 00002c50 74 3d 26 37 34 0d 20 20 31 31 30 20 66 69 6e 69 |t=&74. 110 fini| 00002c60 73 68 3d 46 41 4c 53 45 0d 20 20 31 32 30 20 41 |sh=FALSE. 120 A| 00002c70 25 3d 30 0d 20 20 31 33 30 20 58 25 3d 30 0d 20 |%=0. 130 X%=0. | 00002c80 20 31 34 30 20 59 25 3d 30 0d 20 20 31 35 30 20 | 140 Y%=0. 150 | 00002c90 64 69 73 63 3d 55 53 52 28 6f 73 61 72 67 73 29 |disc=USR(osargs)| 00002ca0 41 4e 44 20 26 30 30 30 30 30 30 46 46 0d 20 20 |AND &000000FF. | 00002cb0 31 36 30 20 49 46 64 69 73 63 3d 31 20 4f 52 20 |160 IFdisc=1 OR | 00002cc0 64 69 73 63 3d 32 20 64 69 73 63 3d 46 41 4c 53 |disc=2 disc=FALS| 00002cd0 45 20 45 4c 53 45 20 64 69 73 63 3d 54 52 55 45 |E ELSE disc=TRUE| 00002ce0 0d 20 20 31 37 30 20 46 4f 52 70 61 73 73 3d 30 |. 170 FORpass=0| 00002cf0 20 54 4f 20 32 20 53 54 45 50 20 32 0d 20 20 31 | TO 2 STEP 2. 1| 00002d00 38 30 20 50 25 3d 6d 63 6f 64 65 0d 20 20 31 39 |80 P%=mcode. 19| 00002d10 30 20 5b 20 20 20 20 20 20 20 4f 50 54 20 70 61 |0 [ OPT pa| 00002d20 73 73 0d 20 20 32 30 30 20 20 20 20 20 20 20 20 |ss. 200 | 00002d30 20 4c 44 41 20 23 30 0d 20 20 32 31 30 20 20 20 | LDA #0. 210 | 00002d40 20 20 20 20 20 20 53 54 41 20 68 69 67 68 0d 20 | STA high. | 00002d50 20 32 32 30 20 20 20 20 20 20 20 20 20 53 54 41 | 220 STA| 00002d60 20 6c 6f 77 0d 20 20 32 33 30 20 20 20 20 20 20 | low. 230 | 00002d70 20 20 20 54 41 59 0d 20 20 32 34 30 20 2e 6e 65 | TAY. 240 .ne| 00002d80 78 74 62 79 74 65 0d 20 20 32 35 30 20 20 20 20 |xtbyte. 250 | 00002d90 20 20 20 20 20 4c 44 41 20 68 69 67 68 0d 20 20 | LDA high. | 00002da0 32 36 30 20 20 20 20 20 20 20 20 20 45 4f 52 20 |260 EOR | 00002db0 28 61 64 64 72 65 73 73 29 2c 59 0d 20 20 32 37 |(address),Y. 27| 00002dc0 30 20 20 20 20 20 20 20 20 20 53 54 41 20 68 69 |0 STA hi| 00002dd0 67 68 0d 20 20 32 38 30 20 20 20 20 20 20 20 20 |gh. 280 | 00002de0 20 4c 44 58 20 23 38 0d 20 20 32 39 30 20 2e 6c | LDX #8. 290 .l| 00002df0 6f 6f 70 0d 20 20 33 30 30 20 20 20 20 20 20 20 |oop. 300 | 00002e00 20 20 4c 44 41 20 68 69 67 68 0d 20 20 33 31 30 | LDA high. 310| 00002e10 20 20 20 20 20 20 20 20 20 52 4f 4c 20 41 0d 20 | ROL A. | 00002e20 20 33 32 30 20 20 20 20 20 20 20 20 20 42 43 43 | 320 BCC| 00002e30 20 72 6f 74 61 74 65 0d 20 20 33 33 30 20 20 20 | rotate. 330 | 00002e40 20 20 20 20 20 20 4c 44 41 20 68 69 67 68 0d 20 | LDA high. | 00002e50 20 33 34 30 20 20 20 20 20 20 20 20 20 45 4f 52 | 340 EOR| 00002e60 20 23 38 0d 20 20 33 35 30 20 20 20 20 20 20 20 | #8. 350 | 00002e70 20 20 53 54 41 20 68 69 67 68 0d 20 20 33 36 30 | STA high. 360| 00002e80 20 20 20 20 20 20 20 20 20 4c 44 41 20 6c 6f 77 | LDA low| 00002e90 0d 20 20 33 37 30 20 20 20 20 20 20 20 20 20 45 |. 370 E| 00002ea0 4f 52 20 23 26 31 30 0d 20 20 33 38 30 20 20 20 |OR #&10. 380 | 00002eb0 20 20 20 20 20 20 53 54 41 20 6c 6f 77 0d 20 20 | STA low. | 00002ec0 33 39 30 20 2e 72 6f 74 61 74 65 0d 20 20 34 30 |390 .rotate. 40| 00002ed0 30 20 20 20 20 20 20 20 20 20 52 4f 4c 20 6c 6f |0 ROL lo| 00002ee0 77 0d 20 20 34 31 30 20 20 20 20 20 20 20 20 20 |w. 410 | 00002ef0 52 4f 4c 20 68 69 67 68 0d 20 20 34 32 30 20 20 |ROL high. 420 | 00002f00 20 20 20 20 20 20 20 44 45 58 0d 20 20 34 33 30 | DEX. 430| 00002f10 20 20 20 20 20 20 20 20 20 42 4e 45 20 6c 6f 6f | BNE loo| 00002f20 70 0d 20 20 34 34 30 20 20 20 20 20 20 20 20 20 |p. 440 | 00002f30 49 4e 59 0d 20 20 34 35 30 20 20 20 20 20 20 20 |INY. 450 | 00002f40 20 20 43 50 59 20 6c 61 73 74 0d 20 20 34 36 30 | CPY last. 460| 00002f50 20 20 20 20 20 20 20 20 20 42 4e 45 20 6e 65 78 | BNE nex| 00002f60 74 62 79 74 65 0d 20 20 34 37 30 20 20 20 20 20 |tbyte. 470 | 00002f70 20 20 20 20 52 54 53 0d 20 20 34 38 30 20 5d 0d | RTS. 480 ].| 00002f80 20 20 34 39 30 20 4e 45 58 54 0d 20 20 35 30 30 | 490 NEXT. 500| 00002f90 20 49 46 20 64 69 73 63 20 3a 20 2a 43 41 54 0d | IF disc : *CAT.| 00002fa0 20 20 35 31 30 20 50 52 49 4e 54 27 22 50 72 65 | 510 PRINT'"Pre| 00002fb0 73 73 20 3c 52 45 54 55 52 4e 3e 20 74 6f 20 65 |ss <RETURN> to e| 00002fc0 6e 64 22 27 0d 20 20 35 32 30 20 52 45 50 45 41 |nd"'. 520 REPEA| 00002fd0 54 0d 20 20 35 33 30 20 49 4e 50 55 54 4c 49 4e |T. 530 INPUTLIN| 00002fe0 45 22 45 6e 74 65 72 20 66 69 6c 65 20 6e 61 6d |E"Enter file nam| 00002ff0 65 20 3d 20 22 24 6e 61 6d 65 0d 20 20 35 34 30 |e = "$name. 540| 00003000 20 49 46 20 24 6e 61 6d 65 3d 22 22 20 66 69 6e | IF $name="" fin| 00003010 69 73 68 3d 54 52 55 45 0d 20 20 35 35 30 20 49 |ish=TRUE. 550 I| 00003020 46 20 4e 4f 54 20 64 69 73 63 20 50 52 4f 43 74 |F NOT disc PROCt| 00003030 61 70 65 0d 20 20 35 36 30 20 49 46 20 4e 4f 54 |ape. 560 IF NOT| 00003040 20 66 69 6e 69 73 68 20 50 52 4f 43 66 69 6c 65 | finish PROCfile| 00003050 0d 20 20 35 37 30 20 55 4e 54 49 4c 20 66 69 6e |. 570 UNTIL fin| 00003060 69 73 68 0d 20 20 35 38 30 20 3f 4f 25 3d 41 53 |ish. 580 ?O%=AS| 00003070 43 28 22 2b 22 29 0d 20 20 35 39 30 20 49 4e 50 |C("+"). 590 INP| 00003080 55 54 27 22 53 61 76 65 20 66 69 6c 65 6e 61 6d |UT'"Save filenam| 00003090 65 20 3d 20 22 66 69 6c 65 6e 61 6d 65 24 0d 20 |e = "filename$. | 000030a0 20 36 30 30 20 49 46 20 66 69 6c 65 6e 61 6d 65 | 600 IF filename| 000030b0 24 3d 22 22 20 45 4e 44 0d 20 20 36 31 30 20 24 |$="" END. 610 $| 000030c0 6d 63 6f 64 65 3d 22 53 41 56 45 20 22 2b 66 69 |mcode="SAVE "+fi| 000030d0 6c 65 6e 61 6d 65 24 2b 22 20 22 2b 53 54 52 24 |lename$+" "+STR$| 000030e0 7e 28 48 49 4d 45 4d 29 2b 22 20 22 2b 53 54 52 |~(HIMEM)+" "+STR| 000030f0 24 7e 28 4f 25 0d 20 20 20 20 20 20 2b 31 29 2b |$~(O%. +1)+| 00003100 22 20 46 46 46 46 38 30 30 30 20 46 46 46 46 38 |" FFFF8000 FFFF8| 00003110 30 30 30 22 0d 20 20 36 32 30 20 58 25 3d 6d 63 |000". 620 X%=mc| 00003120 6f 64 65 20 4d 4f 44 20 32 35 36 0d 20 20 36 33 |ode MOD 256. 63| 00003130 30 20 59 25 3d 6d 63 6f 64 65 20 44 49 56 20 32 |0 Y%=mcode DIV 2| 00003140 35 36 0d 20 20 36 34 30 20 2a 4f 50 54 31 2c 32 |56. 640 *OPT1,2| 00003150 0d 20 20 36 35 30 20 43 41 4c 4c 20 6f 73 63 6c |. 650 CALL oscl| 00003160 69 0d 20 20 36 36 30 20 2a 4f 50 54 31 2c 30 0d |i. 660 *OPT1,0.| 00003170 20 20 36 37 30 20 45 4e 44 0d 20 20 36 38 30 20 | 670 END. 680 | 00003180 44 45 46 50 52 4f 43 66 69 6c 65 0d 20 20 36 39 |DEFPROCfile. 69| 00003190 30 20 63 68 61 6e 6e 65 6c 3d 4f 50 45 4e 55 50 |0 channel=OPENUP| 000031a0 28 24 6e 61 6d 65 29 0d 20 20 37 30 30 20 49 46 |($name). 700 IF| 000031b0 63 68 61 6e 6e 65 6c 3d 30 20 50 52 49 4e 54 22 |channel=0 PRINT"| 000031c0 46 69 6c 65 20 6e 6f 74 20 66 6f 75 6e 64 22 20 |File not found" | 000031d0 3a 20 43 4c 4f 53 45 23 63 68 61 6e 6e 65 6c 20 |: CLOSE#channel | 000031e0 3a 20 45 4e 44 50 52 4f 43 0d 20 20 37 31 30 20 |: ENDPROC. 710 | 000031f0 21 70 62 6c 6f 63 6b 3d 6e 61 6d 65 0d 20 20 37 |!pblock=name. 7| 00003200 32 30 20 49 46 20 64 69 73 63 20 50 52 4f 43 64 |20 IF disc PROCd| 00003210 69 73 63 0d 20 20 37 33 30 20 6c 65 6e 61 6d 65 |isc. 730 lename| 00003220 3d 4c 45 4e 28 24 6e 61 6d 65 29 2b 32 33 0d 20 |=LEN($name)+23. | 00003230 20 37 34 30 20 6e 65 78 74 66 69 6c 65 3d 26 38 | 740 nextfile=&8| 00003240 30 30 30 2b 4f 25 2d 48 49 4d 45 4d 2b 6c 65 6e |000+O%-HIMEM+len| 00003250 61 6d 65 2d 6c 65 6e 61 6d 65 2a 28 66 73 69 7a |ame-lename*(fsiz| 00003260 65 3e 32 35 36 29 2d 33 2a 0d 20 20 20 20 20 20 |e>256)-3*. | 00003270 28 66 73 69 7a 65 3e 35 31 32 29 2a 28 28 28 66 |(fsize>512)*(((f| 00003280 73 69 7a 65 2d 31 29 44 49 56 32 35 36 29 2d 31 |size-1)DIV256)-1| 00003290 29 20 2b 20 66 73 69 7a 65 0d 20 20 37 35 30 20 |) + fsize. 750 | 000032a0 49 46 20 6e 65 78 74 66 69 6c 65 20 3e 20 26 42 |IF nextfile > &B| 000032b0 46 46 45 20 50 52 49 4e 54 22 46 69 6c 65 20 74 |FFE PRINT"File t| 000032c0 6f 6f 20 62 69 67 22 20 3a 20 43 4c 4f 53 45 23 |oo big" : CLOSE#| 000032d0 63 68 61 6e 6e 65 6c 0d 20 20 20 20 20 20 3a 20 |channel. : | 000032e0 45 4e 44 50 52 4f 43 0d 20 20 37 36 30 20 62 6c |ENDPROC. 760 bl| 000032f0 6f 63 6b 3d 30 0d 20 20 37 37 30 20 49 46 66 73 |ock=0. 770 IFfs| 00003300 69 7a 65 3e 32 35 36 20 50 52 4f 43 66 69 72 73 |ize>256 PROCfirs| 00003310 74 0d 20 20 37 38 30 20 50 52 4f 43 68 65 61 64 |t. 780 PROChead| 00003320 65 72 28 31 32 38 2c 66 73 69 7a 65 29 0d 20 20 |er(128,fsize). | 00003330 37 39 30 20 43 4c 4f 53 45 23 63 68 61 6e 6e 65 |790 CLOSE#channe| 00003340 6c 0d 20 20 38 30 30 20 45 4e 44 50 52 4f 43 0d |l. 800 ENDPROC.| 00003350 20 20 38 31 30 20 44 45 46 50 52 4f 43 68 65 61 | 810 DEFPROChea| 00003360 64 65 72 28 66 6c 61 67 2c 6c 65 6e 67 74 68 29 |der(flag,length)| 00003370 0d 20 20 38 32 30 20 6c 65 6e 61 6d 65 3d 4c 45 |. 820 lename=LE| 00003380 4e 28 24 6e 61 6d 65 29 0d 20 20 38 33 30 20 3f |N($name). 830 ?| 00003390 4f 25 3d 41 53 43 28 22 2a 22 29 0d 20 20 38 34 |O%=ASC("*"). 84| 000033a0 30 20 4f 25 3d 4f 25 2b 31 0d 20 20 38 35 30 20 |0 O%=O%+1. 850 | 000033b0 24 4f 25 3d 24 6e 61 6d 65 0d 20 20 38 36 30 20 |$O%=$name. 860 | 000033c0 4f 25 3d 6c 65 6e 61 6d 65 2b 4f 25 0d 20 20 38 |O%=lename+O%. 8| 000033d0 37 30 20 3f 4f 25 3d 30 0d 20 20 38 38 30 20 4f |70 ?O%=0. 880 O| 000033e0 25 21 31 3d 6c 6f 61 64 0d 20 20 38 39 30 20 4f |%!1=load. 890 O| 000033f0 25 21 35 3d 65 78 65 63 0d 20 20 39 30 30 20 4f |%!5=exec. 900 O| 00003400 25 21 39 3d 62 6c 6f 63 6b 0d 20 20 39 31 30 20 |%!9=block. 910 | 00003410 4f 25 21 31 31 3d 6c 65 6e 67 74 68 0d 20 20 39 |O%!11=length. 9| 00003420 32 30 20 4f 25 3f 31 33 3d 66 6c 61 67 0d 20 20 |20 O%?13=flag. | 00003430 39 33 30 20 4f 25 21 31 34 3d 6e 65 78 74 66 69 |930 O%!14=nextfi| 00003440 6c 65 0d 20 20 39 34 30 20 3f 6c 61 73 74 3d 6c |le. 940 ?last=l| 00003450 65 6e 61 6d 65 2b 31 38 0d 20 20 39 35 30 20 21 |ename+18. 950 !| 00003460 61 64 64 72 65 73 73 3d 4f 25 2d 6c 65 6e 61 6d |address=O%-lenam| 00003470 65 0d 20 20 39 36 30 20 43 41 4c 4c 20 6d 63 6f |e. 960 CALL mco| 00003480 64 65 0d 20 20 39 37 30 20 4f 25 21 31 38 3d 21 |de. 970 O%!18=!| 00003490 68 69 67 68 0d 20 20 39 38 30 20 4f 25 3d 4f 25 |high. 980 O%=O%| 000034a0 2b 32 30 0d 20 20 39 39 30 20 50 52 4f 43 72 65 |+20. 990 PROCre| 000034b0 61 64 28 6c 65 6e 67 74 68 29 0d 20 31 30 30 30 |ad(length). 1000| 000034c0 20 62 6c 6f 63 6b 3d 62 6c 6f 63 6b 2b 31 0d 20 | block=block+1. | 000034d0 31 30 31 30 20 45 4e 44 50 52 4f 43 0d 20 31 30 |1010 ENDPROC. 10| 000034e0 32 30 20 44 45 46 50 52 4f 43 72 65 61 64 28 6c |20 DEFPROCread(l| 000034f0 65 6e 67 74 68 29 0d 20 31 30 33 30 20 4a 25 3d |ength). 1030 J%=| 00003500 6c 65 6e 67 74 68 2d 31 0d 20 31 30 34 30 20 46 |length-1. 1040 F| 00003510 4f 52 49 25 3d 30 54 4f 4a 25 0d 20 31 30 35 30 |ORI%=0TOJ%. 1050| 00003520 20 4f 25 3f 49 25 3d 42 47 45 54 23 63 68 61 6e | O%?I%=BGET#chan| 00003530 6e 65 6c 0d 20 31 30 36 30 20 4e 45 58 54 0d 20 |nel. 1060 NEXT. | 00003540 31 30 37 30 20 21 61 64 64 72 65 73 73 3d 4f 25 |1070 !address=O%| 00003550 0d 20 31 30 38 30 20 3f 6c 61 73 74 3d 6c 65 6e |. 1080 ?last=len| 00003560 67 74 68 0d 20 31 30 39 30 20 43 41 4c 4c 20 6d |gth. 1090 CALL m| 00003570 63 6f 64 65 0d 20 31 31 30 30 20 4f 25 21 6c 65 |code. 1100 O%!le| 00003580 6e 67 74 68 3d 21 68 69 67 68 0d 20 31 31 31 30 |ngth=!high. 1110| 00003590 20 66 73 69 7a 65 3d 66 73 69 7a 65 2d 6c 65 6e | fsize=fsize-len| 000035a0 67 74 68 0d 20 31 31 32 30 20 4f 25 3d 4f 25 2b |gth. 1120 O%=O%+| 000035b0 6c 65 6e 67 74 68 2b 32 0d 20 31 31 33 30 20 45 |length+2. 1130 E| 000035c0 4e 44 50 52 4f 43 0d 20 31 31 34 30 20 44 45 46 |NDPROC. 1140 DEF| 000035d0 50 52 4f 43 66 69 72 73 74 0d 20 31 31 35 30 20 |PROCfirst. 1150 | 000035e0 50 52 4f 43 68 65 61 64 65 72 28 30 2c 32 35 36 |PROCheader(0,256| 000035f0 29 0d 20 31 31 36 30 20 49 46 66 73 69 7a 65 3c |). 1160 IFfsize<| 00003600 3d 32 35 36 20 45 4e 44 50 52 4f 43 0d 20 31 31 |=256 ENDPROC. 11| 00003610 37 30 20 52 45 50 45 41 54 0d 20 31 31 38 30 20 |70 REPEAT. 1180 | 00003620 3f 4f 25 3d 41 53 43 28 22 23 22 29 0d 20 31 31 |?O%=ASC("#"). 11| 00003630 39 30 20 4f 25 3d 4f 25 2b 31 0d 20 31 32 30 30 |90 O%=O%+1. 1200| 00003640 20 50 52 4f 43 72 65 61 64 28 32 35 36 29 0d 20 | PROCread(256). | 00003650 31 32 31 30 20 62 6c 6f 63 6b 3d 62 6c 6f 63 6b |1210 block=block| 00003660 2b 31 0d 20 31 32 32 30 20 55 4e 54 49 4c 20 66 |+1. 1220 UNTIL f| 00003670 73 69 7a 65 3c 3d 32 35 36 0d 20 31 32 33 30 20 |size<=256. 1230 | 00003680 45 4e 44 50 52 4f 43 0d 20 31 32 34 30 20 44 45 |ENDPROC. 1240 DE| 00003690 46 50 52 4f 43 74 61 70 65 0d 20 31 32 35 30 20 |FPROCtape. 1250 | 000036a0 49 46 20 66 69 6e 69 73 68 20 45 4e 44 50 52 4f |IF finish ENDPRO| 000036b0 43 0d 20 31 32 36 30 20 49 4e 50 55 54 27 22 4c |C. 1260 INPUT'"L| 000036c0 6f 61 64 20 61 64 64 72 65 73 73 20 3d 20 26 22 |oad address = &"| 000036d0 6c 24 0d 20 31 32 37 30 20 6c 6f 61 64 3d 45 56 |l$. 1270 load=EV| 000036e0 41 4c 28 22 26 22 2b 6c 24 29 0d 20 31 32 38 30 |AL("&"+l$). 1280| 000036f0 20 49 4e 50 55 54 22 45 78 65 63 20 61 64 64 72 | INPUT"Exec addr| 00003700 65 73 73 20 3d 20 26 22 6c 24 0d 20 31 32 39 30 |ess = &"l$. 1290| 00003710 20 65 78 65 63 3d 45 56 41 4c 28 22 26 22 2b 6c | exec=EVAL("&"+l| 00003720 24 29 0d 20 31 33 30 30 20 49 4e 50 55 54 22 46 |$). 1300 INPUT"F| 00003730 69 6c 65 20 6c 65 6e 67 74 68 20 20 3d 20 26 22 |ile length = &"| 00003740 6c 24 0d 20 31 33 31 30 20 66 73 69 7a 65 3d 45 |l$. 1310 fsize=E| 00003750 56 41 4c 28 22 26 22 2b 6c 24 29 0d 20 31 33 32 |VAL("&"+l$). 132| 00003760 30 20 2a 4f 50 54 31 2c 32 0d 20 31 33 33 30 20 |0 *OPT1,2. 1330 | 00003770 45 4e 44 50 52 4f 43 0d 20 31 33 34 30 20 44 45 |ENDPROC. 1340 DE| 00003780 46 50 52 4f 43 64 69 73 63 0d 20 31 33 35 30 20 |FPROCdisc. 1350 | 00003790 41 25 3d 35 0d 20 31 33 36 30 20 58 25 3d 70 62 |A%=5. 1360 X%=pb| 000037a0 6c 6f 63 6b 20 4d 4f 44 20 32 35 36 0d 20 31 33 |lock MOD 256. 13| 000037b0 37 30 20 59 25 3d 70 62 6c 6f 63 6b 20 44 49 56 |70 Y%=pblock DIV| 000037c0 20 32 35 36 0d 20 31 33 38 30 20 43 41 4c 4c 20 | 256. 1380 CALL | 000037d0 6f 73 66 69 6c 65 0d 20 31 33 39 30 20 6c 6f 61 |osfile. 1390 loa| 000037e0 64 3d 70 62 6c 6f 63 6b 21 32 0d 20 31 34 30 30 |d=pblock!2. 1400| 000037f0 20 65 78 65 63 3d 70 62 6c 6f 63 6b 21 36 0d 20 | exec=pblock!6. | 00003800 31 34 31 30 20 66 73 69 7a 65 3d 70 62 6c 6f 63 |1410 fsize=pbloc| 00003810 6b 21 31 30 0d 20 31 34 32 30 20 45 4e 44 50 52 |k!10. 1420 ENDPR| 00003820 4f 43 0d |OC.| 00003823