Home » CEEFAX disks » telesoftware8.adl » 22-07-88/T\SWR03
22-07-88/T\SWR03
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 » telesoftware8.adl |
Filename: | 22-07-88/T\SWR03 |
Read OK: | ✔ |
File size: | 2D97 bytes |
Load address: | 0000 |
Exec address: | 0000 |
Duplicates
There is 1 duplicate copy of this file in the archive:
- CEEFAX disks » telesoftware3.adl » 06_11_87/T\SWR03
- CEEFAX disks » telesoftware8.adl » 22-07-88/T\SWR03
File contents
Mastering Sideways ROM & RAM - Module 03 - One-command interpreter ------------------------------------------------------------------ In module 2 you were introduced to service calls, rom headers and interpreters. In this module I will show how to trap a service call and create an interpreter to recognise a new * command. If you type a command, such as *SILLY, which is not recognised by the MOS, the command is first offered to the sideways roms and then to the currently active filing system. Load the object code generated by the program TRACE into sideways ram and press the Break key. You will see the now familiar service call trace first used in module 2. Type a few * commands that the MOS will not recognise. Try *SILLY if you can't think of anything better. You will see the trace shown in figure 3.1. The MOS offers the command to the sideways roms using service call 4, Unrecognised Command. The NMI claim is used by the DFS and the Break service call is offered to all the roms before the "bad command" error message is printed by BASIC. >*SILLY A=04 X=0F Y=01 Unrecognised command A=0C X=0F Y=FF NMI claim A=06 X=0F Y=00 Break Bad command > Figure 3.1 Service trace for unrecognised command. -------------------------------------------------- When the unrecognised command service call is issued the roms are entered at the service entry point. &F2 and &F3 are used as text pointers to the command with an offset in the Y register pointing past the asterisk and any leading spaces. Try typing a few spaces after the asterisk and before the ASCII string of your command and watch the effect on the Y register in the trace. &F2 and &F3 point to the unrecognised command in the form of an ASCII string terminated by &0D. The interpreter has to use the text pointers and the Y register to compare every byte of the unrecognised command with every byte of your new command. If every pair of bytes is identical then the command is recognised and your new routine can be executed. If it is not recognised your rom image must return control to the MOS with all the registers preserved. A simple one-command interpreter can compare the title string in the header with the unrecognised command. You must choose the title string with care. It must only use upper case alphabetic characters (because the command will be forced to upper case by ANDing every character with #&DF) and it must not conflict with any other * commands used in your computer. You cannot use titles such as "SAVE" or "INFO" for obvious reasons but you should also beware of title strings such as "DESELECT" or "DRAW" which, if they are compared with the shortened commands *DES. and *DR., will conflict with DESTROY and DRIVE. Figure 3.2 illustrates one method of making the comparison and jumping to a new routine when the unrecognised command matches the title string. It uses absolute indexed addressing with the X register and post-indexed indirect addressing with the Y register to compare every byte of the title string with every byte of the unrecognised command. The service entry point of the rom image in figure 3.2 has a jump to the label ".service" which is the begining of the interpreter. .title EQUS "SILLY" \ title string in the header. BRK \ first byte of copyright string. . . . .service CMP #4 \ is it an unrecognised command? BEQ unrecognised \ branch if it is RTS \ return to MOS if it is not .unrecognised PHA \ push A TXA PHA \ push X TYA PHA \ push Y LDX #&FF \ initialise X .comloop INX \ increment offset on title string LDA title,X \ check if last byte of title. BEQ found \ branch if last byte of title. LDA (&F2),Y \ read next character of command. INY \ increment offset to next character CMP #ASC(".") \ is the character read a "."? BEQ found \ branch if it is a shortened command. AND #&DF \ force upper case. CMP title,X \ is it the same as the title character? BEQ comloop \ if it is compare next character PLA \ if not pull Y TAY \ restore Y PLA \ pull X TAX \ restore X PLA \ restore A RTS \ and return to MOS. .found . \ your new routine . \ goes in here . PLA \ pull Y and discard PLA \ pull X and discard PLA \ pull A and discard LDA #0 \ other roms ignore this request. RTS \ return to MOS Figure 3.2 An unrecognised * command interpreter. ------------------------------------------------- The trace program has shown you that, when an unrecognised * command is passed to the sideways roms, each rom is entered at the service entry point with the accumulator = 4, the X register = the number of the rom, and the Y register = the offset to the unrecognised command. The interpreter compares the accumulator with 4 to see if it is an unrecognised command. If it is control is passed to the label ".unrecognised", if it is not control is returned to the MOS with the A, X, and Y registers all unaltered. Before comparing the unrecognised command with the title string of the rom, the A, X and Y registers are pushed on the stack so that they can be restored if the unrecognised command is not identical to the title string. After pushing the registers every byte of the title string is compared with every byte of the unrecognised command. If the comparison fails before every byte has been compared the registers are restored and control is returned to the MOS. There are two conditions when the command is recognised by the interpreter. 1. If every byte of the unrecognised command is identical to every byte of the title string the interpreter will eventually read the zero byte at the end of the title. 2. If every byte of the title string is identical to every byte of the unrecognised command until a "." terminates the unrecognised command. When the unrecognised command has been recognised by the interpreter control is passed to the label ".found" which will be the beginning of any new routine you care to use. When your new routine has finished the Y, X and A registers pushed onto the stack by the interpreter must be pulled off and discarded. Your program must pull the Y, X and A registers off the stack but there is no need to transfer A to Y and X with the first two pulls because the index registers will be ignored when you return with A=0. After the third PLA, your program must load the accumulator with zero before returning to the MOS. This will inform all other roms that the service request has been recognised. This simple interpreter has been used to convert the program ZAP into its sideways ram equivalent NEWCOM. In the program ZAP the Assembly language coding from line 70 to line 230 is the equivalent of the BASIC ENVELOPE and SOUND commands. The program uses Osword 8 with a 14 byte parameter block (which corresponds with the 14 parameters in the ENVELOPE command) and Osword 7 with an 8 byte parameter block (which corresponds with the 4 parameters in the sound command). Line 270 executes the machine code generated by the Assembly language coding. When the program has been converted into sideways ram format and loaded into sideways ram the entire program can be replaced with the new command *ZAP. 10 REM: ZAP 20 DIM mcode 100 30 osword=&FFF1 40 FOR pass = 0 TO 2 STEP 2 50 P%=mcode 60 [ OPT pass 70 LDA #8 80 LDX #envelope MOD 256 90 LDY #envelope DIV 256 100 JSR osword 110 LDA #7 120 LDX #sound MOD 256 130 LDY #sound DIV 256 140 JSR osword 150 RTS 160 .envelope 170 OPT FNequd(&7FFC0101) 180 OPT FNequd(&8D65830A) 190 OPT FNequd(&8100FF7F) 200 OPT FNequw(&7E7E) 210 .sound 220 OPT FNequd(&00010011) 230 OPT FNequd(&00640000) 240 .lastbyte 250 ] 260 NEXT 270 CALL mcode 280 END 290 DEFFNequw(word) 300 ?P%=word MOD 256 310 P%?1=word DIV 256 320 P%=P%+2 330 =pass 340 DEFFNequd(double) 350 !P%=double 360 P%=P%+4 370 =pass The program NEWCOM illustrates the conversion into sideways ram format using the simple one-command interpreter described above. The rom type byte in line 170 of NEWCOM indicates to the MOS that the rom image has a service entry. The interpreter (lines 270-530) compares the unrecognised command with the title string and if they match contol is passed to the label ".found" in line 540. The code taken from the program ZAP is inserted after the label ".found" in NEWCOM but the RTS instruction in line 150 of ZAP has been replaced with PLA : PLA : PLA : LDA #0 : RTS in lines 630 to 670 of NEWCOM in order to balance the stack and load the accumulator with zero before returning control to the MOS. 10 REM: NEWCOM 20 MODE7 30 HIMEM=&3C00 40 DIM save 50 50 diff=&8000-HIMEM 60 comvec=&F2 70 gsread=&FFC5 80 osword=&FFF1 90 oscli=&FFF7 100 FOR pass = 0 TO 2 STEP 2 110 P%=HIMEM 120 [ OPT pass 130 BRK 140 BRK 150 BRK 160 JMP service+diff 170 OPT FNequb(&82) 180 OPT FNequb((copyright+diff) MOD 256) 190 BRK 200 .title 210 OPT FNequs("ZAP") 220 .copyright 230 BRK 240 OPT FNequs("(C) Gordon Horsington 1987") 250 BRK 260 .service 270 CMP #4 280 BEQ unrecognised 290 RTS 300 .unrecognised 310 PHA 320 TXA 330 PHA 340 TYA 350 PHA 360 LDX #&FF 370 .comloop 380 INX 390 LDA title+diff,X 400 BEQ found 410 LDA (comvec),Y 420 INY 430 CMP #ASC(".") 440 BEQ found 450 AND #&DF 460 CMP title+diff,X 470 BEQ comloop 480 PLA 490 TAY 500 PLA 510 TAX 520 PLA 530 RTS 540 .found 550 LDA #8 560 LDX #((envelope+diff) MOD 256) 570 LDY #((envelope+diff) DIV 256) 580 JSR osword 590 LDA #7 600 LDX #((sound+diff) MOD 256) 610 LDY #((sound+diff) DIV 256) 620 JSR osword 630 PLA 640 PLA 650 PLA 660 LDA #0 670 RTS 680 .envelope 690 OPT FNequd(&7FFC0101) 700 OPT FNequd(&8D65830A) 710 OPT FNequd(&8100FF7F) 720 OPT FNequw(&7E7E) 730 .sound 740 OPT FNequd(&00010011) 750 OPT FNequd(&00640000) 760 .lastbyte 770 ] 780 NEXT 790 INPUT'"Save filename = "filename$ 800 IF filename$="" END 810 $save="SAVE "+filename$+" "+STR$~(HIMEM)+" "+STR$~(las tbyte)+" FFFF8000 FFFF8000" 820 X%=save MOD 256 830 Y%=save DIV 256 840 *OPT1,2 850 CALL oscli 860 *OPT1,0 870 END 880 DEFFNequb(byte) 890 ?P%=byte 900 P%=P%+1 910 =pass 920 DEFFNequw(word) 930 ?P%=word MOD 256 940 P%?1=word DIV 256 950 P%=P%+2 960 =pass 970 DEFFNequd(double) 980 !P%=double 990 P%=P%+4 1000 =pass 1010 DEFFNequs(string$) 1020 $P%=string$ 1030 P%=P%+LEN(string$) 1040 =pass
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 30 33 20 2d 20 4f 6e 65 2d 63 |odule 03 - One-c| 00000030 6f 6d 6d 61 6e 64 20 69 6e 74 65 72 70 72 65 74 |ommand interpret| 00000040 65 72 0d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |er.-------------| 00000050 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 00000080 2d 2d 2d 2d 2d 0d 0d 20 20 49 6e 20 6d 6f 64 75 |-----.. In modu| 00000090 6c 65 20 32 20 79 6f 75 20 77 65 72 65 20 69 6e |le 2 you were in| 000000a0 74 72 6f 64 75 63 65 64 20 74 6f 20 73 65 72 76 |troduced to serv| 000000b0 69 63 65 20 63 61 6c 6c 73 2c 20 72 6f 6d 20 68 |ice calls, rom h| 000000c0 65 61 64 65 72 73 20 61 6e 64 0d 69 6e 74 65 72 |eaders and.inter| 000000d0 70 72 65 74 65 72 73 2e 20 49 6e 20 74 68 69 73 |preters. In this| 000000e0 20 6d 6f 64 75 6c 65 20 49 20 77 69 6c 6c 20 73 | module I will s| 000000f0 68 6f 77 20 68 6f 77 20 74 6f 20 74 72 61 70 20 |how how to trap | 00000100 61 20 73 65 72 76 69 63 65 20 63 61 6c 6c 0d 61 |a service call.a| 00000110 6e 64 20 63 72 65 61 74 65 20 61 6e 20 69 6e 74 |nd create an int| 00000120 65 72 70 72 65 74 65 72 20 74 6f 20 72 65 63 6f |erpreter to reco| 00000130 67 6e 69 73 65 20 61 20 6e 65 77 20 2a 20 63 6f |gnise a new * co| 00000140 6d 6d 61 6e 64 2e 0d 0d 20 20 49 66 20 79 6f 75 |mmand... If you| 00000150 20 74 79 70 65 20 61 20 63 6f 6d 6d 61 6e 64 2c | type a command,| 00000160 20 73 75 63 68 20 61 73 20 2a 53 49 4c 4c 59 2c | such as *SILLY,| 00000170 20 77 68 69 63 68 20 69 73 20 6e 6f 74 20 72 65 | which is not re| 00000180 63 6f 67 6e 69 73 65 64 20 62 79 0d 74 68 65 20 |cognised by.the | 00000190 4d 4f 53 2c 20 74 68 65 20 63 6f 6d 6d 61 6e 64 |MOS, the command| 000001a0 20 69 73 20 66 69 72 73 74 20 6f 66 66 65 72 65 | is first offere| 000001b0 64 20 74 6f 20 74 68 65 20 73 69 64 65 77 61 79 |d to the sideway| 000001c0 73 20 72 6f 6d 73 20 61 6e 64 20 74 68 65 6e 20 |s roms and then | 000001d0 74 6f 0d 74 68 65 20 63 75 72 72 65 6e 74 6c 79 |to.the currently| 000001e0 20 61 63 74 69 76 65 20 66 69 6c 69 6e 67 20 73 | active filing s| 000001f0 79 73 74 65 6d 2e 0d 0d 20 20 4c 6f 61 64 20 74 |ystem... Load t| 00000200 68 65 20 6f 62 6a 65 63 74 20 63 6f 64 65 20 67 |he object code g| 00000210 65 6e 65 72 61 74 65 64 20 62 79 20 74 68 65 20 |enerated by the | 00000220 70 72 6f 67 72 61 6d 20 54 52 41 43 45 20 69 6e |program TRACE in| 00000230 74 6f 20 73 69 64 65 77 61 79 73 0d 72 61 6d 20 |to sideways.ram | 00000240 61 6e 64 20 70 72 65 73 73 20 74 68 65 20 42 72 |and press the Br| 00000250 65 61 6b 20 6b 65 79 2e 20 59 6f 75 20 77 69 6c |eak key. You wil| 00000260 6c 20 73 65 65 20 74 68 65 20 6e 6f 77 20 66 61 |l see the now fa| 00000270 6d 69 6c 69 61 72 20 73 65 72 76 69 63 65 0d 63 |miliar service.c| 00000280 61 6c 6c 20 74 72 61 63 65 20 66 69 72 73 74 20 |all trace first | 00000290 75 73 65 64 20 69 6e 20 6d 6f 64 75 6c 65 20 32 |used in module 2| 000002a0 2e 20 54 79 70 65 20 61 20 66 65 77 20 2a 20 63 |. Type a few * c| 000002b0 6f 6d 6d 61 6e 64 73 20 74 68 61 74 20 74 68 65 |ommands that the| 000002c0 20 4d 4f 53 0d 77 69 6c 6c 20 6e 6f 74 20 72 65 | MOS.will not re| 000002d0 63 6f 67 6e 69 73 65 2e 20 54 72 79 20 2a 53 49 |cognise. Try *SI| 000002e0 4c 4c 59 20 69 66 20 79 6f 75 20 63 61 6e 27 74 |LLY if you can't| 000002f0 20 74 68 69 6e 6b 20 6f 66 20 61 6e 79 74 68 69 | think of anythi| 00000300 6e 67 20 62 65 74 74 65 72 2e 0d 59 6f 75 20 77 |ng better..You w| 00000310 69 6c 6c 20 73 65 65 20 74 68 65 20 74 72 61 63 |ill see the trac| 00000320 65 20 73 68 6f 77 6e 20 69 6e 20 66 69 67 75 72 |e shown in figur| 00000330 65 20 33 2e 31 2e 20 54 68 65 20 4d 4f 53 20 6f |e 3.1. The MOS o| 00000340 66 66 65 72 73 20 74 68 65 20 63 6f 6d 6d 61 6e |ffers the comman| 00000350 64 0d 74 6f 20 74 68 65 20 73 69 64 65 77 61 79 |d.to the sideway| 00000360 73 20 72 6f 6d 73 20 75 73 69 6e 67 20 73 65 72 |s roms using ser| 00000370 76 69 63 65 20 63 61 6c 6c 20 34 2c 20 55 6e 72 |vice call 4, Unr| 00000380 65 63 6f 67 6e 69 73 65 64 20 43 6f 6d 6d 61 6e |ecognised Comman| 00000390 64 2e 20 54 68 65 0d 4e 4d 49 20 63 6c 61 69 6d |d. The.NMI claim| 000003a0 20 69 73 20 75 73 65 64 20 62 79 20 74 68 65 20 | is used by the | 000003b0 44 46 53 20 61 6e 64 20 74 68 65 20 42 72 65 61 |DFS and the Brea| 000003c0 6b 20 73 65 72 76 69 63 65 20 63 61 6c 6c 20 69 |k service call i| 000003d0 73 20 6f 66 66 65 72 65 64 20 74 6f 0d 61 6c 6c |s offered to.all| 000003e0 20 74 68 65 20 72 6f 6d 73 20 62 65 66 6f 72 65 | the roms before| 000003f0 20 74 68 65 20 22 62 61 64 20 63 6f 6d 6d 61 6e | the "bad comman| 00000400 64 22 20 65 72 72 6f 72 20 6d 65 73 73 61 67 65 |d" error message| 00000410 20 69 73 20 70 72 69 6e 74 65 64 20 62 79 0d 42 | is printed by.B| 00000420 41 53 49 43 2e 0d 0d 0d 0d 3e 2a 53 49 4c 4c 59 |ASIC.....>*SILLY| 00000430 0d 20 41 3d 30 34 20 58 3d 30 46 20 59 3d 30 31 |. A=04 X=0F Y=01| 00000440 20 55 6e 72 65 63 6f 67 6e 69 73 65 64 20 63 6f | Unrecognised co| 00000450 6d 6d 61 6e 64 0d 20 41 3d 30 43 20 58 3d 30 46 |mmand. A=0C X=0F| 00000460 20 59 3d 46 46 20 4e 4d 49 20 63 6c 61 69 6d 0d | Y=FF NMI claim.| 00000470 20 41 3d 30 36 20 58 3d 30 46 20 59 3d 30 30 20 | A=06 X=0F Y=00 | 00000480 42 72 65 61 6b 0d 0d 42 61 64 20 63 6f 6d 6d 61 |Break..Bad comma| 00000490 6e 64 0d 3e 0d 0d 46 69 67 75 72 65 20 33 2e 31 |nd.>..Figure 3.1| 000004a0 20 53 65 72 76 69 63 65 20 74 72 61 63 65 20 66 | Service trace f| 000004b0 6f 72 20 75 6e 72 65 63 6f 67 6e 69 73 65 64 20 |or unrecognised | 000004c0 63 6f 6d 6d 61 6e 64 2e 0d 2d 2d 2d 2d 2d 2d 2d |command..-------| 000004d0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 000004f0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0d 0d 0d 20 |-----------.... | 00000500 20 57 68 65 6e 20 74 68 65 20 75 6e 72 65 63 6f | When the unreco| 00000510 67 6e 69 73 65 64 20 63 6f 6d 6d 61 6e 64 20 73 |gnised command s| 00000520 65 72 76 69 63 65 20 63 61 6c 6c 20 69 73 20 69 |ervice call is i| 00000530 73 73 75 65 64 20 74 68 65 20 72 6f 6d 73 20 61 |ssued the roms a| 00000540 72 65 0d 65 6e 74 65 72 65 64 20 61 74 20 74 68 |re.entered at th| 00000550 65 20 73 65 72 76 69 63 65 20 65 6e 74 72 79 20 |e service entry | 00000560 70 6f 69 6e 74 2e 20 26 46 32 20 61 6e 64 20 26 |point. &F2 and &| 00000570 46 33 20 61 72 65 20 75 73 65 64 20 61 73 20 74 |F3 are used as t| 00000580 65 78 74 0d 70 6f 69 6e 74 65 72 73 20 74 6f 20 |ext.pointers to | 00000590 74 68 65 20 63 6f 6d 6d 61 6e 64 20 77 69 74 68 |the command with| 000005a0 20 61 6e 20 6f 66 66 73 65 74 20 69 6e 20 74 68 | an offset in th| 000005b0 65 20 59 20 72 65 67 69 73 74 65 72 20 70 6f 69 |e Y register poi| 000005c0 6e 74 69 6e 67 20 70 61 73 74 0d 74 68 65 20 61 |nting past.the a| 000005d0 73 74 65 72 69 73 6b 20 61 6e 64 20 61 6e 79 20 |sterisk and any | 000005e0 6c 65 61 64 69 6e 67 20 73 70 61 63 65 73 2e 20 |leading spaces. | 000005f0 54 72 79 20 74 79 70 69 6e 67 20 61 20 66 65 77 |Try typing a few| 00000600 20 73 70 61 63 65 73 20 61 66 74 65 72 20 74 68 | spaces after th| 00000610 65 0d 61 73 74 65 72 69 73 6b 20 61 6e 64 20 62 |e.asterisk and b| 00000620 65 66 6f 72 65 20 74 68 65 20 41 53 43 49 49 20 |efore the ASCII | 00000630 73 74 72 69 6e 67 20 6f 66 20 79 6f 75 72 20 63 |string of your c| 00000640 6f 6d 6d 61 6e 64 20 61 6e 64 20 77 61 74 63 68 |ommand and watch| 00000650 20 74 68 65 0d 65 66 66 65 63 74 20 6f 6e 20 74 | the.effect on t| 00000660 68 65 20 59 20 72 65 67 69 73 74 65 72 20 69 6e |he Y register in| 00000670 20 74 68 65 20 74 72 61 63 65 2e 20 26 46 32 20 | the trace. &F2 | 00000680 61 6e 64 20 26 46 33 20 70 6f 69 6e 74 20 74 6f |and &F3 point to| 00000690 20 74 68 65 0d 75 6e 72 65 63 6f 67 6e 69 73 65 | the.unrecognise| 000006a0 64 20 63 6f 6d 6d 61 6e 64 20 69 6e 20 74 68 65 |d command in the| 000006b0 20 66 6f 72 6d 20 6f 66 20 61 6e 20 41 53 43 49 | form of an ASCI| 000006c0 49 20 73 74 72 69 6e 67 20 74 65 72 6d 69 6e 61 |I string termina| 000006d0 74 65 64 20 62 79 20 26 30 44 2e 0d 54 68 65 20 |ted by &0D..The | 000006e0 69 6e 74 65 72 70 72 65 74 65 72 20 68 61 73 20 |interpreter has | 000006f0 74 6f 20 75 73 65 20 74 68 65 20 74 65 78 74 20 |to use the text | 00000700 70 6f 69 6e 74 65 72 73 20 61 6e 64 20 74 68 65 |pointers and the| 00000710 20 59 20 72 65 67 69 73 74 65 72 20 74 6f 0d 63 | Y register to.c| 00000720 6f 6d 70 61 72 65 20 65 76 65 72 79 20 62 79 74 |ompare every byt| 00000730 65 20 6f 66 20 74 68 65 20 75 6e 72 65 63 6f 67 |e of the unrecog| 00000740 6e 69 73 65 64 20 63 6f 6d 6d 61 6e 64 20 77 69 |nised command wi| 00000750 74 68 20 65 76 65 72 79 20 62 79 74 65 20 6f 66 |th every byte of| 00000760 20 79 6f 75 72 0d 6e 65 77 20 63 6f 6d 6d 61 6e | your.new comman| 00000770 64 2e 20 49 66 20 65 76 65 72 79 20 70 61 69 72 |d. If every pair| 00000780 20 6f 66 20 62 79 74 65 73 20 69 73 20 69 64 65 | of bytes is ide| 00000790 6e 74 69 63 61 6c 20 74 68 65 6e 20 74 68 65 20 |ntical then the | 000007a0 63 6f 6d 6d 61 6e 64 20 69 73 0d 72 65 63 6f 67 |command is.recog| 000007b0 6e 69 73 65 64 20 61 6e 64 20 79 6f 75 72 20 6e |nised and your n| 000007c0 65 77 20 72 6f 75 74 69 6e 65 20 63 61 6e 20 62 |ew routine can b| 000007d0 65 20 65 78 65 63 75 74 65 64 2e 20 49 66 20 69 |e executed. If i| 000007e0 74 20 69 73 20 6e 6f 74 0d 72 65 63 6f 67 6e 69 |t is not.recogni| 000007f0 73 65 64 20 79 6f 75 72 20 72 6f 6d 20 69 6d 61 |sed your rom ima| 00000800 67 65 20 6d 75 73 74 20 72 65 74 75 72 6e 20 63 |ge must return c| 00000810 6f 6e 74 72 6f 6c 20 74 6f 20 74 68 65 20 4d 4f |ontrol to the MO| 00000820 53 20 77 69 74 68 20 61 6c 6c 20 74 68 65 0d 72 |S with all the.r| 00000830 65 67 69 73 74 65 72 73 20 70 72 65 73 65 72 76 |egisters preserv| 00000840 65 64 2e 0d 0d 20 20 41 20 73 69 6d 70 6c 65 20 |ed... A simple | 00000850 6f 6e 65 2d 63 6f 6d 6d 61 6e 64 20 69 6e 74 65 |one-command inte| 00000860 72 70 72 65 74 65 72 20 63 61 6e 20 63 6f 6d 70 |rpreter can comp| 00000870 61 72 65 20 74 68 65 20 74 69 74 6c 65 20 73 74 |are the title st| 00000880 72 69 6e 67 20 69 6e 20 74 68 65 0d 68 65 61 64 |ring in the.head| 00000890 65 72 20 77 69 74 68 20 74 68 65 20 75 6e 72 65 |er with the unre| 000008a0 63 6f 67 6e 69 73 65 64 20 63 6f 6d 6d 61 6e 64 |cognised command| 000008b0 2e 20 59 6f 75 20 6d 75 73 74 20 63 68 6f 6f 73 |. You must choos| 000008c0 65 20 74 68 65 20 74 69 74 6c 65 20 73 74 72 69 |e the title stri| 000008d0 6e 67 0d 77 69 74 68 20 63 61 72 65 2e 20 49 74 |ng.with care. It| 000008e0 20 6d 75 73 74 20 6f 6e 6c 79 20 75 73 65 20 75 | must only use u| 000008f0 70 70 65 72 20 63 61 73 65 20 61 6c 70 68 61 62 |pper case alphab| 00000900 65 74 69 63 20 63 68 61 72 61 63 74 65 72 73 20 |etic characters | 00000910 28 62 65 63 61 75 73 65 0d 74 68 65 20 63 6f 6d |(because.the com| 00000920 6d 61 6e 64 20 77 69 6c 6c 20 62 65 20 66 6f 72 |mand will be for| 00000930 63 65 64 20 74 6f 20 75 70 70 65 72 20 63 61 73 |ced to upper cas| 00000940 65 20 62 79 20 41 4e 44 69 6e 67 20 65 76 65 72 |e by ANDing ever| 00000950 79 20 63 68 61 72 61 63 74 65 72 0d 77 69 74 68 |y character.with| 00000960 20 23 26 44 46 29 20 61 6e 64 20 69 74 20 6d 75 | #&DF) and it mu| 00000970 73 74 20 6e 6f 74 20 63 6f 6e 66 6c 69 63 74 20 |st not conflict | 00000980 77 69 74 68 20 61 6e 79 20 6f 74 68 65 72 20 2a |with any other *| 00000990 20 63 6f 6d 6d 61 6e 64 73 20 75 73 65 64 20 69 | commands used i| 000009a0 6e 0d 79 6f 75 72 20 63 6f 6d 70 75 74 65 72 2e |n.your computer.| 000009b0 20 59 6f 75 20 63 61 6e 6e 6f 74 20 75 73 65 20 | You cannot use | 000009c0 74 69 74 6c 65 73 20 73 75 63 68 20 61 73 20 22 |titles such as "| 000009d0 53 41 56 45 22 20 6f 72 20 22 49 4e 46 4f 22 20 |SAVE" or "INFO" | 000009e0 66 6f 72 0d 6f 62 76 69 6f 75 73 20 72 65 61 73 |for.obvious reas| 000009f0 6f 6e 73 20 62 75 74 20 79 6f 75 20 73 68 6f 75 |ons but you shou| 00000a00 6c 64 20 61 6c 73 6f 20 62 65 77 61 72 65 20 6f |ld also beware o| 00000a10 66 20 74 69 74 6c 65 20 73 74 72 69 6e 67 73 20 |f title strings | 00000a20 73 75 63 68 20 61 73 0d 22 44 45 53 45 4c 45 43 |such as."DESELEC| 00000a30 54 22 20 6f 72 20 22 44 52 41 57 22 20 77 68 69 |T" or "DRAW" whi| 00000a40 63 68 2c 20 69 66 20 74 68 65 79 20 61 72 65 20 |ch, if they are | 00000a50 63 6f 6d 70 61 72 65 64 20 77 69 74 68 20 74 68 |compared with th| 00000a60 65 20 73 68 6f 72 74 65 6e 65 64 0d 63 6f 6d 6d |e shortened.comm| 00000a70 61 6e 64 73 20 2a 44 45 53 2e 20 61 6e 64 20 2a |ands *DES. and *| 00000a80 44 52 2e 2c 20 77 69 6c 6c 20 63 6f 6e 66 6c 69 |DR., will confli| 00000a90 63 74 20 77 69 74 68 20 44 45 53 54 52 4f 59 20 |ct with DESTROY | 00000aa0 61 6e 64 20 44 52 49 56 45 2e 0d 0d 20 20 46 69 |and DRIVE... Fi| 00000ab0 67 75 72 65 20 33 2e 32 20 69 6c 6c 75 73 74 72 |gure 3.2 illustr| 00000ac0 61 74 65 73 20 6f 6e 65 20 6d 65 74 68 6f 64 20 |ates one method | 00000ad0 6f 66 20 6d 61 6b 69 6e 67 20 74 68 65 20 63 6f |of making the co| 00000ae0 6d 70 61 72 69 73 6f 6e 20 61 6e 64 0d 6a 75 6d |mparison and.jum| 00000af0 70 69 6e 67 20 74 6f 20 61 20 6e 65 77 20 72 6f |ping to a new ro| 00000b00 75 74 69 6e 65 20 77 68 65 6e 20 74 68 65 20 75 |utine when the u| 00000b10 6e 72 65 63 6f 67 6e 69 73 65 64 20 63 6f 6d 6d |nrecognised comm| 00000b20 61 6e 64 20 6d 61 74 63 68 65 73 20 74 68 65 0d |and matches the.| 00000b30 74 69 74 6c 65 20 73 74 72 69 6e 67 2e 20 49 74 |title string. It| 00000b40 20 75 73 65 73 20 61 62 73 6f 6c 75 74 65 20 69 | uses absolute i| 00000b50 6e 64 65 78 65 64 20 61 64 64 72 65 73 73 69 6e |ndexed addressin| 00000b60 67 20 77 69 74 68 20 74 68 65 20 58 20 72 65 67 |g with the X reg| 00000b70 69 73 74 65 72 0d 61 6e 64 20 70 6f 73 74 2d 69 |ister.and post-i| 00000b80 6e 64 65 78 65 64 20 69 6e 64 69 72 65 63 74 20 |ndexed indirect | 00000b90 61 64 64 72 65 73 73 69 6e 67 20 77 69 74 68 20 |addressing with | 00000ba0 74 68 65 20 59 20 72 65 67 69 73 74 65 72 20 74 |the Y register t| 00000bb0 6f 20 63 6f 6d 70 61 72 65 0d 65 76 65 72 79 20 |o compare.every | 00000bc0 62 79 74 65 20 6f 66 20 74 68 65 20 74 69 74 6c |byte of the titl| 00000bd0 65 20 73 74 72 69 6e 67 20 77 69 74 68 20 65 76 |e string with ev| 00000be0 65 72 79 20 62 79 74 65 20 6f 66 20 74 68 65 20 |ery byte of the | 00000bf0 75 6e 72 65 63 6f 67 6e 69 73 65 64 0d 63 6f 6d |unrecognised.com| 00000c00 6d 61 6e 64 2e 20 54 68 65 20 73 65 72 76 69 63 |mand. The servic| 00000c10 65 20 65 6e 74 72 79 20 70 6f 69 6e 74 20 6f 66 |e entry point of| 00000c20 20 74 68 65 20 72 6f 6d 20 69 6d 61 67 65 20 69 | the rom image i| 00000c30 6e 20 66 69 67 75 72 65 20 33 2e 32 20 68 61 73 |n figure 3.2 has| 00000c40 20 61 0d 6a 75 6d 70 20 74 6f 20 74 68 65 20 6c | a.jump to the l| 00000c50 61 62 65 6c 20 22 2e 73 65 72 76 69 63 65 22 20 |abel ".service" | 00000c60 77 68 69 63 68 20 69 73 20 74 68 65 20 62 65 67 |which is the beg| 00000c70 69 6e 69 6e 67 20 6f 66 20 74 68 65 20 69 6e 74 |ining of the int| 00000c80 65 72 70 72 65 74 65 72 2e 0d 0d 0d 0d 0d 2e 74 |erpreter.......t| 00000c90 69 74 6c 65 0d 20 20 20 20 20 20 20 20 45 51 55 |itle. EQU| 00000ca0 53 20 22 53 49 4c 4c 59 22 20 20 20 20 20 5c 20 |S "SILLY" \ | 00000cb0 74 69 74 6c 65 20 73 74 72 69 6e 67 20 69 6e 20 |title string in | 00000cc0 74 68 65 20 68 65 61 64 65 72 2e 0d 20 20 20 20 |the header.. | 00000cd0 20 20 20 20 42 52 4b 20 20 20 20 20 20 20 20 20 | BRK | 00000ce0 20 20 20 20 20 5c 20 66 69 72 73 74 20 62 79 74 | \ first byt| 00000cf0 65 20 6f 66 20 63 6f 70 79 72 69 67 68 74 20 73 |e of copyright s| 00000d00 74 72 69 6e 67 2e 0d 20 20 20 20 20 20 20 20 20 |tring.. | 00000d10 2e 0d 20 20 20 20 20 20 20 20 20 2e 0d 20 20 20 |.. .. | 00000d20 20 20 20 20 20 20 2e 0d 2e 73 65 72 76 69 63 65 | ...service| 00000d30 0d 20 20 20 20 20 20 20 20 43 4d 50 20 23 34 20 |. CMP #4 | 00000d40 20 20 20 20 20 20 20 20 20 20 5c 20 69 73 20 69 | \ is i| 00000d50 74 20 61 6e 20 75 6e 72 65 63 6f 67 6e 69 73 65 |t an unrecognise| 00000d60 64 20 63 6f 6d 6d 61 6e 64 3f 0d 20 20 20 20 20 |d command?. | 00000d70 20 20 20 42 45 51 20 75 6e 72 65 63 6f 67 6e 69 | BEQ unrecogni| 00000d80 73 65 64 20 5c 20 62 72 61 6e 63 68 20 69 66 20 |sed \ branch if | 00000d90 69 74 20 69 73 0d 20 20 20 20 20 20 20 20 52 54 |it is. RT| 00000da0 53 20 20 20 20 20 20 20 20 20 20 20 20 20 20 5c |S \| 00000db0 20 72 65 74 75 72 6e 20 74 6f 20 4d 4f 53 20 69 | return to MOS i| 00000dc0 66 20 69 74 20 69 73 20 6e 6f 74 0d 2e 75 6e 72 |f it is not..unr| 00000dd0 65 63 6f 67 6e 69 73 65 64 0d 20 20 20 20 20 20 |ecognised. | 00000de0 20 20 50 48 41 20 20 20 20 20 20 20 20 20 20 20 | PHA | 00000df0 20 20 20 5c 20 70 75 73 68 20 41 0d 20 20 20 20 | \ push A. | 00000e00 20 20 20 20 54 58 41 0d 20 20 20 20 20 20 20 20 | TXA. | 00000e10 50 48 41 20 20 20 20 20 20 20 20 20 20 20 20 20 |PHA | 00000e20 20 5c 20 70 75 73 68 20 58 0d 20 20 20 20 20 20 | \ push X. | 00000e30 20 20 54 59 41 0d 20 20 20 20 20 20 20 20 50 48 | TYA. PH| 00000e40 41 20 20 20 20 20 20 20 20 20 20 20 20 20 20 5c |A \| 00000e50 20 70 75 73 68 20 59 0d 20 20 20 20 20 20 20 20 | push Y. | 00000e60 4c 44 58 20 23 26 46 46 20 20 20 20 20 20 20 20 |LDX #&FF | 00000e70 20 5c 20 69 6e 69 74 69 61 6c 69 73 65 20 58 0d | \ initialise X.| 00000e80 2e 63 6f 6d 6c 6f 6f 70 0d 20 20 20 20 20 20 20 |.comloop. | 00000e90 20 49 4e 58 20 20 20 20 20 20 20 20 20 20 20 20 | INX | 00000ea0 20 20 5c 20 69 6e 63 72 65 6d 65 6e 74 20 6f 66 | \ increment of| 00000eb0 66 73 65 74 20 6f 6e 20 74 69 74 6c 65 20 73 74 |fset on title st| 00000ec0 72 69 6e 67 0d 20 20 20 20 20 20 20 20 4c 44 41 |ring. LDA| 00000ed0 20 74 69 74 6c 65 2c 58 20 20 20 20 20 20 5c 20 | title,X \ | 00000ee0 63 68 65 63 6b 20 69 66 20 6c 61 73 74 20 62 79 |check if last by| 00000ef0 74 65 20 6f 66 20 74 69 74 6c 65 2e 0d 20 20 20 |te of title.. | 00000f00 20 20 20 20 20 42 45 51 20 66 6f 75 6e 64 20 20 | BEQ found | 00000f10 20 20 20 20 20 20 5c 20 62 72 61 6e 63 68 20 69 | \ branch i| 00000f20 66 20 6c 61 73 74 20 62 79 74 65 20 6f 66 20 74 |f last byte of t| 00000f30 69 74 6c 65 2e 0d 20 20 20 20 20 20 20 20 4c 44 |itle.. LD| 00000f40 41 20 28 26 46 32 29 2c 59 20 20 20 20 20 20 5c |A (&F2),Y \| 00000f50 20 72 65 61 64 20 6e 65 78 74 20 63 68 61 72 61 | read next chara| 00000f60 63 74 65 72 20 6f 66 20 63 6f 6d 6d 61 6e 64 2e |cter of command.| 00000f70 0d 20 20 20 20 20 20 20 20 49 4e 59 20 20 20 20 |. INY | 00000f80 20 20 20 20 20 20 20 20 20 20 5c 20 69 6e 63 72 | \ incr| 00000f90 65 6d 65 6e 74 20 6f 66 66 73 65 74 20 74 6f 20 |ement offset to | 00000fa0 6e 65 78 74 20 63 68 61 72 61 63 74 65 72 0d 20 |next character. | 00000fb0 20 20 20 20 20 20 20 43 4d 50 20 23 41 53 43 28 | CMP #ASC(| 00000fc0 22 2e 22 29 20 20 20 20 5c 20 69 73 20 74 68 65 |".") \ is the| 00000fd0 20 63 68 61 72 61 63 74 65 72 20 72 65 61 64 20 | character read | 00000fe0 61 20 22 2e 22 3f 0d 20 20 20 20 20 20 20 20 42 |a "."?. B| 00000ff0 45 51 20 66 6f 75 6e 64 20 20 20 20 20 20 20 20 |EQ found | 00001000 5c 20 62 72 61 6e 63 68 20 69 66 20 69 74 20 69 |\ branch if it i| 00001010 73 20 61 20 73 68 6f 72 74 65 6e 65 64 20 63 6f |s a shortened co| 00001020 6d 6d 61 6e 64 2e 0d 20 20 20 20 20 20 20 20 41 |mmand.. A| 00001030 4e 44 20 23 26 44 46 20 20 20 20 20 20 20 20 20 |ND #&DF | 00001040 5c 20 66 6f 72 63 65 20 75 70 70 65 72 20 63 61 |\ force upper ca| 00001050 73 65 2e 0d 20 20 20 20 20 20 20 20 43 4d 50 20 |se.. CMP | 00001060 74 69 74 6c 65 2c 58 20 20 20 20 20 20 5c 20 69 |title,X \ i| 00001070 73 20 69 74 20 74 68 65 20 73 61 6d 65 20 61 73 |s it the same as| 00001080 20 74 68 65 20 74 69 74 6c 65 20 63 68 61 72 61 | the title chara| 00001090 63 74 65 72 3f 0d 20 20 20 20 20 20 20 20 42 45 |cter?. BE| 000010a0 51 20 63 6f 6d 6c 6f 6f 70 20 20 20 20 20 20 5c |Q comloop \| 000010b0 20 69 66 20 69 74 20 69 73 20 63 6f 6d 70 61 72 | if it is compar| 000010c0 65 20 6e 65 78 74 20 63 68 61 72 61 63 74 65 72 |e next character| 000010d0 0d 20 20 20 20 20 20 20 20 50 4c 41 20 20 20 20 |. PLA | 000010e0 20 20 20 20 20 20 20 20 20 20 5c 20 69 66 20 6e | \ if n| 000010f0 6f 74 20 70 75 6c 6c 20 59 0d 20 20 20 20 20 20 |ot pull Y. | 00001100 20 20 54 41 59 20 20 20 20 20 20 20 20 20 20 20 | TAY | 00001110 20 20 20 5c 20 72 65 73 74 6f 72 65 20 59 0d 20 | \ restore Y. | 00001120 20 20 20 20 20 20 20 50 4c 41 20 20 20 20 20 20 | PLA | 00001130 20 20 20 20 20 20 20 20 5c 20 70 75 6c 6c 20 58 | \ pull X| 00001140 0d 20 20 20 20 20 20 20 20 54 41 58 20 20 20 20 |. TAX | 00001150 20 20 20 20 20 20 20 20 20 20 5c 20 72 65 73 74 | \ rest| 00001160 6f 72 65 20 58 0d 20 20 20 20 20 20 20 20 50 4c |ore X. PL| 00001170 41 20 20 20 20 20 20 20 20 20 20 20 20 20 20 5c |A \| 00001180 20 72 65 73 74 6f 72 65 20 41 0d 20 20 20 20 20 | restore A. | 00001190 20 20 20 52 54 53 20 20 20 20 20 20 20 20 20 20 | RTS | 000011a0 20 20 20 20 5c 20 61 6e 64 20 72 65 74 75 72 6e | \ and return| 000011b0 20 74 6f 20 4d 4f 53 2e 0d 2e 66 6f 75 6e 64 0d | to MOS...found.| 000011c0 20 20 20 20 20 20 20 20 20 2e 20 20 20 20 20 20 | . | 000011d0 20 20 20 20 20 20 20 20 20 5c 20 79 6f 75 72 20 | \ your | 000011e0 6e 65 77 20 72 6f 75 74 69 6e 65 0d 20 20 20 20 |new routine. | 000011f0 20 20 20 20 20 2e 20 20 20 20 20 20 20 20 20 20 | . | 00001200 20 20 20 20 20 5c 20 67 6f 65 73 20 69 6e 20 68 | \ goes in h| 00001210 65 72 65 0d 20 20 20 20 20 20 20 20 20 2e 0d 20 |ere. .. | 00001220 20 20 20 20 20 20 20 50 4c 41 20 20 20 20 20 20 | PLA | 00001230 20 20 20 20 20 20 20 20 5c 20 70 75 6c 6c 20 59 | \ pull Y| 00001240 20 61 6e 64 20 64 69 73 63 61 72 64 0d 20 20 20 | and discard. | 00001250 20 20 20 20 20 50 4c 41 20 20 20 20 20 20 20 20 | PLA | 00001260 20 20 20 20 20 20 5c 20 70 75 6c 6c 20 58 20 61 | \ pull X a| 00001270 6e 64 20 64 69 73 63 61 72 64 0d 20 20 20 20 20 |nd discard. | 00001280 20 20 20 50 4c 41 20 20 20 20 20 20 20 20 20 20 | PLA | 00001290 20 20 20 20 5c 20 70 75 6c 6c 20 41 20 61 6e 64 | \ pull A and| 000012a0 20 64 69 73 63 61 72 64 0d 20 20 20 20 20 20 20 | discard. | 000012b0 20 4c 44 41 20 23 30 20 20 20 20 20 20 20 20 20 | LDA #0 | 000012c0 20 20 5c 20 6f 74 68 65 72 20 72 6f 6d 73 20 69 | \ other roms i| 000012d0 67 6e 6f 72 65 20 74 68 69 73 20 72 65 71 75 65 |gnore this reque| 000012e0 73 74 2e 0d 20 20 20 20 20 20 20 20 52 54 53 20 |st.. RTS | 000012f0 20 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 72 | \ r| 00001300 65 74 75 72 6e 20 74 6f 20 4d 4f 53 0d 0d 46 69 |eturn to MOS..Fi| 00001310 67 75 72 65 20 33 2e 32 20 41 6e 20 75 6e 72 65 |gure 3.2 An unre| 00001320 63 6f 67 6e 69 73 65 64 20 2a 20 63 6f 6d 6d 61 |cognised * comma| 00001330 6e 64 20 69 6e 74 65 72 70 72 65 74 65 72 2e 0d |nd interpreter..| 00001340 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 00001370 2d 0d 0d 0d 0d 20 20 54 68 65 20 74 72 61 63 65 |-.... The trace| 00001380 20 70 72 6f 67 72 61 6d 20 68 61 73 20 73 68 6f | program has sho| 00001390 77 6e 20 79 6f 75 20 74 68 61 74 2c 20 77 68 65 |wn you that, whe| 000013a0 6e 20 61 6e 20 75 6e 72 65 63 6f 67 6e 69 73 65 |n an unrecognise| 000013b0 64 20 2a 20 63 6f 6d 6d 61 6e 64 0d 69 73 20 70 |d * command.is p| 000013c0 61 73 73 65 64 20 74 6f 20 74 68 65 20 73 69 64 |assed to the sid| 000013d0 65 77 61 79 73 20 72 6f 6d 73 2c 20 65 61 63 68 |eways roms, each| 000013e0 20 72 6f 6d 20 69 73 20 65 6e 74 65 72 65 64 20 | rom is entered | 000013f0 61 74 20 74 68 65 20 73 65 72 76 69 63 65 0d 65 |at the service.e| 00001400 6e 74 72 79 20 70 6f 69 6e 74 20 77 69 74 68 20 |ntry point with | 00001410 74 68 65 20 61 63 63 75 6d 75 6c 61 74 6f 72 20 |the accumulator | 00001420 3d 20 34 2c 20 74 68 65 20 58 20 72 65 67 69 73 |= 4, the X regis| 00001430 74 65 72 20 3d 20 74 68 65 20 6e 75 6d 62 65 72 |ter = the number| 00001440 20 6f 66 0d 74 68 65 20 72 6f 6d 2c 20 61 6e 64 | of.the rom, and| 00001450 20 74 68 65 20 59 20 72 65 67 69 73 74 65 72 20 | the Y register | 00001460 3d 20 74 68 65 20 6f 66 66 73 65 74 20 74 6f 20 |= the offset to | 00001470 74 68 65 20 75 6e 72 65 63 6f 67 6e 69 73 65 64 |the unrecognised| 00001480 20 63 6f 6d 6d 61 6e 64 2e 0d 0d 20 20 54 68 65 | command... The| 00001490 20 69 6e 74 65 72 70 72 65 74 65 72 20 63 6f 6d | interpreter com| 000014a0 70 61 72 65 73 20 74 68 65 20 61 63 63 75 6d 75 |pares the accumu| 000014b0 6c 61 74 6f 72 20 77 69 74 68 20 34 20 74 6f 20 |lator with 4 to | 000014c0 73 65 65 20 69 66 20 69 74 20 69 73 20 61 6e 0d |see if it is an.| 000014d0 75 6e 72 65 63 6f 67 6e 69 73 65 64 20 63 6f 6d |unrecognised com| 000014e0 6d 61 6e 64 2e 20 49 66 20 69 74 20 69 73 20 63 |mand. If it is c| 000014f0 6f 6e 74 72 6f 6c 20 69 73 20 70 61 73 73 65 64 |ontrol is passed| 00001500 20 74 6f 20 74 68 65 20 6c 61 62 65 6c 0d 22 2e | to the label.".| 00001510 75 6e 72 65 63 6f 67 6e 69 73 65 64 22 2c 20 69 |unrecognised", i| 00001520 66 20 69 74 20 69 73 20 6e 6f 74 20 63 6f 6e 74 |f it is not cont| 00001530 72 6f 6c 20 69 73 20 72 65 74 75 72 6e 65 64 20 |rol is returned | 00001540 74 6f 20 74 68 65 20 4d 4f 53 20 77 69 74 68 20 |to the MOS with | 00001550 74 68 65 0d 41 2c 20 58 2c 20 61 6e 64 20 59 20 |the.A, X, and Y | 00001560 72 65 67 69 73 74 65 72 73 20 61 6c 6c 20 75 6e |registers all un| 00001570 61 6c 74 65 72 65 64 2e 0d 0d 20 20 42 65 66 6f |altered... Befo| 00001580 72 65 20 63 6f 6d 70 61 72 69 6e 67 20 74 68 65 |re comparing the| 00001590 20 75 6e 72 65 63 6f 67 6e 69 73 65 64 20 63 6f | unrecognised co| 000015a0 6d 6d 61 6e 64 20 77 69 74 68 20 74 68 65 20 74 |mmand with the t| 000015b0 69 74 6c 65 20 73 74 72 69 6e 67 20 6f 66 0d 74 |itle string of.t| 000015c0 68 65 20 72 6f 6d 2c 20 74 68 65 20 41 2c 20 58 |he rom, the A, X| 000015d0 20 61 6e 64 20 59 20 72 65 67 69 73 74 65 72 73 | and Y registers| 000015e0 20 61 72 65 20 70 75 73 68 65 64 20 6f 6e 20 74 | are pushed on t| 000015f0 68 65 20 73 74 61 63 6b 20 73 6f 20 74 68 61 74 |he stack so that| 00001600 20 74 68 65 79 0d 63 61 6e 20 62 65 20 72 65 73 | they.can be res| 00001610 74 6f 72 65 64 20 69 66 20 74 68 65 20 75 6e 72 |tored if the unr| 00001620 65 63 6f 67 6e 69 73 65 64 20 63 6f 6d 6d 61 6e |ecognised comman| 00001630 64 20 69 73 20 6e 6f 74 20 69 64 65 6e 74 69 63 |d is not identic| 00001640 61 6c 20 74 6f 20 74 68 65 0d 74 69 74 6c 65 20 |al to the.title | 00001650 73 74 72 69 6e 67 2e 20 41 66 74 65 72 20 70 75 |string. After pu| 00001660 73 68 69 6e 67 20 74 68 65 20 72 65 67 69 73 74 |shing the regist| 00001670 65 72 73 20 65 76 65 72 79 20 62 79 74 65 20 6f |ers every byte o| 00001680 66 20 74 68 65 20 74 69 74 6c 65 0d 73 74 72 69 |f the title.stri| 00001690 6e 67 20 69 73 20 63 6f 6d 70 61 72 65 64 20 77 |ng is compared w| 000016a0 69 74 68 20 65 76 65 72 79 20 62 79 74 65 20 6f |ith every byte o| 000016b0 66 20 74 68 65 20 75 6e 72 65 63 6f 67 6e 69 73 |f the unrecognis| 000016c0 65 64 20 63 6f 6d 6d 61 6e 64 2e 20 49 66 20 74 |ed command. If t| 000016d0 68 65 0d 63 6f 6d 70 61 72 69 73 6f 6e 20 66 61 |he.comparison fa| 000016e0 69 6c 73 20 62 65 66 6f 72 65 20 65 76 65 72 79 |ils before every| 000016f0 20 62 79 74 65 20 68 61 73 20 62 65 65 6e 20 63 | byte has been c| 00001700 6f 6d 70 61 72 65 64 20 74 68 65 20 72 65 67 69 |ompared the regi| 00001710 73 74 65 72 73 20 61 72 65 0d 72 65 73 74 6f 72 |sters are.restor| 00001720 65 64 20 61 6e 64 20 63 6f 6e 74 72 6f 6c 20 69 |ed and control i| 00001730 73 20 72 65 74 75 72 6e 65 64 20 74 6f 20 74 68 |s returned to th| 00001740 65 20 4d 4f 53 2e 0d 0d 20 20 54 68 65 72 65 20 |e MOS... There | 00001750 61 72 65 20 74 77 6f 20 63 6f 6e 64 69 74 69 6f |are two conditio| 00001760 6e 73 20 77 68 65 6e 20 74 68 65 20 63 6f 6d 6d |ns when the comm| 00001770 61 6e 64 20 69 73 20 72 65 63 6f 67 6e 69 73 65 |and is recognise| 00001780 64 20 62 79 20 74 68 65 0d 69 6e 74 65 72 70 72 |d by the.interpr| 00001790 65 74 65 72 2e 0d 0d 31 2e 20 49 66 20 65 76 65 |eter...1. If eve| 000017a0 72 79 20 62 79 74 65 20 6f 66 20 74 68 65 20 75 |ry byte of the u| 000017b0 6e 72 65 63 6f 67 6e 69 73 65 64 20 63 6f 6d 6d |nrecognised comm| 000017c0 61 6e 64 20 69 73 20 69 64 65 6e 74 69 63 61 6c |and is identical| 000017d0 20 74 6f 20 65 76 65 72 79 0d 62 79 74 65 20 6f | to every.byte o| 000017e0 66 20 74 68 65 20 74 69 74 6c 65 20 73 74 72 69 |f the title stri| 000017f0 6e 67 20 74 68 65 20 69 6e 74 65 72 70 72 65 74 |ng the interpret| 00001800 65 72 20 77 69 6c 6c 20 65 76 65 6e 74 75 61 6c |er will eventual| 00001810 6c 79 20 72 65 61 64 20 74 68 65 20 7a 65 72 6f |ly read the zero| 00001820 0d 62 79 74 65 20 61 74 20 74 68 65 20 65 6e 64 |.byte at the end| 00001830 20 6f 66 20 74 68 65 20 74 69 74 6c 65 2e 0d 0d | of the title...| 00001840 32 2e 20 49 66 20 65 76 65 72 79 20 62 79 74 65 |2. If every byte| 00001850 20 6f 66 20 74 68 65 20 74 69 74 6c 65 20 73 74 | of the title st| 00001860 72 69 6e 67 20 69 73 20 69 64 65 6e 74 69 63 61 |ring is identica| 00001870 6c 20 74 6f 20 65 76 65 72 79 20 62 79 74 65 20 |l to every byte | 00001880 6f 66 20 74 68 65 0d 75 6e 72 65 63 6f 67 6e 69 |of the.unrecogni| 00001890 73 65 64 20 63 6f 6d 6d 61 6e 64 20 75 6e 74 69 |sed command unti| 000018a0 6c 20 61 20 22 2e 22 20 74 65 72 6d 69 6e 61 74 |l a "." terminat| 000018b0 65 73 20 74 68 65 20 75 6e 72 65 63 6f 67 6e 69 |es the unrecogni| 000018c0 73 65 64 20 63 6f 6d 6d 61 6e 64 2e 0d 0d 20 20 |sed command... | 000018d0 57 68 65 6e 20 74 68 65 20 75 6e 72 65 63 6f 67 |When the unrecog| 000018e0 6e 69 73 65 64 20 63 6f 6d 6d 61 6e 64 20 68 61 |nised command ha| 000018f0 73 20 62 65 65 6e 20 72 65 63 6f 67 6e 69 73 65 |s been recognise| 00001900 64 20 62 79 20 74 68 65 20 69 6e 74 65 72 70 72 |d by the interpr| 00001910 65 74 65 72 0d 63 6f 6e 74 72 6f 6c 20 69 73 20 |eter.control is | 00001920 70 61 73 73 65 64 20 74 6f 20 74 68 65 20 6c 61 |passed to the la| 00001930 62 65 6c 20 22 2e 66 6f 75 6e 64 22 20 77 68 69 |bel ".found" whi| 00001940 63 68 20 77 69 6c 6c 20 62 65 20 74 68 65 20 62 |ch will be the b| 00001950 65 67 69 6e 6e 69 6e 67 20 6f 66 0d 61 6e 79 20 |eginning of.any | 00001960 6e 65 77 20 72 6f 75 74 69 6e 65 20 79 6f 75 20 |new routine you | 00001970 63 61 72 65 20 74 6f 20 75 73 65 2e 20 57 68 65 |care to use. Whe| 00001980 6e 20 79 6f 75 72 20 6e 65 77 20 72 6f 75 74 69 |n your new routi| 00001990 6e 65 20 68 61 73 20 66 69 6e 69 73 68 65 64 0d |ne has finished.| 000019a0 74 68 65 20 59 2c 20 58 20 61 6e 64 20 41 20 72 |the Y, X and A r| 000019b0 65 67 69 73 74 65 72 73 20 70 75 73 68 65 64 20 |egisters pushed | 000019c0 6f 6e 74 6f 20 74 68 65 20 73 74 61 63 6b 20 62 |onto the stack b| 000019d0 79 20 74 68 65 20 69 6e 74 65 72 70 72 65 74 65 |y the interprete| 000019e0 72 20 6d 75 73 74 0d 62 65 20 70 75 6c 6c 65 64 |r must.be pulled| 000019f0 20 6f 66 66 20 61 6e 64 20 64 69 73 63 61 72 64 | off and discard| 00001a00 65 64 2e 20 59 6f 75 72 20 70 72 6f 67 72 61 6d |ed. Your program| 00001a10 20 6d 75 73 74 20 70 75 6c 6c 20 74 68 65 20 59 | must pull the Y| 00001a20 2c 20 58 20 61 6e 64 20 41 0d 72 65 67 69 73 74 |, X and A.regist| 00001a30 65 72 73 20 6f 66 66 20 74 68 65 20 73 74 61 63 |ers off the stac| 00001a40 6b 20 62 75 74 20 74 68 65 72 65 20 69 73 20 6e |k but there is n| 00001a50 6f 20 6e 65 65 64 20 74 6f 20 74 72 61 6e 73 66 |o need to transf| 00001a60 65 72 20 41 20 74 6f 20 59 20 61 6e 64 20 58 0d |er A to Y and X.| 00001a70 77 69 74 68 20 74 68 65 20 66 69 72 73 74 20 74 |with the first t| 00001a80 77 6f 20 70 75 6c 6c 73 20 62 65 63 61 75 73 65 |wo pulls because| 00001a90 20 74 68 65 20 69 6e 64 65 78 20 72 65 67 69 73 | the index regis| 00001aa0 74 65 72 73 20 77 69 6c 6c 20 62 65 20 69 67 6e |ters will be ign| 00001ab0 6f 72 65 64 0d 77 68 65 6e 20 79 6f 75 20 72 65 |ored.when you re| 00001ac0 74 75 72 6e 20 77 69 74 68 20 41 3d 30 2e 20 41 |turn with A=0. A| 00001ad0 66 74 65 72 20 74 68 65 20 74 68 69 72 64 20 50 |fter the third P| 00001ae0 4c 41 2c 20 79 6f 75 72 20 70 72 6f 67 72 61 6d |LA, your program| 00001af0 20 6d 75 73 74 20 6c 6f 61 64 0d 74 68 65 20 61 | must load.the a| 00001b00 63 63 75 6d 75 6c 61 74 6f 72 20 77 69 74 68 20 |ccumulator with | 00001b10 7a 65 72 6f 20 62 65 66 6f 72 65 20 72 65 74 75 |zero before retu| 00001b20 72 6e 69 6e 67 20 74 6f 20 74 68 65 20 4d 4f 53 |rning to the MOS| 00001b30 2e 20 54 68 69 73 20 77 69 6c 6c 0d 69 6e 66 6f |. This will.info| 00001b40 72 6d 20 61 6c 6c 20 6f 74 68 65 72 20 72 6f 6d |rm all other rom| 00001b50 73 20 74 68 61 74 20 74 68 65 20 73 65 72 76 69 |s that the servi| 00001b60 63 65 20 72 65 71 75 65 73 74 20 68 61 73 20 62 |ce request has b| 00001b70 65 65 6e 20 72 65 63 6f 67 6e 69 73 65 64 2e 0d |een recognised..| 00001b80 0d 20 20 54 68 69 73 20 73 69 6d 70 6c 65 20 69 |. This simple i| 00001b90 6e 74 65 72 70 72 65 74 65 72 20 68 61 73 20 62 |nterpreter has b| 00001ba0 65 65 6e 20 75 73 65 64 20 74 6f 20 63 6f 6e 76 |een used to conv| 00001bb0 65 72 74 20 74 68 65 20 70 72 6f 67 72 61 6d 20 |ert the program | 00001bc0 5a 41 50 0d 69 6e 74 6f 20 69 74 73 20 73 69 64 |ZAP.into its sid| 00001bd0 65 77 61 79 73 20 72 61 6d 20 65 71 75 69 76 61 |eways ram equiva| 00001be0 6c 65 6e 74 20 4e 45 57 43 4f 4d 2e 0d 0d 20 20 |lent NEWCOM... | 00001bf0 49 6e 20 74 68 65 20 70 72 6f 67 72 61 6d 20 5a |In the program Z| 00001c00 41 50 20 74 68 65 20 41 73 73 65 6d 62 6c 79 20 |AP the Assembly | 00001c10 6c 61 6e 67 75 61 67 65 20 63 6f 64 69 6e 67 20 |language coding | 00001c20 66 72 6f 6d 20 6c 69 6e 65 20 37 30 20 74 6f 20 |from line 70 to | 00001c30 6c 69 6e 65 0d 32 33 30 20 69 73 20 74 68 65 20 |line.230 is the | 00001c40 65 71 75 69 76 61 6c 65 6e 74 20 6f 66 20 74 68 |equivalent of th| 00001c50 65 20 42 41 53 49 43 20 45 4e 56 45 4c 4f 50 45 |e BASIC ENVELOPE| 00001c60 20 61 6e 64 20 53 4f 55 4e 44 20 63 6f 6d 6d 61 | and SOUND comma| 00001c70 6e 64 73 2e 20 54 68 65 0d 70 72 6f 67 72 61 6d |nds. The.program| 00001c80 20 75 73 65 73 20 4f 73 77 6f 72 64 20 38 20 77 | uses Osword 8 w| 00001c90 69 74 68 20 61 20 31 34 20 62 79 74 65 20 70 61 |ith a 14 byte pa| 00001ca0 72 61 6d 65 74 65 72 20 62 6c 6f 63 6b 20 28 77 |rameter block (w| 00001cb0 68 69 63 68 0d 63 6f 72 72 65 73 70 6f 6e 64 73 |hich.corresponds| 00001cc0 20 77 69 74 68 20 74 68 65 20 31 34 20 70 61 72 | with the 14 par| 00001cd0 61 6d 65 74 65 72 73 20 69 6e 20 74 68 65 20 45 |ameters in the E| 00001ce0 4e 56 45 4c 4f 50 45 20 63 6f 6d 6d 61 6e 64 29 |NVELOPE command)| 00001cf0 20 61 6e 64 20 4f 73 77 6f 72 64 0d 37 20 77 69 | and Osword.7 wi| 00001d00 74 68 20 61 6e 20 38 20 62 79 74 65 20 70 61 72 |th an 8 byte par| 00001d10 61 6d 65 74 65 72 20 62 6c 6f 63 6b 20 28 77 68 |ameter block (wh| 00001d20 69 63 68 20 63 6f 72 72 65 73 70 6f 6e 64 73 20 |ich corresponds | 00001d30 77 69 74 68 20 74 68 65 20 34 0d 70 61 72 61 6d |with the 4.param| 00001d40 65 74 65 72 73 20 69 6e 20 74 68 65 20 73 6f 75 |eters in the sou| 00001d50 6e 64 20 63 6f 6d 6d 61 6e 64 29 2e 20 4c 69 6e |nd command). Lin| 00001d60 65 20 32 37 30 20 65 78 65 63 75 74 65 73 20 74 |e 270 executes t| 00001d70 68 65 20 6d 61 63 68 69 6e 65 20 63 6f 64 65 0d |he machine code.| 00001d80 67 65 6e 65 72 61 74 65 64 20 62 79 20 74 68 65 |generated by the| 00001d90 20 41 73 73 65 6d 62 6c 79 20 6c 61 6e 67 75 61 | Assembly langua| 00001da0 67 65 20 63 6f 64 69 6e 67 2e 20 57 68 65 6e 20 |ge coding. When | 00001db0 74 68 65 20 70 72 6f 67 72 61 6d 20 68 61 73 20 |the program has | 00001dc0 62 65 65 6e 0d 63 6f 6e 76 65 72 74 65 64 20 69 |been.converted i| 00001dd0 6e 74 6f 20 73 69 64 65 77 61 79 73 20 72 61 6d |nto sideways ram| 00001de0 20 66 6f 72 6d 61 74 20 61 6e 64 20 6c 6f 61 64 | format and load| 00001df0 65 64 20 69 6e 74 6f 20 73 69 64 65 77 61 79 73 |ed into sideways| 00001e00 20 72 61 6d 20 74 68 65 0d 65 6e 74 69 72 65 20 | ram the.entire | 00001e10 70 72 6f 67 72 61 6d 20 63 61 6e 20 62 65 20 72 |program can be r| 00001e20 65 70 6c 61 63 65 64 20 77 69 74 68 20 74 68 65 |eplaced with the| 00001e30 20 6e 65 77 20 63 6f 6d 6d 61 6e 64 20 2a 5a 41 | new command *ZA| 00001e40 50 2e 0d 0d 0d 0d 0d 20 20 20 31 30 20 52 45 4d |P...... 10 REM| 00001e50 3a 20 5a 41 50 0d 20 20 20 32 30 20 44 49 4d 20 |: ZAP. 20 DIM | 00001e60 6d 63 6f 64 65 20 31 30 30 0d 20 20 20 33 30 20 |mcode 100. 30 | 00001e70 6f 73 77 6f 72 64 3d 26 46 46 46 31 0d 20 20 20 |osword=&FFF1. | 00001e80 34 30 20 46 4f 52 20 70 61 73 73 20 3d 20 30 20 |40 FOR pass = 0 | 00001e90 54 4f 20 32 20 53 54 45 50 20 32 0d 20 20 20 35 |TO 2 STEP 2. 5| 00001ea0 30 20 50 25 3d 6d 63 6f 64 65 0d 20 20 20 36 30 |0 P%=mcode. 60| 00001eb0 20 5b 20 20 20 20 20 20 20 4f 50 54 20 70 61 73 | [ OPT pas| 00001ec0 73 0d 20 20 20 37 30 20 20 20 20 20 20 20 20 20 |s. 70 | 00001ed0 4c 44 41 20 23 38 0d 20 20 20 38 30 20 20 20 20 |LDA #8. 80 | 00001ee0 20 20 20 20 20 4c 44 58 20 23 65 6e 76 65 6c 6f | LDX #envelo| 00001ef0 70 65 20 4d 4f 44 20 32 35 36 0d 20 20 20 39 30 |pe MOD 256. 90| 00001f00 20 20 20 20 20 20 20 20 20 4c 44 59 20 23 65 6e | LDY #en| 00001f10 76 65 6c 6f 70 65 20 44 49 56 20 32 35 36 0d 20 |velope DIV 256. | 00001f20 20 31 30 30 20 20 20 20 20 20 20 20 20 4a 53 52 | 100 JSR| 00001f30 20 6f 73 77 6f 72 64 0d 20 20 31 31 30 20 20 20 | osword. 110 | 00001f40 20 20 20 20 20 20 4c 44 41 20 23 37 0d 20 20 31 | LDA #7. 1| 00001f50 32 30 20 20 20 20 20 20 20 20 20 4c 44 58 20 23 |20 LDX #| 00001f60 73 6f 75 6e 64 20 4d 4f 44 20 32 35 36 0d 20 20 |sound MOD 256. | 00001f70 31 33 30 20 20 20 20 20 20 20 20 20 4c 44 59 20 |130 LDY | 00001f80 23 73 6f 75 6e 64 20 44 49 56 20 32 35 36 0d 20 |#sound DIV 256. | 00001f90 20 31 34 30 20 20 20 20 20 20 20 20 20 4a 53 52 | 140 JSR| 00001fa0 20 6f 73 77 6f 72 64 0d 20 20 31 35 30 20 20 20 | osword. 150 | 00001fb0 20 20 20 20 20 20 52 54 53 0d 20 20 31 36 30 20 | RTS. 160 | 00001fc0 2e 65 6e 76 65 6c 6f 70 65 0d 20 20 31 37 30 20 |.envelope. 170 | 00001fd0 20 20 20 20 20 20 20 20 4f 50 54 20 46 4e 65 71 | OPT FNeq| 00001fe0 75 64 28 26 37 46 46 43 30 31 30 31 29 0d 20 20 |ud(&7FFC0101). | 00001ff0 31 38 30 20 20 20 20 20 20 20 20 20 4f 50 54 20 |180 OPT | 00002000 46 4e 65 71 75 64 28 26 38 44 36 35 38 33 30 41 |FNequd(&8D65830A| 00002010 29 0d 20 20 31 39 30 20 20 20 20 20 20 20 20 20 |). 190 | 00002020 4f 50 54 20 46 4e 65 71 75 64 28 26 38 31 30 30 |OPT FNequd(&8100| 00002030 46 46 37 46 29 0d 20 20 32 30 30 20 20 20 20 20 |FF7F). 200 | 00002040 20 20 20 20 4f 50 54 20 46 4e 65 71 75 77 28 26 | OPT FNequw(&| 00002050 37 45 37 45 29 0d 20 20 32 31 30 20 2e 73 6f 75 |7E7E). 210 .sou| 00002060 6e 64 0d 20 20 32 32 30 20 20 20 20 20 20 20 20 |nd. 220 | 00002070 20 4f 50 54 20 46 4e 65 71 75 64 28 26 30 30 30 | OPT FNequd(&000| 00002080 31 30 30 31 31 29 0d 20 20 32 33 30 20 20 20 20 |10011). 230 | 00002090 20 20 20 20 20 4f 50 54 20 46 4e 65 71 75 64 28 | OPT FNequd(| 000020a0 26 30 30 36 34 30 30 30 30 29 0d 20 20 32 34 30 |&00640000). 240| 000020b0 20 2e 6c 61 73 74 62 79 74 65 0d 20 20 32 35 30 | .lastbyte. 250| 000020c0 20 5d 0d 20 20 32 36 30 20 4e 45 58 54 0d 20 20 | ]. 260 NEXT. | 000020d0 32 37 30 20 43 41 4c 4c 20 6d 63 6f 64 65 0d 20 |270 CALL mcode. | 000020e0 20 32 38 30 20 45 4e 44 0d 20 20 32 39 30 20 44 | 280 END. 290 D| 000020f0 45 46 46 4e 65 71 75 77 28 77 6f 72 64 29 0d 20 |EFFNequw(word). | 00002100 20 33 30 30 20 3f 50 25 3d 77 6f 72 64 20 4d 4f | 300 ?P%=word MO| 00002110 44 20 32 35 36 0d 20 20 33 31 30 20 50 25 3f 31 |D 256. 310 P%?1| 00002120 3d 77 6f 72 64 20 44 49 56 20 32 35 36 0d 20 20 |=word DIV 256. | 00002130 33 32 30 20 50 25 3d 50 25 2b 32 0d 20 20 33 33 |320 P%=P%+2. 33| 00002140 30 20 3d 70 61 73 73 0d 20 20 33 34 30 20 44 45 |0 =pass. 340 DE| 00002150 46 46 4e 65 71 75 64 28 64 6f 75 62 6c 65 29 0d |FFNequd(double).| 00002160 20 20 33 35 30 20 21 50 25 3d 64 6f 75 62 6c 65 | 350 !P%=double| 00002170 0d 20 20 33 36 30 20 50 25 3d 50 25 2b 34 0d 20 |. 360 P%=P%+4. | 00002180 20 33 37 30 20 3d 70 61 73 73 0d 0d 0d 0d 0d 20 | 370 =pass..... | 00002190 20 54 68 65 20 70 72 6f 67 72 61 6d 20 4e 45 57 | The program NEW| 000021a0 43 4f 4d 20 69 6c 6c 75 73 74 72 61 74 65 73 20 |COM illustrates | 000021b0 74 68 65 20 63 6f 6e 76 65 72 73 69 6f 6e 20 69 |the conversion i| 000021c0 6e 74 6f 20 73 69 64 65 77 61 79 73 20 72 61 6d |nto sideways ram| 000021d0 0d 66 6f 72 6d 61 74 20 75 73 69 6e 67 20 74 68 |.format using th| 000021e0 65 20 73 69 6d 70 6c 65 20 6f 6e 65 2d 63 6f 6d |e simple one-com| 000021f0 6d 61 6e 64 20 69 6e 74 65 72 70 72 65 74 65 72 |mand interpreter| 00002200 20 64 65 73 63 72 69 62 65 64 20 61 62 6f 76 65 | described above| 00002210 2e 20 54 68 65 0d 72 6f 6d 20 74 79 70 65 20 62 |. The.rom type b| 00002220 79 74 65 20 69 6e 20 6c 69 6e 65 20 31 37 30 20 |yte in line 170 | 00002230 6f 66 20 4e 45 57 43 4f 4d 20 69 6e 64 69 63 61 |of NEWCOM indica| 00002240 74 65 73 20 74 6f 20 74 68 65 20 4d 4f 53 20 74 |tes to the MOS t| 00002250 68 61 74 20 74 68 65 20 72 6f 6d 0d 69 6d 61 67 |hat the rom.imag| 00002260 65 20 68 61 73 20 61 20 73 65 72 76 69 63 65 20 |e has a service | 00002270 65 6e 74 72 79 2e 20 54 68 65 20 69 6e 74 65 72 |entry. The inter| 00002280 70 72 65 74 65 72 20 28 6c 69 6e 65 73 20 32 37 |preter (lines 27| 00002290 30 2d 35 33 30 29 20 63 6f 6d 70 61 72 65 73 0d |0-530) compares.| 000022a0 74 68 65 20 75 6e 72 65 63 6f 67 6e 69 73 65 64 |the unrecognised| 000022b0 20 63 6f 6d 6d 61 6e 64 20 77 69 74 68 20 74 68 | command with th| 000022c0 65 20 74 69 74 6c 65 20 73 74 72 69 6e 67 20 61 |e title string a| 000022d0 6e 64 20 69 66 20 74 68 65 79 20 6d 61 74 63 68 |nd if they match| 000022e0 0d 63 6f 6e 74 6f 6c 20 69 73 20 70 61 73 73 65 |.contol is passe| 000022f0 64 20 74 6f 20 74 68 65 20 6c 61 62 65 6c 20 22 |d to the label "| 00002300 2e 66 6f 75 6e 64 22 20 69 6e 20 6c 69 6e 65 20 |.found" in line | 00002310 35 34 30 2e 20 54 68 65 20 63 6f 64 65 20 74 61 |540. The code ta| 00002320 6b 65 6e 0d 66 72 6f 6d 20 74 68 65 20 70 72 6f |ken.from the pro| 00002330 67 72 61 6d 20 5a 41 50 20 69 73 20 69 6e 73 65 |gram ZAP is inse| 00002340 72 74 65 64 20 61 66 74 65 72 20 74 68 65 20 6c |rted after the l| 00002350 61 62 65 6c 20 22 2e 66 6f 75 6e 64 22 20 69 6e |abel ".found" in| 00002360 20 4e 45 57 43 4f 4d 0d 62 75 74 20 74 68 65 20 | NEWCOM.but the | 00002370 52 54 53 20 69 6e 73 74 72 75 63 74 69 6f 6e 20 |RTS instruction | 00002380 69 6e 20 6c 69 6e 65 20 31 35 30 20 6f 66 20 5a |in line 150 of Z| 00002390 41 50 20 68 61 73 20 62 65 65 6e 20 72 65 70 6c |AP has been repl| 000023a0 61 63 65 64 20 77 69 74 68 20 50 4c 41 0d 3a 20 |aced with PLA.: | 000023b0 50 4c 41 20 3a 20 50 4c 41 20 3a 20 4c 44 41 20 |PLA : PLA : LDA | 000023c0 23 30 20 3a 20 52 54 53 20 69 6e 20 6c 69 6e 65 |#0 : RTS in line| 000023d0 73 20 36 33 30 20 74 6f 20 36 37 30 20 6f 66 20 |s 630 to 670 of | 000023e0 4e 45 57 43 4f 4d 20 69 6e 20 6f 72 64 65 72 20 |NEWCOM in order | 000023f0 74 6f 0d 62 61 6c 61 6e 63 65 20 74 68 65 20 73 |to.balance the s| 00002400 74 61 63 6b 20 61 6e 64 20 6c 6f 61 64 20 74 68 |tack and load th| 00002410 65 20 61 63 63 75 6d 75 6c 61 74 6f 72 20 77 69 |e accumulator wi| 00002420 74 68 20 7a 65 72 6f 20 62 65 66 6f 72 65 20 72 |th zero before r| 00002430 65 74 75 72 6e 69 6e 67 0d 63 6f 6e 74 72 6f 6c |eturning.control| 00002440 20 74 6f 20 74 68 65 20 4d 4f 53 2e 0d 0d 0d 0d | to the MOS.....| 00002450 0d 20 20 20 31 30 20 52 45 4d 3a 20 4e 45 57 43 |. 10 REM: NEWC| 00002460 4f 4d 0d 20 20 20 32 30 20 4d 4f 44 45 37 0d 20 |OM. 20 MODE7. | 00002470 20 20 33 30 20 48 49 4d 45 4d 3d 26 33 43 30 30 | 30 HIMEM=&3C00| 00002480 0d 20 20 20 34 30 20 44 49 4d 20 73 61 76 65 20 |. 40 DIM save | 00002490 35 30 0d 20 20 20 35 30 20 64 69 66 66 3d 26 38 |50. 50 diff=&8| 000024a0 30 30 30 2d 48 49 4d 45 4d 0d 20 20 20 36 30 20 |000-HIMEM. 60 | 000024b0 63 6f 6d 76 65 63 3d 26 46 32 0d 20 20 20 37 30 |comvec=&F2. 70| 000024c0 20 67 73 72 65 61 64 3d 26 46 46 43 35 0d 20 20 | gsread=&FFC5. | 000024d0 20 38 30 20 6f 73 77 6f 72 64 3d 26 46 46 46 31 | 80 osword=&FFF1| 000024e0 0d 20 20 20 39 30 20 6f 73 63 6c 69 3d 26 46 46 |. 90 oscli=&FF| 000024f0 46 37 0d 20 20 31 30 30 20 46 4f 52 20 70 61 73 |F7. 100 FOR pas| 00002500 73 20 3d 20 30 20 54 4f 20 32 20 53 54 45 50 20 |s = 0 TO 2 STEP | 00002510 32 0d 20 20 31 31 30 20 50 25 3d 48 49 4d 45 4d |2. 110 P%=HIMEM| 00002520 0d 20 20 31 32 30 20 5b 20 20 20 20 20 20 20 4f |. 120 [ O| 00002530 50 54 20 70 61 73 73 0d 20 20 31 33 30 20 20 20 |PT pass. 130 | 00002540 20 20 20 20 20 20 42 52 4b 0d 20 20 31 34 30 20 | BRK. 140 | 00002550 20 20 20 20 20 20 20 20 42 52 4b 0d 20 20 31 35 | BRK. 15| 00002560 30 20 20 20 20 20 20 20 20 20 42 52 4b 0d 20 20 |0 BRK. | 00002570 31 36 30 20 20 20 20 20 20 20 20 20 4a 4d 50 20 |160 JMP | 00002580 73 65 72 76 69 63 65 2b 64 69 66 66 0d 20 20 31 |service+diff. 1| 00002590 37 30 20 20 20 20 20 20 20 20 20 4f 50 54 20 46 |70 OPT F| 000025a0 4e 65 71 75 62 28 26 38 32 29 0d 20 20 31 38 30 |Nequb(&82). 180| 000025b0 20 20 20 20 20 20 20 20 20 4f 50 54 20 46 4e 65 | OPT FNe| 000025c0 71 75 62 28 28 63 6f 70 79 72 69 67 68 74 2b 64 |qub((copyright+d| 000025d0 69 66 66 29 20 4d 4f 44 20 32 35 36 29 0d 20 20 |iff) MOD 256). | 000025e0 31 39 30 20 20 20 20 20 20 20 20 20 42 52 4b 0d |190 BRK.| 000025f0 20 20 32 30 30 20 2e 74 69 74 6c 65 0d 20 20 32 | 200 .title. 2| 00002600 31 30 20 20 20 20 20 20 20 20 20 4f 50 54 20 46 |10 OPT F| 00002610 4e 65 71 75 73 28 22 5a 41 50 22 29 0d 20 20 32 |Nequs("ZAP"). 2| 00002620 32 30 20 2e 63 6f 70 79 72 69 67 68 74 0d 20 20 |20 .copyright. | 00002630 32 33 30 20 20 20 20 20 20 20 20 20 42 52 4b 0d |230 BRK.| 00002640 20 20 32 34 30 20 20 20 20 20 20 20 20 20 4f 50 | 240 OP| 00002650 54 20 46 4e 65 71 75 73 28 22 28 43 29 20 47 6f |T FNequs("(C) Go| 00002660 72 64 6f 6e 20 48 6f 72 73 69 6e 67 74 6f 6e 20 |rdon Horsington | 00002670 31 39 38 37 22 29 0d 20 20 32 35 30 20 20 20 20 |1987"). 250 | 00002680 20 20 20 20 20 42 52 4b 0d 20 20 32 36 30 20 2e | BRK. 260 .| 00002690 73 65 72 76 69 63 65 0d 20 20 32 37 30 20 20 20 |service. 270 | 000026a0 20 20 20 20 20 20 43 4d 50 20 23 34 0d 20 20 32 | CMP #4. 2| 000026b0 38 30 20 20 20 20 20 20 20 20 20 42 45 51 20 75 |80 BEQ u| 000026c0 6e 72 65 63 6f 67 6e 69 73 65 64 0d 20 20 32 39 |nrecognised. 29| 000026d0 30 20 20 20 20 20 20 20 20 20 52 54 53 0d 20 20 |0 RTS. | 000026e0 33 30 30 20 2e 75 6e 72 65 63 6f 67 6e 69 73 65 |300 .unrecognise| 000026f0 64 0d 20 20 33 31 30 20 20 20 20 20 20 20 20 20 |d. 310 | 00002700 50 48 41 0d 20 20 33 32 30 20 20 20 20 20 20 20 |PHA. 320 | 00002710 20 20 54 58 41 0d 20 20 33 33 30 20 20 20 20 20 | TXA. 330 | 00002720 20 20 20 20 50 48 41 0d 20 20 33 34 30 20 20 20 | PHA. 340 | 00002730 20 20 20 20 20 20 54 59 41 0d 20 20 33 35 30 20 | TYA. 350 | 00002740 20 20 20 20 20 20 20 20 50 48 41 0d 20 20 33 36 | PHA. 36| 00002750 30 20 20 20 20 20 20 20 20 20 4c 44 58 20 23 26 |0 LDX #&| 00002760 46 46 0d 20 20 33 37 30 20 2e 63 6f 6d 6c 6f 6f |FF. 370 .comloo| 00002770 70 0d 20 20 33 38 30 20 20 20 20 20 20 20 20 20 |p. 380 | 00002780 49 4e 58 0d 20 20 33 39 30 20 20 20 20 20 20 20 |INX. 390 | 00002790 20 20 4c 44 41 20 74 69 74 6c 65 2b 64 69 66 66 | LDA title+diff| 000027a0 2c 58 0d 20 20 34 30 30 20 20 20 20 20 20 20 20 |,X. 400 | 000027b0 20 42 45 51 20 66 6f 75 6e 64 0d 20 20 34 31 30 | BEQ found. 410| 000027c0 20 20 20 20 20 20 20 20 20 4c 44 41 20 28 63 6f | LDA (co| 000027d0 6d 76 65 63 29 2c 59 0d 20 20 34 32 30 20 20 20 |mvec),Y. 420 | 000027e0 20 20 20 20 20 20 49 4e 59 0d 20 20 34 33 30 20 | INY. 430 | 000027f0 20 20 20 20 20 20 20 20 43 4d 50 20 23 41 53 43 | CMP #ASC| 00002800 28 22 2e 22 29 0d 20 20 34 34 30 20 20 20 20 20 |("."). 440 | 00002810 20 20 20 20 42 45 51 20 66 6f 75 6e 64 0d 20 20 | BEQ found. | 00002820 34 35 30 20 20 20 20 20 20 20 20 20 41 4e 44 20 |450 AND | 00002830 23 26 44 46 0d 20 20 34 36 30 20 20 20 20 20 20 |#&DF. 460 | 00002840 20 20 20 43 4d 50 20 74 69 74 6c 65 2b 64 69 66 | CMP title+dif| 00002850 66 2c 58 0d 20 20 34 37 30 20 20 20 20 20 20 20 |f,X. 470 | 00002860 20 20 42 45 51 20 63 6f 6d 6c 6f 6f 70 0d 20 20 | BEQ comloop. | 00002870 34 38 30 20 20 20 20 20 20 20 20 20 50 4c 41 0d |480 PLA.| 00002880 20 20 34 39 30 20 20 20 20 20 20 20 20 20 54 41 | 490 TA| 00002890 59 0d 20 20 35 30 30 20 20 20 20 20 20 20 20 20 |Y. 500 | 000028a0 50 4c 41 0d 20 20 35 31 30 20 20 20 20 20 20 20 |PLA. 510 | 000028b0 20 20 54 41 58 0d 20 20 35 32 30 20 20 20 20 20 | TAX. 520 | 000028c0 20 20 20 20 50 4c 41 0d 20 20 35 33 30 20 20 20 | PLA. 530 | 000028d0 20 20 20 20 20 20 52 54 53 0d 20 20 35 34 30 20 | RTS. 540 | 000028e0 2e 66 6f 75 6e 64 0d 20 20 35 35 30 20 20 20 20 |.found. 550 | 000028f0 20 20 20 20 20 4c 44 41 20 23 38 0d 20 20 35 36 | LDA #8. 56| 00002900 30 20 20 20 20 20 20 20 20 20 4c 44 58 20 23 28 |0 LDX #(| 00002910 28 65 6e 76 65 6c 6f 70 65 2b 64 69 66 66 29 20 |(envelope+diff) | 00002920 4d 4f 44 20 32 35 36 29 0d 20 20 35 37 30 20 20 |MOD 256). 570 | 00002930 20 20 20 20 20 20 20 4c 44 59 20 23 28 28 65 6e | LDY #((en| 00002940 76 65 6c 6f 70 65 2b 64 69 66 66 29 20 44 49 56 |velope+diff) DIV| 00002950 20 32 35 36 29 0d 20 20 35 38 30 20 20 20 20 20 | 256). 580 | 00002960 20 20 20 20 4a 53 52 20 6f 73 77 6f 72 64 0d 20 | JSR osword. | 00002970 20 35 39 30 20 20 20 20 20 20 20 20 20 4c 44 41 | 590 LDA| 00002980 20 23 37 0d 20 20 36 30 30 20 20 20 20 20 20 20 | #7. 600 | 00002990 20 20 4c 44 58 20 23 28 28 73 6f 75 6e 64 2b 64 | LDX #((sound+d| 000029a0 69 66 66 29 20 4d 4f 44 20 32 35 36 29 0d 20 20 |iff) MOD 256). | 000029b0 36 31 30 20 20 20 20 20 20 20 20 20 4c 44 59 20 |610 LDY | 000029c0 23 28 28 73 6f 75 6e 64 2b 64 69 66 66 29 20 44 |#((sound+diff) D| 000029d0 49 56 20 32 35 36 29 0d 20 20 36 32 30 20 20 20 |IV 256). 620 | 000029e0 20 20 20 20 20 20 4a 53 52 20 6f 73 77 6f 72 64 | JSR osword| 000029f0 0d 20 20 36 33 30 20 20 20 20 20 20 20 20 20 50 |. 630 P| 00002a00 4c 41 0d 20 20 36 34 30 20 20 20 20 20 20 20 20 |LA. 640 | 00002a10 20 50 4c 41 0d 20 20 36 35 30 20 20 20 20 20 20 | PLA. 650 | 00002a20 20 20 20 50 4c 41 0d 20 20 36 36 30 20 20 20 20 | PLA. 660 | 00002a30 20 20 20 20 20 4c 44 41 20 23 30 0d 20 20 36 37 | LDA #0. 67| 00002a40 30 20 20 20 20 20 20 20 20 20 52 54 53 0d 20 20 |0 RTS. | 00002a50 36 38 30 20 2e 65 6e 76 65 6c 6f 70 65 0d 20 20 |680 .envelope. | 00002a60 36 39 30 20 20 20 20 20 20 20 20 20 4f 50 54 20 |690 OPT | 00002a70 46 4e 65 71 75 64 28 26 37 46 46 43 30 31 30 31 |FNequd(&7FFC0101| 00002a80 29 0d 20 20 37 30 30 20 20 20 20 20 20 20 20 20 |). 700 | 00002a90 4f 50 54 20 46 4e 65 71 75 64 28 26 38 44 36 35 |OPT FNequd(&8D65| 00002aa0 38 33 30 41 29 0d 20 20 37 31 30 20 20 20 20 20 |830A). 710 | 00002ab0 20 20 20 20 4f 50 54 20 46 4e 65 71 75 64 28 26 | OPT FNequd(&| 00002ac0 38 31 30 30 46 46 37 46 29 0d 20 20 37 32 30 20 |8100FF7F). 720 | 00002ad0 20 20 20 20 20 20 20 20 4f 50 54 20 46 4e 65 71 | OPT FNeq| 00002ae0 75 77 28 26 37 45 37 45 29 0d 20 20 37 33 30 20 |uw(&7E7E). 730 | 00002af0 2e 73 6f 75 6e 64 0d 20 20 37 34 30 20 20 20 20 |.sound. 740 | 00002b00 20 20 20 20 20 4f 50 54 20 46 4e 65 71 75 64 28 | OPT FNequd(| 00002b10 26 30 30 30 31 30 30 31 31 29 0d 20 20 37 35 30 |&00010011). 750| 00002b20 20 20 20 20 20 20 20 20 20 4f 50 54 20 46 4e 65 | OPT FNe| 00002b30 71 75 64 28 26 30 30 36 34 30 30 30 30 29 0d 20 |qud(&00640000). | 00002b40 20 37 36 30 20 2e 6c 61 73 74 62 79 74 65 0d 20 | 760 .lastbyte. | 00002b50 20 37 37 30 20 5d 0d 20 20 37 38 30 20 4e 45 58 | 770 ]. 780 NEX| 00002b60 54 0d 20 20 37 39 30 20 49 4e 50 55 54 27 22 53 |T. 790 INPUT'"S| 00002b70 61 76 65 20 66 69 6c 65 6e 61 6d 65 20 3d 20 22 |ave filename = "| 00002b80 66 69 6c 65 6e 61 6d 65 24 0d 20 20 38 30 30 20 |filename$. 800 | 00002b90 49 46 20 66 69 6c 65 6e 61 6d 65 24 3d 22 22 20 |IF filename$="" | 00002ba0 45 4e 44 0d 20 20 38 31 30 20 24 73 61 76 65 3d |END. 810 $save=| 00002bb0 22 53 41 56 45 20 22 2b 66 69 6c 65 6e 61 6d 65 |"SAVE "+filename| 00002bc0 24 2b 22 20 22 2b 53 54 52 24 7e 28 48 49 4d 45 |$+" "+STR$~(HIME| 00002bd0 4d 29 2b 22 20 22 2b 53 54 52 24 7e 28 6c 61 73 |M)+" "+STR$~(las| 00002be0 0d 20 20 20 20 20 20 74 62 79 74 65 29 2b 22 20 |. tbyte)+" | 00002bf0 46 46 46 46 38 30 30 30 20 46 46 46 46 38 30 30 |FFFF8000 FFFF800| 00002c00 30 22 0d 20 20 38 32 30 20 58 25 3d 73 61 76 65 |0". 820 X%=save| 00002c10 20 4d 4f 44 20 32 35 36 0d 20 20 38 33 30 20 59 | MOD 256. 830 Y| 00002c20 25 3d 73 61 76 65 20 44 49 56 20 32 35 36 0d 20 |%=save DIV 256. | 00002c30 20 38 34 30 20 2a 4f 50 54 31 2c 32 0d 20 20 38 | 840 *OPT1,2. 8| 00002c40 35 30 20 43 41 4c 4c 20 6f 73 63 6c 69 0d 20 20 |50 CALL oscli. | 00002c50 38 36 30 20 2a 4f 50 54 31 2c 30 0d 20 20 38 37 |860 *OPT1,0. 87| 00002c60 30 20 45 4e 44 0d 20 20 38 38 30 20 44 45 46 46 |0 END. 880 DEFF| 00002c70 4e 65 71 75 62 28 62 79 74 65 29 0d 20 20 38 39 |Nequb(byte). 89| 00002c80 30 20 3f 50 25 3d 62 79 74 65 0d 20 20 39 30 30 |0 ?P%=byte. 900| 00002c90 20 50 25 3d 50 25 2b 31 0d 20 20 39 31 30 20 3d | P%=P%+1. 910 =| 00002ca0 70 61 73 73 0d 20 20 39 32 30 20 44 45 46 46 4e |pass. 920 DEFFN| 00002cb0 65 71 75 77 28 77 6f 72 64 29 0d 20 20 39 33 30 |equw(word). 930| 00002cc0 20 3f 50 25 3d 77 6f 72 64 20 4d 4f 44 20 32 35 | ?P%=word MOD 25| 00002cd0 36 0d 20 20 39 34 30 20 50 25 3f 31 3d 77 6f 72 |6. 940 P%?1=wor| 00002ce0 64 20 44 49 56 20 32 35 36 0d 20 20 39 35 30 20 |d DIV 256. 950 | 00002cf0 50 25 3d 50 25 2b 32 0d 20 20 39 36 30 20 3d 70 |P%=P%+2. 960 =p| 00002d00 61 73 73 0d 20 20 39 37 30 20 44 45 46 46 4e 65 |ass. 970 DEFFNe| 00002d10 71 75 64 28 64 6f 75 62 6c 65 29 0d 20 20 39 38 |qud(double). 98| 00002d20 30 20 21 50 25 3d 64 6f 75 62 6c 65 0d 20 20 39 |0 !P%=double. 9| 00002d30 39 30 20 50 25 3d 50 25 2b 34 0d 20 31 30 30 30 |90 P%=P%+4. 1000| 00002d40 20 3d 70 61 73 73 0d 20 31 30 31 30 20 44 45 46 | =pass. 1010 DEF| 00002d50 46 4e 65 71 75 73 28 73 74 72 69 6e 67 24 29 0d |FNequs(string$).| 00002d60 20 31 30 32 30 20 24 50 25 3d 73 74 72 69 6e 67 | 1020 $P%=string| 00002d70 24 0d 20 31 30 33 30 20 50 25 3d 50 25 2b 4c 45 |$. 1030 P%=P%+LE| 00002d80 4e 28 73 74 72 69 6e 67 24 29 0d 20 31 30 34 30 |N(string$). 1040| 00002d90 20 3d 70 61 73 73 0d | =pass.| 00002d97