Home » CEEFAX disks » telesoftware3.adl » 04_12_87/T\SWR07
04_12_87/T\SWR07
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 » telesoftware3.adl |
Filename: | 04_12_87/T\SWR07 |
Read OK: | ✔ |
File size: | 2AF2 bytes |
Load address: | 0000 |
Exec address: | 0000 |
Duplicates
There is 1 duplicate copy of this file in the archive:
- CEEFAX disks » telesoftware3.adl » 04_12_87/T\SWR07
- CEEFAX disks » telesoftware8.adl » 19-08-88/T\SWR07
File contents
Mastering Sideways ROM & RAM - Module 07 - Osword ------------------------------------------------- The new Osbyte demonstrated in Module 6 used the X and Y registers to pass two parameters to a new routine. Osword is a similar concept to Osbyte except that parameters are passed in a parameter block the address of which is sent to the Osword routine in the X and Y registers. The low byte of the address is in X and the high byte in Y. Osword uses the same three consecutive zero page bytes as Osbyte to store the values of the A, X and Y registers. The accumulator value for the most recent Osword (or Osbyte) is stored in &EF. The X register value is stored in &F0 and the Y register value is stored in &F1. Oswords &00 to &0D are used by the MOS. Oswords &7D to &7F are used by the DFS and Oswords &E0 to &FF are passed to the user vector (USERV) at &200. You can define any other Osword in your SWR programs but it is wise to use TRACE to make sure the number you intend to use is available as an unused Osword on your machine. The example program in this module will define Osword 100 (&64). Using TRACE to find the service request for an unrecognised Osword involves a bit more typing than using it to find the service request for an unrecognised Osbyte. Load the object code generated by TRACE into SWR and press the Break key. Call Osword 100 using a dummy parameter block address with the trace active. You should get the response shown in figure 7.1 which shows that service call 8 is used and that the address of the parameter block is only available from &F0 and &F1 and not directly from the index registers. >A%=100:X%=100:Y%=100:CALL &FFF1 A=08 X=0F Y=00 Unrecognised Osword > Figure 7.1 Service trace for unrecognised Osword. ------------------------------------------------- Defining a new Osword is no more difficult than defining a new Osbyte but it more useful because you can pass more than two parameters to and from the new routine in the parameter block. Up to 256 new routines can share the same Osword number by using the a byte of the parameter block as an index on the available routines. For example, if the number stored in the first byte of the parameter block is n, your Osword interpreter could pass control to the (n+1)th routine. The outline Osword interpreter in figure 7.2 does not use this type of extended Osword. .service PHA \ push accumulator CMP #8 \ is it unrecognised Osword? BEQ newosword \ branch if it is .exit PLA \ pull accumulator RTS \ return and give other roms the call .newosword LDA &EF \ load Osword number CMP #100 \ is it 100? BNE exit \ branch if not Osword 100 . . \ new routine goes in here . LDX &F0 \ make sure X and &F0 are identical LDY &F1 \ make sure Y and &F1 are indenical PLA \ pull A pushed by interpreter LDA #0 \ other roms ignore this call RTS \ return to MOS Figure 7.2 An Osword interpreter. --------------------------------- The service entry point of the outline interpreter in figure 7.2 will have a jump to the label ".service". On entering the interpreter the accumulator is pushed on the stack and then compared with 8 to see if the call is an unrecognised Osword. If it is not the accumulator is pulled off the stack and control is returned to the MOS. If the call is for an unrecognised Osword the number stored in &EF is loaded into the accumulator and compared with the number of the new Osword, in this example 100. If the unrecognised Osword number stored in &EF is not 100 the accumulator is pulled off the stack and control is returned to the MOS. If it is 100 then the new routine can be executed. The address of the parameter block can be read from &F0 (low byte) and &F1 (high byte). The parameter block must be in the I/O processor. After completing the new routine you should ensure that the index registers and their zero page copies are identical. In figure 7.2 it is assumed that the contents of &EF, &F0 and &F1 have not been altered. The accumulator was pushed on the stack by the interpreter and it is pulled back off to balance the stack. The accumulator is reset to zero to inform other roms that the service call has been recognised and control is returned to the MOS. On return the MOS copies the Osword number into the accumulator. Unlike Osbyte, Osword does not use &F0 and &F1 to write any results. If your new routines write any results these must be written in the parameter block. &EF, &F0 and &F1 should be restored before returning from Osword. The program OSWORD uses an interpreter similar to the one outlined in figure 7.2 to implement a PRINT TAB(X,Y) routine as Osword 100 (&64). This routine gives access to PRINT TAB in both BASIC and machine code. To use the new Osword you need to load the object code generated by the program OSWORD into SWR and press the Break key. Any program which uses the new routine must define a parameter block to contain the two byte address of a text string and the two bytes for the screen X and Y co-ordinates of the first character of the string. Because four bytes of information are needed for this routine an Osbyte could not be used. The progrm OSWDEMO shows how to set up the parameter block in Assembly language. 10 REM OSWDEMO 20 MODE7 30 DIM mcode &100 40 osword=&FFF1 50 FOR pass=0 TO 2 STEP 2 60 P%=mcode 70 [ OPT pass 80 LDA #100 90 LDX #pblock MOD 256 100 LDY #pblock DIV 256 110 JSR osword 120 LDA #100 130 LDX #pblock2 MOD 256 140 LDY #pblock2 DIV 256 150 JSR osword 160 RTS 170 .pblock 180 OPT FNequw(text) 190 OPT FNequb(5) 200 OPT FNequb(11) 210 .pblock2 220 OPT FNequw(text) 230 OPT FNequb(5) 240 OPT FNequb(12) 250 .text 260 OPT FNequb(141) 270 OPT FNequb(131) 280 OPT FNequs("Demonstration of new Osword") 290 OPT FNequb(13) 300 ] 310 NEXT 320 CALL mcode 330 END 340 DEFFNequb(byte) 350 ?P%=byte 360 P%=P%+1 370 =pass 380 DEFFNequw(word) 390 ?P%=word MOD 256 400 P%?1=word DIV 256 410 P%=P%+2 420 =pass 430 DEFFNequd(double) 440 !P%=double 450 P%=P%+4 460 =pass 470 DEFFNequs(string$) 480 $P%=string$ 490 P%=P%+LEN(string$) 500 =pass The new Osword 100 can be used in any text mode but OSWDEMO uses it to print a string in double height, yellow, Mode 7 characters. OSWDEMO must run in the I/O processor. The first two bytes of the parameter blocks store the address of the text block (lines 180 and 220). The third byte of the parameter blocks store the screen X co-ordinate of the first byte of the string (lines 190 and 230) and the fourth byte stores the screen Y co-ordinate of the first byte of the string (lines 200 and 240). Before calling the new Osword (lines 110 and 150) the accumulator is loaded with the new Osword number (lines 80 and 120), the X register with the low byte of the parameter block address (lines 90 and 130), and the Y register with the high byte of the parameter block address (lines 100 and 140). Osword 100 prints the string on the screen and returns with A, X and Y registers preserved. The program OSWORD uses an Osword interpreter (lines 270-370) similar to the one outlined in figure 7.2. After recognising the new Osword (lines 350-370) the new routine preserves the two zero page bytes it uses to print the string by pushing them on the stack (lines 380-410). The address of the parameter block is stored in &F0 (low byte) and &F1 (high byte). These two zero page memory locations are used with post-indexed indirect addressing to read the contents of the parameter block. The Y register is reset to zero (line 420) and the address of the text block is read from the parameter block and stored in zero page ready to print the text string (lines 430-470). The screen X and Y co-ordinates are read from the parameter block and the text cursor is positioned using the machine code equivalent of VDU 31,x,y (lines 480-550). The text string is then printed on the screen (lines 560-640). The zero page locations used by the print routine are pulled off the stack and restored (lines 650-680). The index registers are restored (lines 690-700), the accumulator is reset to zero to inform the other roms that the service call has been recognised (lines 710-720) and contol is returned to the MOS (line 730). 10 REM: OSWORD 20 MODE7 30 HIMEM=&3C00 40 DIM save 50 50 diff=&8000-HIMEM 60 address=&70 70 accumulator=&EF 80 xregister=&F0 90 yregister=&F1 100 osasci=&FFE3 110 oscli=&FFF7 120 FOR pass = 0 TO 2 STEP 2 130 P%=HIMEM 140 [ OPT pass 150 BRK 160 BRK 170 BRK 180 JMP service+diff 190 OPT FNequb(&82) 200 OPT FNequb((copyright+diff) MOD 256) 210 BRK 220 OPT FNequs("OSWORD") 230 .copyright 240 BRK 250 OPT FNequs("(C) Gordon Horsington 1987") 260 BRK 270 .service 280 PHA 290 CMP #8 300 BEQ newosword 310 .exit 320 PLA 330 RTS 340 .newosword 350 LDA accumulator 360 CMP #100 370 BNE exit 380 LDA address 390 PHA 400 LDA address+1 410 PHA 420 LDY #0 430 LDA (xregister),Y 440 STA address 450 INY 460 LDA (xregister),Y 470 STA address+1 480 LDA #31 490 JSR osasci 500 INY 510 LDA (xregister),Y 520 JSR osasci 530 INY 540 LDA (xregister),Y 550 JSR osasci 560 LDY #&FF 570 .printloop 580 INY 590 LDA (address),Y 600 BEQ finish 610 JSR osasci 620 CMP #13 630 BNE printloop 640 .finish 650 PLA 660 STA address+1 670 PLA 680 STA address 690 LDX xregister 700 LDY yregister 710 PLA 720 LDA #0 730 RTS 740 .lastbyte 750 ] 760 NEXT 770 INPUT'"Save filename = "filename$ 780 IF filename$="" END 790 $save="SAVE "+filename$+" "+STR$~(HIMEM)+" "+STR$~(las tbyte)+" FFFF8000 FFFF8000" 800 X%=save MOD 256 810 Y%=save DIV 256 820 *OPT1,2 830 CALL oscli 840 *OPT1,0 850 END 860 DEFFNequb(byte) 870 ?P%=byte 880 P%=P%+1 890 =pass 900 DEFFNequw(word) 910 ?P%=word MOD 256 920 P%?1=word DIV 256 930 P%=P%+2 940 =pass 950 DEFFNequd(double) 960 !P%=double 970 P%=P%+4 980 =pass 990 DEFFNequs(string$) 1000 $P%=string$ 1010 P%=P%+LEN(string$) 1020 =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 37 20 2d 20 4f 73 77 6f 72 |odule 07 - Oswor| 00000030 64 0d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |d.--------------| 00000040 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 00000060 2d 2d 2d 0d 0d 20 20 54 68 65 20 6e 65 77 20 4f |---.. The new O| 00000070 73 62 79 74 65 20 64 65 6d 6f 6e 73 74 72 61 74 |sbyte demonstrat| 00000080 65 64 20 69 6e 20 4d 6f 64 75 6c 65 20 36 20 75 |ed in Module 6 u| 00000090 73 65 64 20 74 68 65 20 58 20 61 6e 64 20 59 20 |sed the X and Y | 000000a0 72 65 67 69 73 74 65 72 73 20 74 6f 0d 70 61 73 |registers to.pas| 000000b0 73 20 74 77 6f 20 70 61 72 61 6d 65 74 65 72 73 |s two parameters| 000000c0 20 74 6f 20 61 20 6e 65 77 20 72 6f 75 74 69 6e | to a new routin| 000000d0 65 2e 20 4f 73 77 6f 72 64 20 69 73 20 61 20 73 |e. Osword is a s| 000000e0 69 6d 69 6c 61 72 20 63 6f 6e 63 65 70 74 20 74 |imilar concept t| 000000f0 6f 0d 4f 73 62 79 74 65 20 65 78 63 65 70 74 20 |o.Osbyte except | 00000100 74 68 61 74 20 70 61 72 61 6d 65 74 65 72 73 20 |that parameters | 00000110 61 72 65 20 70 61 73 73 65 64 20 69 6e 20 61 20 |are passed in a | 00000120 70 61 72 61 6d 65 74 65 72 20 62 6c 6f 63 6b 20 |parameter block | 00000130 74 68 65 0d 61 64 64 72 65 73 73 20 6f 66 20 77 |the.address of w| 00000140 68 69 63 68 20 69 73 20 73 65 6e 74 20 74 6f 20 |hich is sent to | 00000150 74 68 65 20 4f 73 77 6f 72 64 20 72 6f 75 74 69 |the Osword routi| 00000160 6e 65 20 69 6e 20 74 68 65 20 58 20 61 6e 64 20 |ne in the X and | 00000170 59 20 72 65 67 69 73 74 65 72 73 2e 0d 54 68 65 |Y registers..The| 00000180 20 6c 6f 77 20 62 79 74 65 20 6f 66 20 74 68 65 | low byte of the| 00000190 20 61 64 64 72 65 73 73 20 69 73 20 69 6e 20 58 | address is in X| 000001a0 20 61 6e 64 20 74 68 65 20 68 69 67 68 20 62 79 | and the high by| 000001b0 74 65 20 69 6e 20 59 2e 0d 0d 20 20 4f 73 77 6f |te in Y... Oswo| 000001c0 72 64 20 75 73 65 73 20 74 68 65 20 73 61 6d 65 |rd uses the same| 000001d0 20 74 68 72 65 65 20 63 6f 6e 73 65 63 75 74 69 | three consecuti| 000001e0 76 65 20 7a 65 72 6f 20 70 61 67 65 20 62 79 74 |ve zero page byt| 000001f0 65 73 20 61 73 20 4f 73 62 79 74 65 20 74 6f 0d |es as Osbyte to.| 00000200 73 74 6f 72 65 20 74 68 65 20 76 61 6c 75 65 73 |store the values| 00000210 20 6f 66 20 74 68 65 20 41 2c 20 58 20 61 6e 64 | of the A, X and| 00000220 20 59 20 72 65 67 69 73 74 65 72 73 2e 20 54 68 | Y registers. Th| 00000230 65 20 61 63 63 75 6d 75 6c 61 74 6f 72 20 76 61 |e accumulator va| 00000240 6c 75 65 20 66 6f 72 0d 74 68 65 20 6d 6f 73 74 |lue for.the most| 00000250 20 72 65 63 65 6e 74 20 4f 73 77 6f 72 64 20 28 | recent Osword (| 00000260 6f 72 20 4f 73 62 79 74 65 29 20 69 73 20 73 74 |or Osbyte) is st| 00000270 6f 72 65 64 20 69 6e 20 26 45 46 2e 20 54 68 65 |ored in &EF. The| 00000280 20 58 20 72 65 67 69 73 74 65 72 0d 76 61 6c 75 | X register.valu| 00000290 65 20 69 73 20 73 74 6f 72 65 64 20 69 6e 20 26 |e is stored in &| 000002a0 46 30 20 61 6e 64 20 74 68 65 20 59 20 72 65 67 |F0 and the Y reg| 000002b0 69 73 74 65 72 20 76 61 6c 75 65 20 69 73 20 73 |ister value is s| 000002c0 74 6f 72 65 64 20 69 6e 20 26 46 31 2e 0d 0d 20 |tored in &F1... | 000002d0 20 4f 73 77 6f 72 64 73 20 26 30 30 20 74 6f 20 | Oswords &00 to | 000002e0 26 30 44 20 61 72 65 20 75 73 65 64 20 62 79 20 |&0D are used by | 000002f0 74 68 65 20 4d 4f 53 2e 20 4f 73 77 6f 72 64 73 |the MOS. Oswords| 00000300 20 26 37 44 20 74 6f 20 26 37 46 20 61 72 65 20 | &7D to &7F are | 00000310 75 73 65 64 20 62 79 0d 74 68 65 20 44 46 53 20 |used by.the DFS | 00000320 61 6e 64 20 4f 73 77 6f 72 64 73 20 26 45 30 20 |and Oswords &E0 | 00000330 74 6f 20 26 46 46 20 61 72 65 20 70 61 73 73 65 |to &FF are passe| 00000340 64 20 74 6f 20 74 68 65 20 75 73 65 72 20 76 65 |d to the user ve| 00000350 63 74 6f 72 20 28 55 53 45 52 56 29 20 61 74 0d |ctor (USERV) at.| 00000360 26 32 30 30 2e 20 59 6f 75 20 63 61 6e 20 64 65 |&200. You can de| 00000370 66 69 6e 65 20 61 6e 79 20 6f 74 68 65 72 20 4f |fine any other O| 00000380 73 77 6f 72 64 20 69 6e 20 79 6f 75 72 20 53 57 |sword in your SW| 00000390 52 20 70 72 6f 67 72 61 6d 73 20 62 75 74 20 69 |R programs but i| 000003a0 74 20 69 73 0d 77 69 73 65 20 74 6f 20 75 73 65 |t is.wise to use| 000003b0 20 54 52 41 43 45 20 74 6f 20 6d 61 6b 65 20 73 | TRACE to make s| 000003c0 75 72 65 20 74 68 65 20 6e 75 6d 62 65 72 20 79 |ure the number y| 000003d0 6f 75 20 69 6e 74 65 6e 64 20 74 6f 20 75 73 65 |ou intend to use| 000003e0 20 69 73 20 61 76 61 69 6c 61 62 6c 65 0d 61 73 | is available.as| 000003f0 20 61 6e 20 75 6e 75 73 65 64 20 4f 73 77 6f 72 | an unused Oswor| 00000400 64 20 6f 6e 20 79 6f 75 72 20 6d 61 63 68 69 6e |d on your machin| 00000410 65 2e 20 54 68 65 20 65 78 61 6d 70 6c 65 20 70 |e. The example p| 00000420 72 6f 67 72 61 6d 20 69 6e 20 74 68 69 73 20 6d |rogram in this m| 00000430 6f 64 75 6c 65 0d 77 69 6c 6c 20 64 65 66 69 6e |odule.will defin| 00000440 65 20 4f 73 77 6f 72 64 20 31 30 30 20 28 26 36 |e Osword 100 (&6| 00000450 34 29 2e 0d 0d 20 20 55 73 69 6e 67 20 54 52 41 |4)... Using TRA| 00000460 43 45 20 74 6f 20 66 69 6e 64 20 74 68 65 20 73 |CE to find the s| 00000470 65 72 76 69 63 65 20 72 65 71 75 65 73 74 20 66 |ervice request f| 00000480 6f 72 20 61 6e 20 75 6e 72 65 63 6f 67 6e 69 73 |or an unrecognis| 00000490 65 64 20 4f 73 77 6f 72 64 0d 69 6e 76 6f 6c 76 |ed Osword.involv| 000004a0 65 73 20 61 20 62 69 74 20 6d 6f 72 65 20 74 79 |es a bit more ty| 000004b0 70 69 6e 67 20 74 68 61 6e 20 75 73 69 6e 67 20 |ping than using | 000004c0 69 74 20 74 6f 20 66 69 6e 64 20 74 68 65 20 73 |it to find the s| 000004d0 65 72 76 69 63 65 20 72 65 71 75 65 73 74 20 66 |ervice request f| 000004e0 6f 72 0d 61 6e 20 75 6e 72 65 63 6f 67 6e 69 73 |or.an unrecognis| 000004f0 65 64 20 4f 73 62 79 74 65 2e 0d 0d 20 20 4c 6f |ed Osbyte... Lo| 00000500 61 64 20 74 68 65 20 6f 62 6a 65 63 74 20 63 6f |ad the object co| 00000510 64 65 20 67 65 6e 65 72 61 74 65 64 20 62 79 20 |de generated by | 00000520 54 52 41 43 45 20 69 6e 74 6f 20 53 57 52 20 61 |TRACE into SWR a| 00000530 6e 64 20 70 72 65 73 73 20 74 68 65 20 42 72 65 |nd press the Bre| 00000540 61 6b 0d 6b 65 79 2e 20 43 61 6c 6c 20 4f 73 77 |ak.key. Call Osw| 00000550 6f 72 64 20 31 30 30 20 75 73 69 6e 67 20 61 20 |ord 100 using a | 00000560 64 75 6d 6d 79 20 70 61 72 61 6d 65 74 65 72 20 |dummy parameter | 00000570 62 6c 6f 63 6b 20 61 64 64 72 65 73 73 20 77 69 |block address wi| 00000580 74 68 20 74 68 65 0d 74 72 61 63 65 20 61 63 74 |th the.trace act| 00000590 69 76 65 2e 20 59 6f 75 20 73 68 6f 75 6c 64 20 |ive. You should | 000005a0 67 65 74 20 74 68 65 20 72 65 73 70 6f 6e 73 65 |get the response| 000005b0 20 73 68 6f 77 6e 20 69 6e 20 66 69 67 75 72 65 | shown in figure| 000005c0 20 37 2e 31 20 77 68 69 63 68 0d 73 68 6f 77 73 | 7.1 which.shows| 000005d0 20 74 68 61 74 20 73 65 72 76 69 63 65 20 63 61 | that service ca| 000005e0 6c 6c 20 38 20 69 73 20 75 73 65 64 20 61 6e 64 |ll 8 is used and| 000005f0 20 74 68 61 74 20 74 68 65 20 61 64 64 72 65 73 | that the addres| 00000600 73 20 6f 66 20 74 68 65 20 70 61 72 61 6d 65 74 |s of the paramet| 00000610 65 72 0d 62 6c 6f 63 6b 20 69 73 20 6f 6e 6c 79 |er.block is only| 00000620 20 61 76 61 69 6c 61 62 6c 65 20 66 72 6f 6d 20 | available from | 00000630 26 46 30 20 61 6e 64 20 26 46 31 20 61 6e 64 20 |&F0 and &F1 and | 00000640 6e 6f 74 20 64 69 72 65 63 74 6c 79 20 66 72 6f |not directly fro| 00000650 6d 20 74 68 65 20 69 6e 64 65 78 0d 72 65 67 69 |m the index.regi| 00000660 73 74 65 72 73 2e 0d 0d 0d 0d 0d 3e 41 25 3d 31 |sters......>A%=1| 00000670 30 30 3a 58 25 3d 31 30 30 3a 59 25 3d 31 30 30 |00:X%=100:Y%=100| 00000680 3a 43 41 4c 4c 20 26 46 46 46 31 0d 20 41 3d 30 |:CALL &FFF1. A=0| 00000690 38 20 58 3d 30 46 20 59 3d 30 30 20 55 6e 72 65 |8 X=0F Y=00 Unre| 000006a0 63 6f 67 6e 69 73 65 64 20 4f 73 77 6f 72 64 0d |cognised Osword.| 000006b0 3e 0d 0d 46 69 67 75 72 65 20 37 2e 31 20 53 65 |>..Figure 7.1 Se| 000006c0 72 76 69 63 65 20 74 72 61 63 65 20 66 6f 72 20 |rvice trace for | 000006d0 75 6e 72 65 63 6f 67 6e 69 73 65 64 20 4f 73 77 |unrecognised Osw| 000006e0 6f 72 64 2e 0d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |ord..-----------| 000006f0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 00000710 2d 2d 2d 2d 2d 2d 0d 0d 0d 0d 0d 20 20 44 65 66 |------..... Def| 00000720 69 6e 69 6e 67 20 61 20 6e 65 77 20 4f 73 77 6f |ining a new Oswo| 00000730 72 64 20 69 73 20 6e 6f 20 6d 6f 72 65 20 64 69 |rd is no more di| 00000740 66 66 69 63 75 6c 74 20 74 68 61 6e 20 64 65 66 |fficult than def| 00000750 69 6e 69 6e 67 20 61 20 6e 65 77 20 4f 73 62 79 |ining a new Osby| 00000760 74 65 0d 62 75 74 20 69 74 20 6d 6f 72 65 20 75 |te.but it more u| 00000770 73 65 66 75 6c 20 62 65 63 61 75 73 65 20 79 6f |seful because yo| 00000780 75 20 63 61 6e 20 70 61 73 73 20 6d 6f 72 65 20 |u can pass more | 00000790 74 68 61 6e 20 74 77 6f 20 70 61 72 61 6d 65 74 |than two paramet| 000007a0 65 72 73 20 74 6f 20 61 6e 64 0d 66 72 6f 6d 20 |ers to and.from | 000007b0 74 68 65 20 6e 65 77 20 72 6f 75 74 69 6e 65 20 |the new routine | 000007c0 69 6e 20 74 68 65 20 70 61 72 61 6d 65 74 65 72 |in the parameter| 000007d0 20 62 6c 6f 63 6b 2e 0d 0d 20 20 55 70 20 74 6f | block... Up to| 000007e0 20 32 35 36 20 6e 65 77 20 72 6f 75 74 69 6e 65 | 256 new routine| 000007f0 73 20 63 61 6e 20 73 68 61 72 65 20 74 68 65 20 |s can share the | 00000800 73 61 6d 65 20 4f 73 77 6f 72 64 20 6e 75 6d 62 |same Osword numb| 00000810 65 72 20 62 79 20 75 73 69 6e 67 20 74 68 65 20 |er by using the | 00000820 61 0d 62 79 74 65 20 6f 66 20 74 68 65 20 70 61 |a.byte of the pa| 00000830 72 61 6d 65 74 65 72 20 62 6c 6f 63 6b 20 61 73 |rameter block as| 00000840 20 61 6e 20 69 6e 64 65 78 20 6f 6e 20 74 68 65 | an index on the| 00000850 20 61 76 61 69 6c 61 62 6c 65 20 72 6f 75 74 69 | available routi| 00000860 6e 65 73 2e 20 46 6f 72 0d 65 78 61 6d 70 6c 65 |nes. For.example| 00000870 2c 20 69 66 20 74 68 65 20 6e 75 6d 62 65 72 20 |, if the number | 00000880 73 74 6f 72 65 64 20 69 6e 20 74 68 65 20 66 69 |stored in the fi| 00000890 72 73 74 20 62 79 74 65 20 6f 66 20 74 68 65 20 |rst byte of the | 000008a0 70 61 72 61 6d 65 74 65 72 20 62 6c 6f 63 6b 0d |parameter block.| 000008b0 69 73 20 6e 2c 20 79 6f 75 72 20 4f 73 77 6f 72 |is n, your Oswor| 000008c0 64 20 69 6e 74 65 72 70 72 65 74 65 72 20 63 6f |d interpreter co| 000008d0 75 6c 64 20 70 61 73 73 20 63 6f 6e 74 72 6f 6c |uld pass control| 000008e0 20 74 6f 20 74 68 65 20 28 6e 2b 31 29 74 68 20 | to the (n+1)th | 000008f0 72 6f 75 74 69 6e 65 2e 0d 54 68 65 20 6f 75 74 |routine..The out| 00000900 6c 69 6e 65 20 4f 73 77 6f 72 64 20 69 6e 74 65 |line Osword inte| 00000910 72 70 72 65 74 65 72 20 69 6e 20 66 69 67 75 72 |rpreter in figur| 00000920 65 20 37 2e 32 20 64 6f 65 73 20 6e 6f 74 20 75 |e 7.2 does not u| 00000930 73 65 20 74 68 69 73 20 74 79 70 65 20 6f 66 0d |se this type of.| 00000940 65 78 74 65 6e 64 65 64 20 4f 73 77 6f 72 64 2e |extended Osword.| 00000950 0d 0d 0d 0d 0d 2e 73 65 72 76 69 63 65 0d 20 20 |......service. | 00000960 20 20 20 20 20 20 20 50 48 41 20 20 20 20 20 20 | PHA | 00000970 20 20 20 20 20 5c 20 70 75 73 68 20 61 63 63 75 | \ push accu| 00000980 6d 75 6c 61 74 6f 72 0d 20 20 20 20 20 20 20 20 |mulator. | 00000990 20 43 4d 50 20 23 38 20 20 20 20 20 20 20 20 5c | CMP #8 \| 000009a0 20 69 73 20 69 74 20 75 6e 72 65 63 6f 67 6e 69 | is it unrecogni| 000009b0 73 65 64 20 4f 73 77 6f 72 64 3f 0d 20 20 20 20 |sed Osword?. | 000009c0 20 20 20 20 20 42 45 51 20 6e 65 77 6f 73 77 6f | BEQ newoswo| 000009d0 72 64 20 5c 20 62 72 61 6e 63 68 20 69 66 20 69 |rd \ branch if i| 000009e0 74 20 69 73 0d 2e 65 78 69 74 0d 20 20 20 20 20 |t is..exit. | 000009f0 20 20 20 20 50 4c 41 20 20 20 20 20 20 20 20 20 | PLA | 00000a00 20 20 5c 20 70 75 6c 6c 20 61 63 63 75 6d 75 6c | \ pull accumul| 00000a10 61 74 6f 72 0d 20 20 20 20 20 20 20 20 20 52 54 |ator. RT| 00000a20 53 20 20 20 20 20 20 20 20 20 20 20 5c 20 72 65 |S \ re| 00000a30 74 75 72 6e 20 61 6e 64 20 67 69 76 65 20 6f 74 |turn and give ot| 00000a40 68 65 72 20 72 6f 6d 73 20 74 68 65 20 63 61 6c |her roms the cal| 00000a50 6c 0d 2e 6e 65 77 6f 73 77 6f 72 64 0d 20 20 20 |l..newosword. | 00000a60 20 20 20 20 20 20 4c 44 41 20 26 45 46 20 20 20 | LDA &EF | 00000a70 20 20 20 20 5c 20 6c 6f 61 64 20 4f 73 77 6f 72 | \ load Oswor| 00000a80 64 20 6e 75 6d 62 65 72 0d 20 20 20 20 20 20 20 |d number. | 00000a90 20 20 43 4d 50 20 23 31 30 30 20 20 20 20 20 20 | CMP #100 | 00000aa0 5c 20 69 73 20 69 74 20 31 30 30 3f 0d 20 20 20 |\ is it 100?. | 00000ab0 20 20 20 20 20 20 42 4e 45 20 65 78 69 74 20 20 | BNE exit | 00000ac0 20 20 20 20 5c 20 62 72 61 6e 63 68 20 69 66 20 | \ branch if | 00000ad0 6e 6f 74 20 4f 73 77 6f 72 64 20 31 30 30 0d 20 |not Osword 100. | 00000ae0 20 20 20 20 20 20 20 20 20 2e 0d 20 20 20 20 20 | .. | 00000af0 20 20 20 20 20 2e 20 20 20 20 20 20 20 20 20 20 | . | 00000b00 20 20 5c 20 6e 65 77 20 72 6f 75 74 69 6e 65 20 | \ new routine | 00000b10 67 6f 65 73 20 69 6e 20 68 65 72 65 0d 20 20 20 |goes in here. | 00000b20 20 20 20 20 20 20 20 2e 0d 20 20 20 20 20 20 20 | .. | 00000b30 20 20 4c 44 58 20 26 46 30 20 20 20 20 20 20 20 | LDX &F0 | 00000b40 5c 20 6d 61 6b 65 20 73 75 72 65 20 58 20 61 6e |\ make sure X an| 00000b50 64 20 26 46 30 20 61 72 65 20 69 64 65 6e 74 69 |d &F0 are identi| 00000b60 63 61 6c 0d 20 20 20 20 20 20 20 20 20 4c 44 59 |cal. LDY| 00000b70 20 26 46 31 20 20 20 20 20 20 20 5c 20 6d 61 6b | &F1 \ mak| 00000b80 65 20 73 75 72 65 20 59 20 61 6e 64 20 26 46 31 |e sure Y and &F1| 00000b90 20 61 72 65 20 69 6e 64 65 6e 69 63 61 6c 0d 20 | are indenical. | 00000ba0 20 20 20 20 20 20 20 20 50 4c 41 20 20 20 20 20 | PLA | 00000bb0 20 20 20 20 20 20 5c 20 70 75 6c 6c 20 41 20 70 | \ pull A p| 00000bc0 75 73 68 65 64 20 62 79 20 69 6e 74 65 72 70 72 |ushed by interpr| 00000bd0 65 74 65 72 0d 20 20 20 20 20 20 20 20 20 4c 44 |eter. LD| 00000be0 41 20 23 30 20 20 20 20 20 20 20 20 5c 20 6f 74 |A #0 \ ot| 00000bf0 68 65 72 20 72 6f 6d 73 20 69 67 6e 6f 72 65 20 |her roms ignore | 00000c00 74 68 69 73 20 63 61 6c 6c 0d 20 20 20 20 20 20 |this call. | 00000c10 20 20 20 52 54 53 20 20 20 20 20 20 20 20 20 20 | RTS | 00000c20 20 5c 20 72 65 74 75 72 6e 20 74 6f 20 4d 4f 53 | \ return to MOS| 00000c30 0d 0d 46 69 67 75 72 65 20 37 2e 32 20 41 6e 20 |..Figure 7.2 An | 00000c40 4f 73 77 6f 72 64 20 69 6e 74 65 72 70 72 65 74 |Osword interpret| 00000c50 65 72 2e 0d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |er..------------| 00000c60 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00000c70 2d 2d 2d 2d 2d 0d 0d 0d 0d 20 20 54 68 65 20 73 |-----.... The s| 00000c80 65 72 76 69 63 65 20 65 6e 74 72 79 20 70 6f 69 |ervice entry poi| 00000c90 6e 74 20 6f 66 20 74 68 65 20 6f 75 74 6c 69 6e |nt of the outlin| 00000ca0 65 20 69 6e 74 65 72 70 72 65 74 65 72 20 69 6e |e interpreter in| 00000cb0 20 66 69 67 75 72 65 20 37 2e 32 20 77 69 6c 6c | figure 7.2 will| 00000cc0 0d 68 61 76 65 20 61 20 6a 75 6d 70 20 74 6f 20 |.have a jump to | 00000cd0 74 68 65 20 6c 61 62 65 6c 20 22 2e 73 65 72 76 |the label ".serv| 00000ce0 69 63 65 22 2e 20 4f 6e 20 65 6e 74 65 72 69 6e |ice". On enterin| 00000cf0 67 20 74 68 65 20 69 6e 74 65 72 70 72 65 74 65 |g the interprete| 00000d00 72 20 74 68 65 0d 61 63 63 75 6d 75 6c 61 74 6f |r the.accumulato| 00000d10 72 20 69 73 20 70 75 73 68 65 64 20 6f 6e 20 74 |r is pushed on t| 00000d20 68 65 20 73 74 61 63 6b 20 61 6e 64 20 74 68 65 |he stack and the| 00000d30 6e 20 63 6f 6d 70 61 72 65 64 20 77 69 74 68 20 |n compared with | 00000d40 38 20 74 6f 20 73 65 65 20 69 66 0d 74 68 65 20 |8 to see if.the | 00000d50 63 61 6c 6c 20 69 73 20 61 6e 20 75 6e 72 65 63 |call is an unrec| 00000d60 6f 67 6e 69 73 65 64 20 4f 73 77 6f 72 64 2e 20 |ognised Osword. | 00000d70 49 66 20 69 74 20 69 73 20 6e 6f 74 20 74 68 65 |If it is not the| 00000d80 20 61 63 63 75 6d 75 6c 61 74 6f 72 20 69 73 0d | accumulator is.| 00000d90 70 75 6c 6c 65 64 20 6f 66 66 20 74 68 65 20 73 |pulled off the s| 00000da0 74 61 63 6b 20 61 6e 64 20 63 6f 6e 74 72 6f 6c |tack and control| 00000db0 20 69 73 20 72 65 74 75 72 6e 65 64 20 74 6f 20 | is returned to | 00000dc0 74 68 65 20 4d 4f 53 2e 20 49 66 20 74 68 65 20 |the MOS. If the | 00000dd0 63 61 6c 6c 20 69 73 0d 66 6f 72 20 61 6e 20 75 |call is.for an u| 00000de0 6e 72 65 63 6f 67 6e 69 73 65 64 20 4f 73 77 6f |nrecognised Oswo| 00000df0 72 64 20 74 68 65 20 6e 75 6d 62 65 72 20 73 74 |rd the number st| 00000e00 6f 72 65 64 20 69 6e 20 26 45 46 20 69 73 20 6c |ored in &EF is l| 00000e10 6f 61 64 65 64 20 69 6e 74 6f 20 74 68 65 0d 61 |oaded into the.a| 00000e20 63 63 75 6d 75 6c 61 74 6f 72 20 61 6e 64 20 63 |ccumulator and c| 00000e30 6f 6d 70 61 72 65 64 20 77 69 74 68 20 74 68 65 |ompared with the| 00000e40 20 6e 75 6d 62 65 72 20 6f 66 20 74 68 65 20 6e | number of the n| 00000e50 65 77 20 4f 73 77 6f 72 64 2c 20 69 6e 20 74 68 |ew Osword, in th| 00000e60 69 73 0d 65 78 61 6d 70 6c 65 20 31 30 30 2e 0d |is.example 100..| 00000e70 0d 20 20 49 66 20 74 68 65 20 75 6e 72 65 63 6f |. If the unreco| 00000e80 67 6e 69 73 65 64 20 4f 73 77 6f 72 64 20 6e 75 |gnised Osword nu| 00000e90 6d 62 65 72 20 73 74 6f 72 65 64 20 69 6e 20 26 |mber stored in &| 00000ea0 45 46 20 69 73 20 6e 6f 74 20 31 30 30 20 74 68 |EF is not 100 th| 00000eb0 65 0d 61 63 63 75 6d 75 6c 61 74 6f 72 20 69 73 |e.accumulator is| 00000ec0 20 70 75 6c 6c 65 64 20 6f 66 66 20 74 68 65 20 | pulled off the | 00000ed0 73 74 61 63 6b 20 61 6e 64 20 63 6f 6e 74 72 6f |stack and contro| 00000ee0 6c 20 69 73 20 72 65 74 75 72 6e 65 64 20 74 6f |l is returned to| 00000ef0 20 74 68 65 20 4d 4f 53 2e 0d 49 66 20 69 74 20 | the MOS..If it | 00000f00 69 73 20 31 30 30 20 74 68 65 6e 20 74 68 65 20 |is 100 then the | 00000f10 6e 65 77 20 72 6f 75 74 69 6e 65 20 63 61 6e 20 |new routine can | 00000f20 62 65 20 65 78 65 63 75 74 65 64 2e 20 54 68 65 |be executed. The| 00000f30 20 61 64 64 72 65 73 73 20 6f 66 20 74 68 65 0d | address of the.| 00000f40 70 61 72 61 6d 65 74 65 72 20 62 6c 6f 63 6b 20 |parameter block | 00000f50 63 61 6e 20 62 65 20 72 65 61 64 20 66 72 6f 6d |can be read from| 00000f60 20 26 46 30 20 28 6c 6f 77 20 62 79 74 65 29 20 | &F0 (low byte) | 00000f70 61 6e 64 20 26 46 31 20 28 68 69 67 68 20 62 79 |and &F1 (high by| 00000f80 74 65 29 2e 20 54 68 65 0d 70 61 72 61 6d 65 74 |te). The.paramet| 00000f90 65 72 20 62 6c 6f 63 6b 20 6d 75 73 74 20 62 65 |er block must be| 00000fa0 20 69 6e 20 74 68 65 20 49 2f 4f 20 70 72 6f 63 | in the I/O proc| 00000fb0 65 73 73 6f 72 2e 0d 0d 20 20 41 66 74 65 72 20 |essor... After | 00000fc0 63 6f 6d 70 6c 65 74 69 6e 67 20 74 68 65 20 6e |completing the n| 00000fd0 65 77 20 72 6f 75 74 69 6e 65 20 79 6f 75 20 73 |ew routine you s| 00000fe0 68 6f 75 6c 64 20 65 6e 73 75 72 65 20 74 68 61 |hould ensure tha| 00000ff0 74 20 74 68 65 20 69 6e 64 65 78 0d 72 65 67 69 |t the index.regi| 00001000 73 74 65 72 73 20 61 6e 64 20 74 68 65 69 72 20 |sters and their | 00001010 7a 65 72 6f 20 70 61 67 65 20 63 6f 70 69 65 73 |zero page copies| 00001020 20 61 72 65 20 69 64 65 6e 74 69 63 61 6c 2e 20 | are identical. | 00001030 49 6e 20 66 69 67 75 72 65 20 37 2e 32 20 69 74 |In figure 7.2 it| 00001040 20 69 73 0d 61 73 73 75 6d 65 64 20 74 68 61 74 | is.assumed that| 00001050 20 74 68 65 20 63 6f 6e 74 65 6e 74 73 20 6f 66 | the contents of| 00001060 20 26 45 46 2c 20 26 46 30 20 61 6e 64 20 26 46 | &EF, &F0 and &F| 00001070 31 20 68 61 76 65 20 6e 6f 74 20 62 65 65 6e 20 |1 have not been | 00001080 61 6c 74 65 72 65 64 2e 20 54 68 65 0d 61 63 63 |altered. The.acc| 00001090 75 6d 75 6c 61 74 6f 72 20 77 61 73 20 70 75 73 |umulator was pus| 000010a0 68 65 64 20 6f 6e 20 74 68 65 20 73 74 61 63 6b |hed on the stack| 000010b0 20 62 79 20 74 68 65 20 69 6e 74 65 72 70 72 65 | by the interpre| 000010c0 74 65 72 20 61 6e 64 20 69 74 20 69 73 20 70 75 |ter and it is pu| 000010d0 6c 6c 65 64 0d 62 61 63 6b 20 6f 66 66 20 74 6f |lled.back off to| 000010e0 20 62 61 6c 61 6e 63 65 20 74 68 65 20 73 74 61 | balance the sta| 000010f0 63 6b 2e 20 54 68 65 20 61 63 63 75 6d 75 6c 61 |ck. The accumula| 00001100 74 6f 72 20 69 73 20 72 65 73 65 74 20 74 6f 20 |tor is reset to | 00001110 7a 65 72 6f 20 74 6f 0d 69 6e 66 6f 72 6d 20 6f |zero to.inform o| 00001120 74 68 65 72 20 72 6f 6d 73 20 74 68 61 74 20 74 |ther roms that t| 00001130 68 65 20 73 65 72 76 69 63 65 20 63 61 6c 6c 20 |he service call | 00001140 68 61 73 20 62 65 65 6e 20 72 65 63 6f 67 6e 69 |has been recogni| 00001150 73 65 64 20 61 6e 64 20 63 6f 6e 74 72 6f 6c 0d |sed and control.| 00001160 69 73 20 72 65 74 75 72 6e 65 64 20 74 6f 20 74 |is returned to t| 00001170 68 65 20 4d 4f 53 2e 20 4f 6e 20 72 65 74 75 72 |he MOS. On retur| 00001180 6e 20 74 68 65 20 4d 4f 53 20 63 6f 70 69 65 73 |n the MOS copies| 00001190 20 74 68 65 20 4f 73 77 6f 72 64 20 6e 75 6d 62 | the Osword numb| 000011a0 65 72 20 69 6e 74 6f 0d 74 68 65 20 61 63 63 75 |er into.the accu| 000011b0 6d 75 6c 61 74 6f 72 2e 0d 0d 20 20 55 6e 6c 69 |mulator... Unli| 000011c0 6b 65 20 4f 73 62 79 74 65 2c 20 4f 73 77 6f 72 |ke Osbyte, Oswor| 000011d0 64 20 64 6f 65 73 20 6e 6f 74 20 75 73 65 20 26 |d does not use &| 000011e0 46 30 20 61 6e 64 20 26 46 31 20 74 6f 20 77 72 |F0 and &F1 to wr| 000011f0 69 74 65 20 61 6e 79 20 72 65 73 75 6c 74 73 2e |ite any results.| 00001200 0d 49 66 20 79 6f 75 72 20 6e 65 77 20 72 6f 75 |.If your new rou| 00001210 74 69 6e 65 73 20 77 72 69 74 65 20 61 6e 79 20 |tines write any | 00001220 72 65 73 75 6c 74 73 20 74 68 65 73 65 20 6d 75 |results these mu| 00001230 73 74 20 62 65 20 77 72 69 74 74 65 6e 20 69 6e |st be written in| 00001240 20 74 68 65 0d 70 61 72 61 6d 65 74 65 72 20 62 | the.parameter b| 00001250 6c 6f 63 6b 2e 20 26 45 46 2c 20 26 46 30 20 61 |lock. &EF, &F0 a| 00001260 6e 64 20 26 46 31 20 73 68 6f 75 6c 64 20 62 65 |nd &F1 should be| 00001270 20 72 65 73 74 6f 72 65 64 20 62 65 66 6f 72 65 | restored before| 00001280 20 72 65 74 75 72 6e 69 6e 67 0d 66 72 6f 6d 20 | returning.from | 00001290 4f 73 77 6f 72 64 2e 0d 0d 20 20 54 68 65 20 70 |Osword... The p| 000012a0 72 6f 67 72 61 6d 20 4f 53 57 4f 52 44 20 75 73 |rogram OSWORD us| 000012b0 65 73 20 61 6e 20 69 6e 74 65 72 70 72 65 74 65 |es an interprete| 000012c0 72 20 73 69 6d 69 6c 61 72 20 74 6f 20 74 68 65 |r similar to the| 000012d0 20 6f 6e 65 20 6f 75 74 6c 69 6e 65 64 20 69 6e | one outlined in| 000012e0 0d 66 69 67 75 72 65 20 37 2e 32 20 74 6f 20 69 |.figure 7.2 to i| 000012f0 6d 70 6c 65 6d 65 6e 74 20 61 20 50 52 49 4e 54 |mplement a PRINT| 00001300 20 54 41 42 28 58 2c 59 29 20 72 6f 75 74 69 6e | TAB(X,Y) routin| 00001310 65 20 61 73 20 4f 73 77 6f 72 64 20 31 30 30 20 |e as Osword 100 | 00001320 28 26 36 34 29 2e 0d 54 68 69 73 20 72 6f 75 74 |(&64)..This rout| 00001330 69 6e 65 20 67 69 76 65 73 20 61 63 63 65 73 73 |ine gives access| 00001340 20 74 6f 20 50 52 49 4e 54 20 54 41 42 20 69 6e | to PRINT TAB in| 00001350 20 62 6f 74 68 20 42 41 53 49 43 20 61 6e 64 20 | both BASIC and | 00001360 6d 61 63 68 69 6e 65 20 63 6f 64 65 2e 0d 0d 20 |machine code... | 00001370 20 54 6f 20 75 73 65 20 74 68 65 20 6e 65 77 20 | To use the new | 00001380 4f 73 77 6f 72 64 20 79 6f 75 20 6e 65 65 64 20 |Osword you need | 00001390 74 6f 20 6c 6f 61 64 20 74 68 65 20 6f 62 6a 65 |to load the obje| 000013a0 63 74 20 63 6f 64 65 20 67 65 6e 65 72 61 74 65 |ct code generate| 000013b0 64 20 62 79 0d 74 68 65 20 70 72 6f 67 72 61 6d |d by.the program| 000013c0 20 4f 53 57 4f 52 44 20 69 6e 74 6f 20 53 57 52 | OSWORD into SWR| 000013d0 20 61 6e 64 20 70 72 65 73 73 20 74 68 65 20 42 | and press the B| 000013e0 72 65 61 6b 20 6b 65 79 2e 20 41 6e 79 20 70 72 |reak key. Any pr| 000013f0 6f 67 72 61 6d 20 77 68 69 63 68 0d 75 73 65 73 |ogram which.uses| 00001400 20 74 68 65 20 6e 65 77 20 72 6f 75 74 69 6e 65 | the new routine| 00001410 20 6d 75 73 74 20 64 65 66 69 6e 65 20 61 20 70 | must define a p| 00001420 61 72 61 6d 65 74 65 72 20 62 6c 6f 63 6b 20 74 |arameter block t| 00001430 6f 20 63 6f 6e 74 61 69 6e 20 74 68 65 20 74 77 |o contain the tw| 00001440 6f 0d 62 79 74 65 20 61 64 64 72 65 73 73 20 6f |o.byte address o| 00001450 66 20 61 20 74 65 78 74 20 73 74 72 69 6e 67 20 |f a text string | 00001460 61 6e 64 20 74 68 65 20 74 77 6f 20 62 79 74 65 |and the two byte| 00001470 73 20 66 6f 72 20 74 68 65 20 73 63 72 65 65 6e |s for the screen| 00001480 20 58 20 61 6e 64 20 59 0d 63 6f 2d 6f 72 64 69 | X and Y.co-ordi| 00001490 6e 61 74 65 73 20 6f 66 20 74 68 65 20 66 69 72 |nates of the fir| 000014a0 73 74 20 63 68 61 72 61 63 74 65 72 20 6f 66 20 |st character of | 000014b0 74 68 65 20 73 74 72 69 6e 67 2e 20 42 65 63 61 |the string. Beca| 000014c0 75 73 65 20 66 6f 75 72 20 62 79 74 65 73 20 6f |use four bytes o| 000014d0 66 0d 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 61 72 |f.information ar| 000014e0 65 20 6e 65 65 64 65 64 20 66 6f 72 20 74 68 69 |e needed for thi| 000014f0 73 20 72 6f 75 74 69 6e 65 20 61 6e 20 4f 73 62 |s routine an Osb| 00001500 79 74 65 20 63 6f 75 6c 64 20 6e 6f 74 20 62 65 |yte could not be| 00001510 20 75 73 65 64 2e 20 54 68 65 0d 70 72 6f 67 72 | used. The.progr| 00001520 6d 20 4f 53 57 44 45 4d 4f 20 73 68 6f 77 73 20 |m OSWDEMO shows | 00001530 68 6f 77 20 74 6f 20 73 65 74 20 75 70 20 74 68 |how to set up th| 00001540 65 20 70 61 72 61 6d 65 74 65 72 20 62 6c 6f 63 |e parameter bloc| 00001550 6b 20 69 6e 20 41 73 73 65 6d 62 6c 79 0d 6c 61 |k in Assembly.la| 00001560 6e 67 75 61 67 65 2e 0d 0d 0d 0d 0d 20 20 20 31 |nguage...... 1| 00001570 30 20 52 45 4d 20 20 4f 53 57 44 45 4d 4f 0d 20 |0 REM OSWDEMO. | 00001580 20 20 32 30 20 4d 4f 44 45 37 0d 20 20 20 33 30 | 20 MODE7. 30| 00001590 20 44 49 4d 20 6d 63 6f 64 65 20 26 31 30 30 0d | DIM mcode &100.| 000015a0 20 20 20 34 30 20 6f 73 77 6f 72 64 3d 26 46 46 | 40 osword=&FF| 000015b0 46 31 0d 20 20 20 35 30 20 46 4f 52 20 70 61 73 |F1. 50 FOR pas| 000015c0 73 3d 30 20 54 4f 20 32 20 53 54 45 50 20 32 0d |s=0 TO 2 STEP 2.| 000015d0 20 20 20 36 30 20 50 25 3d 6d 63 6f 64 65 0d 20 | 60 P%=mcode. | 000015e0 20 20 37 30 20 5b 20 20 20 20 20 20 20 4f 50 54 | 70 [ OPT| 000015f0 20 70 61 73 73 0d 20 20 20 38 30 20 20 20 20 20 | pass. 80 | 00001600 20 20 20 20 4c 44 41 20 23 31 30 30 0d 20 20 20 | LDA #100. | 00001610 39 30 20 20 20 20 20 20 20 20 20 4c 44 58 20 23 |90 LDX #| 00001620 70 62 6c 6f 63 6b 20 4d 4f 44 20 32 35 36 0d 20 |pblock MOD 256. | 00001630 20 31 30 30 20 20 20 20 20 20 20 20 20 4c 44 59 | 100 LDY| 00001640 20 23 70 62 6c 6f 63 6b 20 44 49 56 20 32 35 36 | #pblock DIV 256| 00001650 0d 20 20 31 31 30 20 20 20 20 20 20 20 20 20 4a |. 110 J| 00001660 53 52 20 6f 73 77 6f 72 64 0d 20 20 31 32 30 20 |SR osword. 120 | 00001670 20 20 20 20 20 20 20 20 4c 44 41 20 23 31 30 30 | LDA #100| 00001680 0d 20 20 31 33 30 20 20 20 20 20 20 20 20 20 4c |. 130 L| 00001690 44 58 20 23 70 62 6c 6f 63 6b 32 20 4d 4f 44 20 |DX #pblock2 MOD | 000016a0 32 35 36 0d 20 20 31 34 30 20 20 20 20 20 20 20 |256. 140 | 000016b0 20 20 4c 44 59 20 23 70 62 6c 6f 63 6b 32 20 44 | LDY #pblock2 D| 000016c0 49 56 20 32 35 36 0d 20 20 31 35 30 20 20 20 20 |IV 256. 150 | 000016d0 20 20 20 20 20 4a 53 52 20 6f 73 77 6f 72 64 0d | JSR osword.| 000016e0 20 20 31 36 30 20 20 20 20 20 20 20 20 20 52 54 | 160 RT| 000016f0 53 0d 20 20 31 37 30 20 2e 70 62 6c 6f 63 6b 0d |S. 170 .pblock.| 00001700 20 20 31 38 30 20 20 20 20 20 20 20 20 20 4f 50 | 180 OP| 00001710 54 20 46 4e 65 71 75 77 28 74 65 78 74 29 0d 20 |T FNequw(text). | 00001720 20 31 39 30 20 20 20 20 20 20 20 20 20 4f 50 54 | 190 OPT| 00001730 20 46 4e 65 71 75 62 28 35 29 0d 20 20 32 30 30 | FNequb(5). 200| 00001740 20 20 20 20 20 20 20 20 20 4f 50 54 20 46 4e 65 | OPT FNe| 00001750 71 75 62 28 31 31 29 0d 20 20 32 31 30 20 2e 70 |qub(11). 210 .p| 00001760 62 6c 6f 63 6b 32 0d 20 20 32 32 30 20 20 20 20 |block2. 220 | 00001770 20 20 20 20 20 4f 50 54 20 46 4e 65 71 75 77 28 | OPT FNequw(| 00001780 74 65 78 74 29 0d 20 20 32 33 30 20 20 20 20 20 |text). 230 | 00001790 20 20 20 20 4f 50 54 20 46 4e 65 71 75 62 28 35 | OPT FNequb(5| 000017a0 29 0d 20 20 32 34 30 20 20 20 20 20 20 20 20 20 |). 240 | 000017b0 4f 50 54 20 46 4e 65 71 75 62 28 31 32 29 0d 20 |OPT FNequb(12). | 000017c0 20 32 35 30 20 2e 74 65 78 74 0d 20 20 32 36 30 | 250 .text. 260| 000017d0 20 20 20 20 20 20 20 20 20 4f 50 54 20 46 4e 65 | OPT FNe| 000017e0 71 75 62 28 31 34 31 29 0d 20 20 32 37 30 20 20 |qub(141). 270 | 000017f0 20 20 20 20 20 20 20 4f 50 54 20 46 4e 65 71 75 | OPT FNequ| 00001800 62 28 31 33 31 29 0d 20 20 32 38 30 20 20 20 20 |b(131). 280 | 00001810 20 20 20 20 20 4f 50 54 20 46 4e 65 71 75 73 28 | OPT FNequs(| 00001820 22 44 65 6d 6f 6e 73 74 72 61 74 69 6f 6e 20 6f |"Demonstration o| 00001830 66 20 6e 65 77 20 4f 73 77 6f 72 64 22 29 0d 20 |f new Osword"). | 00001840 20 32 39 30 20 20 20 20 20 20 20 20 20 4f 50 54 | 290 OPT| 00001850 20 46 4e 65 71 75 62 28 31 33 29 0d 20 20 33 30 | FNequb(13). 30| 00001860 30 20 5d 0d 20 20 33 31 30 20 4e 45 58 54 0d 20 |0 ]. 310 NEXT. | 00001870 20 33 32 30 20 43 41 4c 4c 20 6d 63 6f 64 65 0d | 320 CALL mcode.| 00001880 20 20 33 33 30 20 45 4e 44 0d 20 20 33 34 30 20 | 330 END. 340 | 00001890 44 45 46 46 4e 65 71 75 62 28 62 79 74 65 29 0d |DEFFNequb(byte).| 000018a0 20 20 33 35 30 20 3f 50 25 3d 62 79 74 65 0d 20 | 350 ?P%=byte. | 000018b0 20 33 36 30 20 50 25 3d 50 25 2b 31 0d 20 20 33 | 360 P%=P%+1. 3| 000018c0 37 30 20 3d 70 61 73 73 0d 20 20 33 38 30 20 44 |70 =pass. 380 D| 000018d0 45 46 46 4e 65 71 75 77 28 77 6f 72 64 29 0d 20 |EFFNequw(word). | 000018e0 20 33 39 30 20 3f 50 25 3d 77 6f 72 64 20 4d 4f | 390 ?P%=word MO| 000018f0 44 20 32 35 36 0d 20 20 34 30 30 20 50 25 3f 31 |D 256. 400 P%?1| 00001900 3d 77 6f 72 64 20 44 49 56 20 32 35 36 0d 20 20 |=word DIV 256. | 00001910 34 31 30 20 50 25 3d 50 25 2b 32 0d 20 20 34 32 |410 P%=P%+2. 42| 00001920 30 20 3d 70 61 73 73 0d 20 20 34 33 30 20 44 45 |0 =pass. 430 DE| 00001930 46 46 4e 65 71 75 64 28 64 6f 75 62 6c 65 29 0d |FFNequd(double).| 00001940 20 20 34 34 30 20 21 50 25 3d 64 6f 75 62 6c 65 | 440 !P%=double| 00001950 0d 20 20 34 35 30 20 50 25 3d 50 25 2b 34 0d 20 |. 450 P%=P%+4. | 00001960 20 34 36 30 20 3d 70 61 73 73 0d 20 20 34 37 30 | 460 =pass. 470| 00001970 20 44 45 46 46 4e 65 71 75 73 28 73 74 72 69 6e | DEFFNequs(strin| 00001980 67 24 29 0d 20 20 34 38 30 20 24 50 25 3d 73 74 |g$). 480 $P%=st| 00001990 72 69 6e 67 24 0d 20 20 34 39 30 20 50 25 3d 50 |ring$. 490 P%=P| 000019a0 25 2b 4c 45 4e 28 73 74 72 69 6e 67 24 29 0d 20 |%+LEN(string$). | 000019b0 20 35 30 30 20 3d 70 61 73 73 0d 0d 0d 0d 0d 0d | 500 =pass......| 000019c0 20 20 54 68 65 20 6e 65 77 20 4f 73 77 6f 72 64 | The new Osword| 000019d0 20 31 30 30 20 63 61 6e 20 62 65 20 75 73 65 64 | 100 can be used| 000019e0 20 69 6e 20 61 6e 79 20 74 65 78 74 20 6d 6f 64 | in any text mod| 000019f0 65 20 62 75 74 20 4f 53 57 44 45 4d 4f 20 75 73 |e but OSWDEMO us| 00001a00 65 73 20 69 74 20 74 6f 0d 70 72 69 6e 74 20 61 |es it to.print a| 00001a10 20 73 74 72 69 6e 67 20 69 6e 20 64 6f 75 62 6c | string in doubl| 00001a20 65 20 68 65 69 67 68 74 2c 20 79 65 6c 6c 6f 77 |e height, yellow| 00001a30 2c 20 4d 6f 64 65 20 37 20 63 68 61 72 61 63 74 |, Mode 7 charact| 00001a40 65 72 73 2e 20 4f 53 57 44 45 4d 4f 20 6d 75 73 |ers. OSWDEMO mus| 00001a50 74 0d 72 75 6e 20 69 6e 20 74 68 65 20 49 2f 4f |t.run in the I/O| 00001a60 20 70 72 6f 63 65 73 73 6f 72 2e 0d 0d 20 20 54 | processor... T| 00001a70 68 65 20 66 69 72 73 74 20 74 77 6f 20 62 79 74 |he first two byt| 00001a80 65 73 20 6f 66 20 74 68 65 20 70 61 72 61 6d 65 |es of the parame| 00001a90 74 65 72 20 62 6c 6f 63 6b 73 20 73 74 6f 72 65 |ter blocks store| 00001aa0 20 74 68 65 20 61 64 64 72 65 73 73 20 6f 66 20 | the address of | 00001ab0 74 68 65 0d 74 65 78 74 20 62 6c 6f 63 6b 20 28 |the.text block (| 00001ac0 6c 69 6e 65 73 20 31 38 30 20 61 6e 64 20 32 32 |lines 180 and 22| 00001ad0 30 29 2e 20 54 68 65 20 74 68 69 72 64 20 62 79 |0). The third by| 00001ae0 74 65 20 6f 66 20 74 68 65 20 70 61 72 61 6d 65 |te of the parame| 00001af0 74 65 72 20 62 6c 6f 63 6b 73 0d 73 74 6f 72 65 |ter blocks.store| 00001b00 20 74 68 65 20 73 63 72 65 65 6e 20 58 20 63 6f | the screen X co| 00001b10 2d 6f 72 64 69 6e 61 74 65 20 6f 66 20 74 68 65 |-ordinate of the| 00001b20 20 66 69 72 73 74 20 62 79 74 65 20 6f 66 20 74 | first byte of t| 00001b30 68 65 20 73 74 72 69 6e 67 20 28 6c 69 6e 65 73 |he string (lines| 00001b40 0d 31 39 30 20 61 6e 64 20 32 33 30 29 20 61 6e |.190 and 230) an| 00001b50 64 20 74 68 65 20 66 6f 75 72 74 68 20 62 79 74 |d the fourth byt| 00001b60 65 20 73 74 6f 72 65 73 20 74 68 65 20 73 63 72 |e stores the scr| 00001b70 65 65 6e 20 59 20 63 6f 2d 6f 72 64 69 6e 61 74 |een Y co-ordinat| 00001b80 65 20 6f 66 20 74 68 65 0d 66 69 72 73 74 20 62 |e of the.first b| 00001b90 79 74 65 20 6f 66 20 74 68 65 20 73 74 72 69 6e |yte of the strin| 00001ba0 67 20 28 6c 69 6e 65 73 20 32 30 30 20 61 6e 64 |g (lines 200 and| 00001bb0 20 32 34 30 29 2e 0d 0d 20 20 42 65 66 6f 72 65 | 240)... Before| 00001bc0 20 63 61 6c 6c 69 6e 67 20 74 68 65 20 6e 65 77 | calling the new| 00001bd0 20 4f 73 77 6f 72 64 20 28 6c 69 6e 65 73 20 31 | Osword (lines 1| 00001be0 31 30 20 61 6e 64 20 31 35 30 29 20 74 68 65 20 |10 and 150) the | 00001bf0 61 63 63 75 6d 75 6c 61 74 6f 72 20 69 73 0d 6c |accumulator is.l| 00001c00 6f 61 64 65 64 20 77 69 74 68 20 74 68 65 20 6e |oaded with the n| 00001c10 65 77 20 4f 73 77 6f 72 64 20 6e 75 6d 62 65 72 |ew Osword number| 00001c20 20 28 6c 69 6e 65 73 20 38 30 20 61 6e 64 20 31 | (lines 80 and 1| 00001c30 32 30 29 2c 20 74 68 65 20 58 20 72 65 67 69 73 |20), the X regis| 00001c40 74 65 72 0d 77 69 74 68 20 74 68 65 20 6c 6f 77 |ter.with the low| 00001c50 20 62 79 74 65 20 6f 66 20 74 68 65 20 70 61 72 | byte of the par| 00001c60 61 6d 65 74 65 72 20 62 6c 6f 63 6b 20 61 64 64 |ameter block add| 00001c70 72 65 73 73 20 28 6c 69 6e 65 73 20 39 30 20 61 |ress (lines 90 a| 00001c80 6e 64 20 31 33 30 29 2c 20 61 6e 64 0d 74 68 65 |nd 130), and.the| 00001c90 20 59 20 72 65 67 69 73 74 65 72 20 77 69 74 68 | Y register with| 00001ca0 20 74 68 65 20 68 69 67 68 20 62 79 74 65 20 6f | the high byte o| 00001cb0 66 20 74 68 65 20 70 61 72 61 6d 65 74 65 72 20 |f the parameter | 00001cc0 62 6c 6f 63 6b 20 61 64 64 72 65 73 73 20 28 6c |block address (l| 00001cd0 69 6e 65 73 0d 31 30 30 20 61 6e 64 20 31 34 30 |ines.100 and 140| 00001ce0 29 2e 20 4f 73 77 6f 72 64 20 31 30 30 20 70 72 |). Osword 100 pr| 00001cf0 69 6e 74 73 20 74 68 65 20 73 74 72 69 6e 67 20 |ints the string | 00001d00 6f 6e 20 74 68 65 20 73 63 72 65 65 6e 20 61 6e |on the screen an| 00001d10 64 20 72 65 74 75 72 6e 73 0d 77 69 74 68 20 41 |d returns.with A| 00001d20 2c 20 58 20 61 6e 64 20 59 20 72 65 67 69 73 74 |, X and Y regist| 00001d30 65 72 73 20 70 72 65 73 65 72 76 65 64 2e 0d 0d |ers preserved...| 00001d40 20 20 54 68 65 20 70 72 6f 67 72 61 6d 20 4f 53 | The program OS| 00001d50 57 4f 52 44 20 75 73 65 73 20 61 6e 20 4f 73 77 |WORD uses an Osw| 00001d60 6f 72 64 20 69 6e 74 65 72 70 72 65 74 65 72 20 |ord interpreter | 00001d70 28 6c 69 6e 65 73 20 32 37 30 2d 33 37 30 29 20 |(lines 270-370) | 00001d80 73 69 6d 69 6c 61 72 0d 74 6f 20 74 68 65 20 6f |similar.to the o| 00001d90 6e 65 20 6f 75 74 6c 69 6e 65 64 20 69 6e 20 66 |ne outlined in f| 00001da0 69 67 75 72 65 20 37 2e 32 2e 20 41 66 74 65 72 |igure 7.2. After| 00001db0 20 72 65 63 6f 67 6e 69 73 69 6e 67 20 74 68 65 | recognising the| 00001dc0 20 6e 65 77 20 4f 73 77 6f 72 64 0d 28 6c 69 6e | new Osword.(lin| 00001dd0 65 73 20 33 35 30 2d 33 37 30 29 20 74 68 65 20 |es 350-370) the | 00001de0 6e 65 77 20 72 6f 75 74 69 6e 65 20 70 72 65 73 |new routine pres| 00001df0 65 72 76 65 73 20 74 68 65 20 74 77 6f 20 7a 65 |erves the two ze| 00001e00 72 6f 20 70 61 67 65 20 62 79 74 65 73 20 69 74 |ro page bytes it| 00001e10 0d 75 73 65 73 20 74 6f 20 70 72 69 6e 74 20 74 |.uses to print t| 00001e20 68 65 20 73 74 72 69 6e 67 20 62 79 20 70 75 73 |he string by pus| 00001e30 68 69 6e 67 20 74 68 65 6d 20 6f 6e 20 74 68 65 |hing them on the| 00001e40 20 73 74 61 63 6b 20 28 6c 69 6e 65 73 20 33 38 | stack (lines 38| 00001e50 30 2d 34 31 30 29 2e 0d 0d 20 20 54 68 65 20 61 |0-410)... The a| 00001e60 64 64 72 65 73 73 20 6f 66 20 74 68 65 20 70 61 |ddress of the pa| 00001e70 72 61 6d 65 74 65 72 20 62 6c 6f 63 6b 20 69 73 |rameter block is| 00001e80 20 73 74 6f 72 65 64 20 69 6e 20 26 46 30 20 28 | stored in &F0 (| 00001e90 6c 6f 77 20 62 79 74 65 29 20 61 6e 64 20 26 46 |low byte) and &F| 00001ea0 31 0d 28 68 69 67 68 20 62 79 74 65 29 2e 20 54 |1.(high byte). T| 00001eb0 68 65 73 65 20 74 77 6f 20 7a 65 72 6f 20 70 61 |hese two zero pa| 00001ec0 67 65 20 6d 65 6d 6f 72 79 20 6c 6f 63 61 74 69 |ge memory locati| 00001ed0 6f 6e 73 20 61 72 65 20 75 73 65 64 20 77 69 74 |ons are used wit| 00001ee0 68 0d 70 6f 73 74 2d 69 6e 64 65 78 65 64 20 69 |h.post-indexed i| 00001ef0 6e 64 69 72 65 63 74 20 61 64 64 72 65 73 73 69 |ndirect addressi| 00001f00 6e 67 20 74 6f 20 72 65 61 64 20 74 68 65 20 63 |ng to read the c| 00001f10 6f 6e 74 65 6e 74 73 20 6f 66 20 74 68 65 20 70 |ontents of the p| 00001f20 61 72 61 6d 65 74 65 72 0d 62 6c 6f 63 6b 2e 20 |arameter.block. | 00001f30 54 68 65 20 59 20 72 65 67 69 73 74 65 72 20 69 |The Y register i| 00001f40 73 20 72 65 73 65 74 20 74 6f 20 7a 65 72 6f 20 |s reset to zero | 00001f50 28 6c 69 6e 65 20 34 32 30 29 20 61 6e 64 20 74 |(line 420) and t| 00001f60 68 65 20 61 64 64 72 65 73 73 20 6f 66 20 74 68 |he address of th| 00001f70 65 0d 74 65 78 74 20 62 6c 6f 63 6b 20 69 73 20 |e.text block is | 00001f80 72 65 61 64 20 66 72 6f 6d 20 74 68 65 20 70 61 |read from the pa| 00001f90 72 61 6d 65 74 65 72 20 62 6c 6f 63 6b 20 61 6e |rameter block an| 00001fa0 64 20 73 74 6f 72 65 64 20 69 6e 20 7a 65 72 6f |d stored in zero| 00001fb0 20 70 61 67 65 0d 72 65 61 64 79 20 74 6f 20 70 | page.ready to p| 00001fc0 72 69 6e 74 20 74 68 65 20 74 65 78 74 20 73 74 |rint the text st| 00001fd0 72 69 6e 67 20 28 6c 69 6e 65 73 20 34 33 30 2d |ring (lines 430-| 00001fe0 34 37 30 29 2e 20 54 68 65 20 73 63 72 65 65 6e |470). The screen| 00001ff0 20 58 20 61 6e 64 20 59 0d 63 6f 2d 6f 72 64 69 | X and Y.co-ordi| 00002000 6e 61 74 65 73 20 61 72 65 20 72 65 61 64 20 66 |nates are read f| 00002010 72 6f 6d 20 74 68 65 20 70 61 72 61 6d 65 74 65 |rom the paramete| 00002020 72 20 62 6c 6f 63 6b 20 61 6e 64 20 74 68 65 20 |r block and the | 00002030 74 65 78 74 20 63 75 72 73 6f 72 20 69 73 0d 70 |text cursor is.p| 00002040 6f 73 69 74 69 6f 6e 65 64 20 75 73 69 6e 67 20 |ositioned using | 00002050 74 68 65 20 6d 61 63 68 69 6e 65 20 63 6f 64 65 |the machine code| 00002060 20 65 71 75 69 76 61 6c 65 6e 74 20 6f 66 20 56 | equivalent of V| 00002070 44 55 20 33 31 2c 78 2c 79 20 28 6c 69 6e 65 73 |DU 31,x,y (lines| 00002080 0d 34 38 30 2d 35 35 30 29 2e 20 54 68 65 20 74 |.480-550). The t| 00002090 65 78 74 20 73 74 72 69 6e 67 20 69 73 20 74 68 |ext string is th| 000020a0 65 6e 20 70 72 69 6e 74 65 64 20 6f 6e 20 74 68 |en printed on th| 000020b0 65 20 73 63 72 65 65 6e 20 28 6c 69 6e 65 73 20 |e screen (lines | 000020c0 35 36 30 2d 36 34 30 29 2e 0d 0d 20 20 54 68 65 |560-640)... The| 000020d0 20 7a 65 72 6f 20 70 61 67 65 20 6c 6f 63 61 74 | zero page locat| 000020e0 69 6f 6e 73 20 75 73 65 64 20 62 79 20 74 68 65 |ions used by the| 000020f0 20 70 72 69 6e 74 20 72 6f 75 74 69 6e 65 20 61 | print routine a| 00002100 72 65 20 70 75 6c 6c 65 64 20 6f 66 66 20 74 68 |re pulled off th| 00002110 65 0d 73 74 61 63 6b 20 61 6e 64 20 72 65 73 74 |e.stack and rest| 00002120 6f 72 65 64 20 28 6c 69 6e 65 73 20 36 35 30 2d |ored (lines 650-| 00002130 36 38 30 29 2e 20 54 68 65 20 69 6e 64 65 78 20 |680). The index | 00002140 72 65 67 69 73 74 65 72 73 20 61 72 65 20 72 65 |registers are re| 00002150 73 74 6f 72 65 64 0d 28 6c 69 6e 65 73 20 36 39 |stored.(lines 69| 00002160 30 2d 37 30 30 29 2c 20 74 68 65 20 61 63 63 75 |0-700), the accu| 00002170 6d 75 6c 61 74 6f 72 20 69 73 20 72 65 73 65 74 |mulator is reset| 00002180 20 74 6f 20 7a 65 72 6f 20 74 6f 20 69 6e 66 6f | to zero to info| 00002190 72 6d 20 74 68 65 20 6f 74 68 65 72 0d 72 6f 6d |rm the other.rom| 000021a0 73 20 74 68 61 74 20 74 68 65 20 73 65 72 76 69 |s that the servi| 000021b0 63 65 20 63 61 6c 6c 20 68 61 73 20 62 65 65 6e |ce call has been| 000021c0 20 72 65 63 6f 67 6e 69 73 65 64 20 28 6c 69 6e | recognised (lin| 000021d0 65 73 20 37 31 30 2d 37 32 30 29 20 61 6e 64 0d |es 710-720) and.| 000021e0 63 6f 6e 74 6f 6c 20 69 73 20 72 65 74 75 72 6e |contol is return| 000021f0 65 64 20 74 6f 20 74 68 65 20 4d 4f 53 20 28 6c |ed to the MOS (l| 00002200 69 6e 65 20 37 33 30 29 2e 0d 0d 0d 0d 0d 0d 20 |ine 730)....... | 00002210 20 20 31 30 20 52 45 4d 3a 20 4f 53 57 4f 52 44 | 10 REM: OSWORD| 00002220 0d 20 20 20 32 30 20 4d 4f 44 45 37 0d 20 20 20 |. 20 MODE7. | 00002230 33 30 20 48 49 4d 45 4d 3d 26 33 43 30 30 0d 20 |30 HIMEM=&3C00. | 00002240 20 20 34 30 20 44 49 4d 20 73 61 76 65 20 35 30 | 40 DIM save 50| 00002250 0d 20 20 20 35 30 20 64 69 66 66 3d 26 38 30 30 |. 50 diff=&800| 00002260 30 2d 48 49 4d 45 4d 0d 20 20 20 36 30 20 61 64 |0-HIMEM. 60 ad| 00002270 64 72 65 73 73 3d 26 37 30 0d 20 20 20 37 30 20 |dress=&70. 70 | 00002280 61 63 63 75 6d 75 6c 61 74 6f 72 3d 26 45 46 0d |accumulator=&EF.| 00002290 20 20 20 38 30 20 78 72 65 67 69 73 74 65 72 3d | 80 xregister=| 000022a0 26 46 30 0d 20 20 20 39 30 20 79 72 65 67 69 73 |&F0. 90 yregis| 000022b0 74 65 72 3d 26 46 31 0d 20 20 31 30 30 20 6f 73 |ter=&F1. 100 os| 000022c0 61 73 63 69 3d 26 46 46 45 33 0d 20 20 31 31 30 |asci=&FFE3. 110| 000022d0 20 6f 73 63 6c 69 3d 26 46 46 46 37 0d 20 20 31 | oscli=&FFF7. 1| 000022e0 32 30 20 46 4f 52 20 70 61 73 73 20 3d 20 30 20 |20 FOR pass = 0 | 000022f0 54 4f 20 32 20 53 54 45 50 20 32 0d 20 20 31 33 |TO 2 STEP 2. 13| 00002300 30 20 50 25 3d 48 49 4d 45 4d 0d 20 20 31 34 30 |0 P%=HIMEM. 140| 00002310 20 5b 20 20 20 20 20 20 20 4f 50 54 20 70 61 73 | [ OPT pas| 00002320 73 0d 20 20 31 35 30 20 20 20 20 20 20 20 20 20 |s. 150 | 00002330 42 52 4b 0d 20 20 31 36 30 20 20 20 20 20 20 20 |BRK. 160 | 00002340 20 20 42 52 4b 0d 20 20 31 37 30 20 20 20 20 20 | BRK. 170 | 00002350 20 20 20 20 42 52 4b 0d 20 20 31 38 30 20 20 20 | BRK. 180 | 00002360 20 20 20 20 20 20 4a 4d 50 20 73 65 72 76 69 63 | JMP servic| 00002370 65 2b 64 69 66 66 0d 20 20 31 39 30 20 20 20 20 |e+diff. 190 | 00002380 20 20 20 20 20 4f 50 54 20 46 4e 65 71 75 62 28 | OPT FNequb(| 00002390 26 38 32 29 0d 20 20 32 30 30 20 20 20 20 20 20 |&82). 200 | 000023a0 20 20 20 4f 50 54 20 46 4e 65 71 75 62 28 28 63 | OPT FNequb((c| 000023b0 6f 70 79 72 69 67 68 74 2b 64 69 66 66 29 20 4d |opyright+diff) M| 000023c0 4f 44 20 32 35 36 29 0d 20 20 32 31 30 20 20 20 |OD 256). 210 | 000023d0 20 20 20 20 20 20 42 52 4b 0d 20 20 32 32 30 20 | BRK. 220 | 000023e0 20 20 20 20 20 20 20 20 4f 50 54 20 46 4e 65 71 | OPT FNeq| 000023f0 75 73 28 22 4f 53 57 4f 52 44 22 29 0d 20 20 32 |us("OSWORD"). 2| 00002400 33 30 20 2e 63 6f 70 79 72 69 67 68 74 0d 20 20 |30 .copyright. | 00002410 32 34 30 20 20 20 20 20 20 20 20 20 42 52 4b 0d |240 BRK.| 00002420 20 20 32 35 30 20 20 20 20 20 20 20 20 20 4f 50 | 250 OP| 00002430 54 20 46 4e 65 71 75 73 28 22 28 43 29 20 47 6f |T FNequs("(C) Go| 00002440 72 64 6f 6e 20 48 6f 72 73 69 6e 67 74 6f 6e 20 |rdon Horsington | 00002450 31 39 38 37 22 29 0d 20 20 32 36 30 20 20 20 20 |1987"). 260 | 00002460 20 20 20 20 20 42 52 4b 0d 20 20 32 37 30 20 2e | BRK. 270 .| 00002470 73 65 72 76 69 63 65 0d 20 20 32 38 30 20 20 20 |service. 280 | 00002480 20 20 20 20 20 20 50 48 41 0d 20 20 32 39 30 20 | PHA. 290 | 00002490 20 20 20 20 20 20 20 20 43 4d 50 20 23 38 0d 20 | CMP #8. | 000024a0 20 33 30 30 20 20 20 20 20 20 20 20 20 42 45 51 | 300 BEQ| 000024b0 20 6e 65 77 6f 73 77 6f 72 64 0d 20 20 33 31 30 | newosword. 310| 000024c0 20 2e 65 78 69 74 0d 20 20 33 32 30 20 20 20 20 | .exit. 320 | 000024d0 20 20 20 20 20 50 4c 41 0d 20 20 33 33 30 20 20 | PLA. 330 | 000024e0 20 20 20 20 20 20 20 52 54 53 0d 20 20 33 34 30 | RTS. 340| 000024f0 20 2e 6e 65 77 6f 73 77 6f 72 64 0d 20 20 33 35 | .newosword. 35| 00002500 30 20 20 20 20 20 20 20 20 20 4c 44 41 20 61 63 |0 LDA ac| 00002510 63 75 6d 75 6c 61 74 6f 72 0d 20 20 33 36 30 20 |cumulator. 360 | 00002520 20 20 20 20 20 20 20 20 43 4d 50 20 23 31 30 30 | CMP #100| 00002530 0d 20 20 33 37 30 20 20 20 20 20 20 20 20 20 42 |. 370 B| 00002540 4e 45 20 65 78 69 74 0d 20 20 33 38 30 20 20 20 |NE exit. 380 | 00002550 20 20 20 20 20 20 4c 44 41 20 61 64 64 72 65 73 | LDA addres| 00002560 73 0d 20 20 33 39 30 20 20 20 20 20 20 20 20 20 |s. 390 | 00002570 50 48 41 0d 20 20 34 30 30 20 20 20 20 20 20 20 |PHA. 400 | 00002580 20 20 4c 44 41 20 61 64 64 72 65 73 73 2b 31 0d | LDA address+1.| 00002590 20 20 34 31 30 20 20 20 20 20 20 20 20 20 50 48 | 410 PH| 000025a0 41 0d 20 20 34 32 30 20 20 20 20 20 20 20 20 20 |A. 420 | 000025b0 4c 44 59 20 23 30 0d 20 20 34 33 30 20 20 20 20 |LDY #0. 430 | 000025c0 20 20 20 20 20 4c 44 41 20 28 78 72 65 67 69 73 | LDA (xregis| 000025d0 74 65 72 29 2c 59 0d 20 20 34 34 30 20 20 20 20 |ter),Y. 440 | 000025e0 20 20 20 20 20 53 54 41 20 61 64 64 72 65 73 73 | STA address| 000025f0 0d 20 20 34 35 30 20 20 20 20 20 20 20 20 20 49 |. 450 I| 00002600 4e 59 0d 20 20 34 36 30 20 20 20 20 20 20 20 20 |NY. 460 | 00002610 20 4c 44 41 20 28 78 72 65 67 69 73 74 65 72 29 | LDA (xregister)| 00002620 2c 59 0d 20 20 34 37 30 20 20 20 20 20 20 20 20 |,Y. 470 | 00002630 20 53 54 41 20 61 64 64 72 65 73 73 2b 31 0d 20 | STA address+1. | 00002640 20 34 38 30 20 20 20 20 20 20 20 20 20 4c 44 41 | 480 LDA| 00002650 20 23 33 31 0d 20 20 34 39 30 20 20 20 20 20 20 | #31. 490 | 00002660 20 20 20 4a 53 52 20 6f 73 61 73 63 69 0d 20 20 | JSR osasci. | 00002670 35 30 30 20 20 20 20 20 20 20 20 20 49 4e 59 0d |500 INY.| 00002680 20 20 35 31 30 20 20 20 20 20 20 20 20 20 4c 44 | 510 LD| 00002690 41 20 28 78 72 65 67 69 73 74 65 72 29 2c 59 0d |A (xregister),Y.| 000026a0 20 20 35 32 30 20 20 20 20 20 20 20 20 20 4a 53 | 520 JS| 000026b0 52 20 6f 73 61 73 63 69 0d 20 20 35 33 30 20 20 |R osasci. 530 | 000026c0 20 20 20 20 20 20 20 49 4e 59 0d 20 20 35 34 30 | INY. 540| 000026d0 20 20 20 20 20 20 20 20 20 4c 44 41 20 28 78 72 | LDA (xr| 000026e0 65 67 69 73 74 65 72 29 2c 59 0d 20 20 35 35 30 |egister),Y. 550| 000026f0 20 20 20 20 20 20 20 20 20 4a 53 52 20 6f 73 61 | JSR osa| 00002700 73 63 69 0d 20 20 35 36 30 20 20 20 20 20 20 20 |sci. 560 | 00002710 20 20 4c 44 59 20 23 26 46 46 0d 20 20 35 37 30 | LDY #&FF. 570| 00002720 20 2e 70 72 69 6e 74 6c 6f 6f 70 0d 20 20 35 38 | .printloop. 58| 00002730 30 20 20 20 20 20 20 20 20 20 49 4e 59 0d 20 20 |0 INY. | 00002740 35 39 30 20 20 20 20 20 20 20 20 20 4c 44 41 20 |590 LDA | 00002750 28 61 64 64 72 65 73 73 29 2c 59 0d 20 20 36 30 |(address),Y. 60| 00002760 30 20 20 20 20 20 20 20 20 20 42 45 51 20 66 69 |0 BEQ fi| 00002770 6e 69 73 68 0d 20 20 36 31 30 20 20 20 20 20 20 |nish. 610 | 00002780 20 20 20 4a 53 52 20 6f 73 61 73 63 69 0d 20 20 | JSR osasci. | 00002790 36 32 30 20 20 20 20 20 20 20 20 20 43 4d 50 20 |620 CMP | 000027a0 23 31 33 0d 20 20 36 33 30 20 20 20 20 20 20 20 |#13. 630 | 000027b0 20 20 42 4e 45 20 70 72 69 6e 74 6c 6f 6f 70 0d | BNE printloop.| 000027c0 20 20 36 34 30 20 2e 66 69 6e 69 73 68 0d 20 20 | 640 .finish. | 000027d0 36 35 30 20 20 20 20 20 20 20 20 20 50 4c 41 0d |650 PLA.| 000027e0 20 20 36 36 30 20 20 20 20 20 20 20 20 20 53 54 | 660 ST| 000027f0 41 20 61 64 64 72 65 73 73 2b 31 0d 20 20 36 37 |A address+1. 67| 00002800 30 20 20 20 20 20 20 20 20 20 50 4c 41 0d 20 20 |0 PLA. | 00002810 36 38 30 20 20 20 20 20 20 20 20 20 53 54 41 20 |680 STA | 00002820 61 64 64 72 65 73 73 0d 20 20 36 39 30 20 20 20 |address. 690 | 00002830 20 20 20 20 20 20 4c 44 58 20 78 72 65 67 69 73 | LDX xregis| 00002840 74 65 72 0d 20 20 37 30 30 20 20 20 20 20 20 20 |ter. 700 | 00002850 20 20 4c 44 59 20 79 72 65 67 69 73 74 65 72 0d | LDY yregister.| 00002860 20 20 37 31 30 20 20 20 20 20 20 20 20 20 50 4c | 710 PL| 00002870 41 0d 20 20 37 32 30 20 20 20 20 20 20 20 20 20 |A. 720 | 00002880 4c 44 41 20 23 30 0d 20 20 37 33 30 20 20 20 20 |LDA #0. 730 | 00002890 20 20 20 20 20 52 54 53 0d 20 20 37 34 30 20 2e | RTS. 740 .| 000028a0 6c 61 73 74 62 79 74 65 0d 20 20 37 35 30 20 5d |lastbyte. 750 ]| 000028b0 0d 20 20 37 36 30 20 4e 45 58 54 0d 20 20 37 37 |. 760 NEXT. 77| 000028c0 30 20 49 4e 50 55 54 27 22 53 61 76 65 20 66 69 |0 INPUT'"Save fi| 000028d0 6c 65 6e 61 6d 65 20 3d 20 22 66 69 6c 65 6e 61 |lename = "filena| 000028e0 6d 65 24 0d 20 20 37 38 30 20 49 46 20 66 69 6c |me$. 780 IF fil| 000028f0 65 6e 61 6d 65 24 3d 22 22 20 45 4e 44 0d 20 20 |ename$="" END. | 00002900 37 39 30 20 24 73 61 76 65 3d 22 53 41 56 45 20 |790 $save="SAVE | 00002910 22 2b 66 69 6c 65 6e 61 6d 65 24 2b 22 20 22 2b |"+filename$+" "+| 00002920 53 54 52 24 7e 28 48 49 4d 45 4d 29 2b 22 20 22 |STR$~(HIMEM)+" "| 00002930 2b 53 54 52 24 7e 28 6c 61 73 0d 20 20 20 20 20 |+STR$~(las. | 00002940 20 74 62 79 74 65 29 2b 22 20 46 46 46 46 38 30 | tbyte)+" FFFF80| 00002950 30 30 20 46 46 46 46 38 30 30 30 22 0d 20 20 38 |00 FFFF8000". 8| 00002960 30 30 20 58 25 3d 73 61 76 65 20 4d 4f 44 20 32 |00 X%=save MOD 2| 00002970 35 36 0d 20 20 38 31 30 20 59 25 3d 73 61 76 65 |56. 810 Y%=save| 00002980 20 44 49 56 20 32 35 36 0d 20 20 38 32 30 20 2a | DIV 256. 820 *| 00002990 4f 50 54 31 2c 32 0d 20 20 38 33 30 20 43 41 4c |OPT1,2. 830 CAL| 000029a0 4c 20 6f 73 63 6c 69 0d 20 20 38 34 30 20 2a 4f |L oscli. 840 *O| 000029b0 50 54 31 2c 30 0d 20 20 38 35 30 20 45 4e 44 0d |PT1,0. 850 END.| 000029c0 20 20 38 36 30 20 44 45 46 46 4e 65 71 75 62 28 | 860 DEFFNequb(| 000029d0 62 79 74 65 29 0d 20 20 38 37 30 20 3f 50 25 3d |byte). 870 ?P%=| 000029e0 62 79 74 65 0d 20 20 38 38 30 20 50 25 3d 50 25 |byte. 880 P%=P%| 000029f0 2b 31 0d 20 20 38 39 30 20 3d 70 61 73 73 0d 20 |+1. 890 =pass. | 00002a00 20 39 30 30 20 44 45 46 46 4e 65 71 75 77 28 77 | 900 DEFFNequw(w| 00002a10 6f 72 64 29 0d 20 20 39 31 30 20 3f 50 25 3d 77 |ord). 910 ?P%=w| 00002a20 6f 72 64 20 4d 4f 44 20 32 35 36 0d 20 20 39 32 |ord MOD 256. 92| 00002a30 30 20 50 25 3f 31 3d 77 6f 72 64 20 44 49 56 20 |0 P%?1=word DIV | 00002a40 32 35 36 0d 20 20 39 33 30 20 50 25 3d 50 25 2b |256. 930 P%=P%+| 00002a50 32 0d 20 20 39 34 30 20 3d 70 61 73 73 0d 20 20 |2. 940 =pass. | 00002a60 39 35 30 20 44 45 46 46 4e 65 71 75 64 28 64 6f |950 DEFFNequd(do| 00002a70 75 62 6c 65 29 0d 20 20 39 36 30 20 21 50 25 3d |uble). 960 !P%=| 00002a80 64 6f 75 62 6c 65 0d 20 20 39 37 30 20 50 25 3d |double. 970 P%=| 00002a90 50 25 2b 34 0d 20 20 39 38 30 20 3d 70 61 73 73 |P%+4. 980 =pass| 00002aa0 0d 20 20 39 39 30 20 44 45 46 46 4e 65 71 75 73 |. 990 DEFFNequs| 00002ab0 28 73 74 72 69 6e 67 24 29 0d 20 31 30 30 30 20 |(string$). 1000 | 00002ac0 24 50 25 3d 73 74 72 69 6e 67 24 0d 20 31 30 31 |$P%=string$. 101| 00002ad0 30 20 50 25 3d 50 25 2b 4c 45 4e 28 73 74 72 69 |0 P%=P%+LEN(stri| 00002ae0 6e 67 24 29 0d 20 31 30 32 30 20 3d 70 61 73 73 |ng$). 1020 =pass| 00002af0 0d 0d |..| 00002af2