Home » CEEFAX disks » telesoftware4.adl » 10-01-88/T\OSB09
10-01-88/T\OSB09
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 » telesoftware4.adl |
Filename: | 10-01-88/T\OSB09 |
Read OK: | ✔ |
File size: | 4673 bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
OSBITS - An Exploration of the BBC Micro at Machine Level By Programmer ........................................................... Part 9: Operating System Calls (III) And so a 'final' look at the general operating system calls in the BBC Micro. This is a list of them, together with their call addresses and their vector addresses. (We'll come onto vectors in a later module.) OSCLI FFF7 208 OSBYTE FFF4 20A OSWORD FFF1 20C OSWRCH FFEE 20E OSNEWL FFE7 OSASCI FFE3 OSRDCH FFE0 210 OSFILE FFDD 212 OSARGS FFDA 214 OSBGET FFD7 216 OSBPUT FFD4 218 OSGBPB FFD1 21A OSFIND FFCE 21C NVOSWRCH FFCB NVOSRDCH FFC8 GSREAD FFC5 GSINIT FFC2 OSEVEN FFBF OSRDRM FFB9 These are all subroutines, to which we JSR and they will RTS back to us. Many of them pass through a vector, which is to say they are indirected. This means we can intercept the routines for our own purposes as we shall see in a later module. Note that the above list is not exhaustive, particularly since not all OS routines are documented. The top batch of routines, down to OSGBPB are what you might call 'legal' routines on a BBC Micro, which is to say that Acorn have documented them. As the 'Advanced User Guide' points out some of the undocumented calls should be used with caution. In the program in this module I have cautiously used OSRDRM (or OSRDSC as it is known in the Master OS) to read information from a sideways ROM to allow us to print out the title and copyright date. Let's go through the list from the top, in call address order. OSCLI This is the routine that gets us into the command line interpreter. Basically that is the part of the operating system that takes a * (star) command and processes it. If you have BASIC 2 or later you will have an OSCLI in BASIC that does the same thing, i.e. OSCLI("HELP") is equivalent to *HELP. The line of text you wish to be interpreted (the * command but without a * at its head) is put in memory and on entry to the routine X and Y point to that address (X=low byte, Y=high byte) in the same way they do with OSWORD. The line of text must finish with a carriage return (13/&0D). It doesn't matter what is in A. You can use OSCLI to access some of the other routines in this list and it may be easier to use OSCLI for this sometimes. As you might expect the line is checked by the operating system first. Any commands it doesn't recognise are then run past sideways ROMS to see if any of them will pick it up. Finally it is sent to the current filing system to see if it could be run from disc (for example). OSBYTE, OSWORD, OSWRCH, OSNEWL, OSASCI, OSRDCH These I have covered in earlier modules. The next set of routines are concerned with filing systems, like disc or tape or ROM or the network. I don't propose to go into great detail here because the file parameters that can be saved with a file can be numerous. I suggest you refer to your filing system user guide or Advanced reference guide for detailed information on how to lay out parameter blocks and the like. OSFILE This routine is the OS routine equivalent of *SAVE and with it you read or write a whole file and/or its attributes. A file's attributes are such things as who can read or write to it and its load and execution addresses. To use a file for random access OSFIND, OSARGS, OSBPUT and OSGBPB are called. OSFIND This call is similar to the OPEN commands in BASIC in that it is used to open and close files and to allocate the file handle (a number) by which it is recognised. This call must be issued first to open a file before any of the other random access filing routines can be used. OSARGS This routine reads or writes the attributes of a file. It could be used to find out where the pointer to the file lies or see how long the file is. OSBPUT and OSBGET These routines put (write) or get (read) a single byte to or from a file. Where that byte is put depends on the sequential pointer which can be read or changed using OSARGS. OSGBPB (sometimes known as OS Heebeegeebee!) This routine is a block version of OSBGET and OSBPUT in that it reads or writes a group of bytes from or to a file and can also simultaneously perform some OSARGS functions. It is particularly useful with Econet where the routeing bytes sent with every transmitted package will seriously slow a data transfer if you are only sending bytes one at a time. You should try reading a View file over Econet and see the problem (Read not Load, and they've solved the problem with View 3 I am told). This routine is not implemented with the cassette filing system. And so then to the undocumented routines, NVOSWRCH and NVOSRDCH These two non-vectored I/O routines, operate exactly like their vectored equivalents. We will make use of NVOSWRCH in a later module. GSINIT and GSREAD The operating system processes the strings used for some of its commands (like *KEY) using these two routines, one initialises the string and the other reads it byte by byte. OSEVEN I haven't told you about events yet, they come in a later module. Suffice it to say that this routine can cause one and I am rather unsure what it would be useful for. OSRDRM With this routine you can read a byte out of a paged ROM. In the MASTER this routine is called OSRDSC, meaning OS Read Screen, and has a companion OSWRSC to write to the screen. It cannot be called from the second processor and is set up like this: Y contains the ROM number &F6 and &F7 (in I/O memory) hold the address of the byte to be read, low byte first as usual. On exit the accumulator holds the byte read. The program in this module, B/osb09, uses OSRDRM to enable us to build up a list of the headers from the sideways ROMs in your machine. I have made an effort to be more disciplined in the code writing in this module, since it is starting to become fairly complex. This should make it easier to read, and easier to modify later. In lines 130 and 140 I have defined what are called manifest constants. These are constants I will use within the program to define certain parameters. Although they could just as easily be put into statements, like LDA #3 instead of LDA #number_of_zeros, it may be that they would occur more than once. Defining them as constants in this way (by, rather confusingly defining a variable!) avoids any risk of forgetting to change all the occurrences of one of them. It is good practice and I shall also be trying to remember to use manifest constants. (A new years resolution?) I shall use a couple of bytes of zero page for some post-indexed indirect addressing. Those bytes are the value of zp% and zp%+1. zp% is set in line 150 and I am using a bit of the user space in zero page. In fact anything in there should be safe because the code saves the contents of those two bytes on the stack before running and restores them afterwards. This is done in lines 250-280 and 860-890. The only possibility of corruption would come from an interrupt routine which uses those bytes and does not save and restore properly. Line 170 is a safeguard and is there for two reasons. Firstly the OS routine we are going to use, OSRDRM (called OSRDSC on the Master) will only work in the I/O processor, otherwise known as an ordinary unexpanded B or B+, or a Master without a co-processor. Secondly I intend pinching a page of OS workspace for the routine and that is in the I/O processor of course. Now in BASIC 2 there is a means of assembling code with an offset so you can use ordinary memory whilst assembling for a special piece of memory. I won't use that here but when I come onto sideways ROMS I will. (If not before.) In the code as broadcast I am using page A which is the RS423 and cassette input buffer. This could cause a problem if you want to run the finished code from cassette but if you have no disc filing system then you can use page D (the Non Maskable Interrupt workspace which is normally only used by disc filing systems. Other options could be the equivalent output buffer in page 9, or the user defined character buffer in page C. Or there is always the bits of disc filing system space such as page 12 or 13. To change the position of the code simply change the value of code% in line 190. If you have a Master things are a little more difficult. You are not supposed to use any of the bits of OS workspace here either and of course the disc workspace is hidden in private RAM. I suggest you use page B or page C. These are allocated for ECONET and if you have no econet they should be useable. If you have econet then why not stay where I put the code which is in page A. Maybe Acorn will eventually provide us with some user space in their micros into which we can put code. I should mention that the legal way to do all this is to reset PAGE or HIMEM and tuck your code away there, but that negates the benefit of running this little routine from disc. I have allocated some space for variables; this is in lines 1950-1980. I could have just put a BRK instruction or op-code at that address but on this occasion I have used the EQU functions. BASIC 2 users can replace those with their built-in EQU pseudo-operators. One thing to note in passing line 230 is the effect of putting the OPT pass% on the same line as the bracket. If you do not the machine will always print out the start address of the assembly when you assemble. There is no way you can stop it. So, into the body of the code. After saving the zero page workspace we clear the screen and print out a little title, saying Sideways ROMs. You will find the wording for the title in line 1940 but beware of lengthening it by more than a couple of bytes because the code length is very nearly a whole page (256 bytes). If you don't want to clear the screen just remove the 'CHR$ 12 +' from line 1940. OSBYTE 170 is called next to get the address of the table of information about the sideways ROMS. This call is one of a group of OSBYTE calls that can read or write, which is why we set Y to &FF to define a read. Details in your Advanced Guide. On exit from this call the X and Y registers hold the low and high bytes respectively of the origin of the table. By then transferring these to zp% and zp%+1 (our two bytes of zero page workspace) we prepare for indexing our way through the table of 16 bytes in line 440. Before we do though there is a subroutine which keeps track of which ROM we are dealing with (from 0 to 15) and prints its number in Hex (0-F). We use an address called 'romnumber' to store the number currently being processed. (Hence setting it to zero in line 310. This makes use of setting X to zero before printing out the heading and saves a couple of bytes.) The subroutine is in lines 1060-1180 and makes use of the trick with binary coded decimal I explained in module 6. Y is set to the current ROM number during the routine. In line 440 we read the ROM information byte for the current ROM. If this is zero then there is not a properly formatted ROM in that socket so we can ignore it. Hence the code here BEQs to a label where we have finished with that particular ROM. If the ROM info byte is not zero we save it and go to a subroutine at serv_or_lang which checks to see if this ROM has a service and/or language entry point. Basically if a ROM has a language entry point it will run as a language. Examples are VIEW, BASIC, BCPL, ULTRACALC. A service entry point enables the ROM to react to * commands, including the one to select itself. Every ROM has a service entry point except BASIC. The command *BASIC is actually part of the operating system. Details of all this is in the Advanced Guides of course. This subroutine checks to see if bit 6 is set (denoting a language entry point) or bit 7 (denoting a service entry point) and prints an L or S accordingly. This check is done using the BIT operation as described in the last module. From line 530 is the main section of the routine. Now this differs from the standard ROM listing routine in that it prints out all the ROM header. This enables you to see what the copyright year of your BASIC is for example (I have 3 versions of BBC BASIC in my machine). These headers can be long and a line length of 70, set in line 130, is fine for 80 column modes. If you want to use the routine in a 40 column mode (like Mode 7) then change line_length to 30. After setting the counters for zeros and letters printed to zero we enter the main loop. In the loop we use OSRDRM to get the bytes from the header one at a time. The header information we want to read starts at &8009 so we add 9 to the letter counter and then invoke OSRDRM as described earlier. On exit from OSRDRM we have the byte read in the accumulator and we call a subroutine at address 'test'. This subroutine checks out the byte, prints it if it is valid, and exits with the carry flag clear if 3 nulls (zeros) have been counted from the header and with the character to print in the accumulator. After 3 nulls there should be no more human readable information left in the header. This subroutine starts at line 1670. Why do I use the carry flag to say that we have finished the header? Two reasons. I use a flag at all because we cannot branch directly out of a subroutine without unbalancing the stack. When you enter a subroutine the microprocessor puts the return address on the stack ready to be pulled off when an RTS is reached. If you JMP or BRanch back instead that address remains on the stack and may corrupt any stack storage you are using. In this program we are using the stack for storage during the whole routine. The carry flag is used because it is easily set or cleared (SEC or CLC), whereas the overflow flag cannot be directly affected like this. Also the carry flag is not affected by a load or save command like the zero flag would be. I have used it this particular way around to save a couple of bytes because it will always be clear at line 1750. During the test subroutine any control codes or bytes over 126 are replaced with spaces. On exit from test we finish with this ROM if the carry flag is clear (as per line 680). If not we print the character, increase the letter counter and check if we are now over our allotted length. If we are we go on to the next ROM, if not we look at the next letter. Line 750 is the address 'rom_finished' where we go when each ROM has been read. The ROM counter is incremented and we check to see if we have reached 16 and the end, if not round we go again. The routines exit is at line 830 and notice that we restore the zero page bytes in reverse order. This is because the stack operates last-in-first-out so you read out in the reverse order to how you put in. The rest of the assembler code contains the subroutines and variable addresses. The final bit of BASIC prints out a line you can copy with the cursor keys to save the assembled code. Notice that we set the top 16 bits of a 32 bit address to tell the filing system that we are in the I/O processor and want the code to run there. Here is the output of the routine when I ran it in my machine. Note that socket 2 is empty and socket F has RAM in it but that RAM contained only random bytes. Lines 5 and C have been truncated by me to make them fit here. Also note that in socket 8 is the DNFS which does not contain a proper copyright message in its header, hence the gibberish. (To save you asking, MicroFax is a BBC chip to enable me to format pages for CEEFAX.) Sideways Roms 0 ( S) TELETEXT 2.50 (C)BBC 1986 1 (L ) BASIC (C)1981 Acorn 2 3 ( S) TOOLKIT 1.22 (C)1983 Beebug 4 (LS) VIEW A2.1 (C) 1982 Protechnic 5 ( S) Watford Electronics EPSON NLQ ROM V1.0 (C) Watford 6 (LS) MONITOR 2.01 (C)1985 ISMEC 7 (LS) SPELLCHECK II v1.20 (C)1984 BEEBUGSOFT 8 ( S) DFS,NET (C)ROFF '1119E 9 (LS) Ultracalc 2 (C)1984 Topexpress Limited A (LS) BCPL 7.0 (C) 1982 RICHARDS COMPUTER PRODUCTS LTD. B (LS) MicroFax 4.4 (C)T.E.Kennington 1985 C ( S) AMX Mouse Support (C)1984 Advanced Memory Systems D (L ) BASIC (C)1983 Acorn E (L ) BASIC (C)1982 Acorn F I hope you will be wondering why I used subroutines in this code even though the routines were only called once. My general rule is to try to write code with these sort of priorities: Firstly try to make it as simple and readable as possible. Hence subroutines and lots of comments. I may have to modify the program a year or two later. Secondly any piece of code that is used in more than one place should be a subroutine. This reduces the size of the code. Thirdly subroutines slow down code because of the calling and putting of return addressed on the stack. So if time is very critical try to avoid them. These three things do not always work towards the same end and there is not usually a single solution to a programming problem (thank goodness). And what about a flow chart. Well, to be brutally honest they are almost impossible to do by telesoftware so I am unable to send any to you. In fact I rarely flowchart a complete program myself (which is possibly why trial and error feature so much in my writing) although if I have a tricky bit of logic to sort out a flow chart is very useful. That's all for this module, next time I'll look at errors and exceptions which become very important as soon as your programs require people to input into them. Also a brief overview of the 6502 microprocessor commands, or OPCODES, which you can use as a reference.
00000000 4f 53 42 49 54 53 20 2d 20 41 6e 20 45 78 70 6c |OSBITS - An Expl| 00000010 6f 72 61 74 69 6f 6e 20 6f 66 20 74 68 65 20 42 |oration of the B| 00000020 42 43 20 4d 69 63 72 6f 20 61 74 20 4d 61 63 68 |BC Micro at Mach| 00000030 69 6e 65 20 4c 65 76 65 6c 0d 0d 42 79 20 50 72 |ine Level..By Pr| 00000040 6f 67 72 61 6d 6d 65 72 0d 0d 2e 2e 2e 2e 2e 2e |ogrammer........| 00000050 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00000080 2e 2e 2e 2e 2e 0d 0d 0d 50 61 72 74 20 39 3a 20 |........Part 9: | 00000090 4f 70 65 72 61 74 69 6e 67 20 53 79 73 74 65 6d |Operating System| 000000a0 20 43 61 6c 6c 73 20 28 49 49 49 29 0d 0d 41 6e | Calls (III)..An| 000000b0 64 20 73 6f 20 61 20 27 66 69 6e 61 6c 27 20 6c |d so a 'final' l| 000000c0 6f 6f 6b 20 61 74 20 74 68 65 20 67 65 6e 65 72 |ook at the gener| 000000d0 61 6c 20 6f 70 65 72 61 74 69 6e 67 20 73 79 73 |al operating sys| 000000e0 74 65 6d 20 63 61 6c 6c 73 0d 69 6e 20 74 68 65 |tem calls.in the| 000000f0 20 42 42 43 20 4d 69 63 72 6f 2e 20 20 54 68 69 | BBC Micro. Thi| 00000100 73 20 69 73 20 61 20 6c 69 73 74 20 6f 66 20 74 |s is a list of t| 00000110 68 65 6d 2c 20 74 6f 67 65 74 68 65 72 20 77 69 |hem, together wi| 00000120 74 68 0d 74 68 65 69 72 20 63 61 6c 6c 20 61 64 |th.their call ad| 00000130 64 72 65 73 73 65 73 20 61 6e 64 20 74 68 65 69 |dresses and thei| 00000140 72 20 76 65 63 74 6f 72 20 61 64 64 72 65 73 73 |r vector address| 00000150 65 73 2e 20 20 28 57 65 27 6c 6c 0d 63 6f 6d 65 |es. (We'll.come| 00000160 20 6f 6e 74 6f 20 76 65 63 74 6f 72 73 20 69 6e | onto vectors in| 00000170 20 61 20 6c 61 74 65 72 20 6d 6f 64 75 6c 65 2e | a later module.| 00000180 29 0d 0d 20 20 20 20 20 20 20 20 20 4f 53 43 4c |).. OSCL| 00000190 49 20 20 20 20 20 20 20 20 20 20 20 20 46 46 46 |I FFF| 000001a0 37 20 20 20 20 20 20 20 20 20 20 20 32 30 38 0d |7 208.| 000001b0 20 20 20 20 20 20 20 20 20 4f 53 42 59 54 45 20 | OSBYTE | 000001c0 20 20 20 20 20 20 20 20 20 20 46 46 46 34 20 20 | FFF4 | 000001d0 20 20 20 20 20 20 20 20 20 32 30 41 0d 20 20 20 | 20A. | 000001e0 20 20 20 20 20 20 4f 53 57 4f 52 44 20 20 20 20 | OSWORD | 000001f0 20 20 20 20 20 20 20 46 46 46 31 20 20 20 20 20 | FFF1 | 00000200 20 20 20 20 20 20 32 30 43 0d 20 20 20 20 20 20 | 20C. | 00000210 20 20 20 4f 53 57 52 43 48 20 20 20 20 20 20 20 | OSWRCH | 00000220 20 20 20 20 46 46 45 45 20 20 20 20 20 20 20 20 | FFEE | 00000230 20 20 20 32 30 45 0d 20 20 20 20 20 20 20 20 20 | 20E. | 00000240 4f 53 4e 45 57 4c 20 20 20 20 20 20 20 20 20 20 |OSNEWL | 00000250 20 46 46 45 37 0d 20 20 20 20 20 20 20 20 20 4f | FFE7. O| 00000260 53 41 53 43 49 20 20 20 20 20 20 20 20 20 20 20 |SASCI | 00000270 46 46 45 33 0d 20 20 20 20 20 20 20 20 20 4f 53 |FFE3. OS| 00000280 52 44 43 48 20 20 20 20 20 20 20 20 20 20 20 46 |RDCH F| 00000290 46 45 30 20 20 20 20 20 20 20 20 20 20 20 32 31 |FE0 21| 000002a0 30 0d 20 20 20 20 20 20 20 20 20 4f 53 46 49 4c |0. OSFIL| 000002b0 45 20 20 20 20 20 20 20 20 20 20 20 46 46 44 44 |E FFDD| 000002c0 20 20 20 20 20 20 20 20 20 20 20 32 31 32 0d 20 | 212. | 000002d0 20 20 20 20 20 20 20 20 4f 53 41 52 47 53 20 20 | OSARGS | 000002e0 20 20 20 20 20 20 20 20 20 46 46 44 41 20 20 20 | FFDA | 000002f0 20 20 20 20 20 20 20 20 32 31 34 0d 20 20 20 20 | 214. | 00000300 20 20 20 20 20 4f 53 42 47 45 54 20 20 20 20 20 | OSBGET | 00000310 20 20 20 20 20 20 46 46 44 37 20 20 20 20 20 20 | FFD7 | 00000320 20 20 20 20 20 32 31 36 0d 20 20 20 20 20 20 20 | 216. | 00000330 20 20 4f 53 42 50 55 54 20 20 20 20 20 20 20 20 | OSBPUT | 00000340 20 20 20 46 46 44 34 20 20 20 20 20 20 20 20 20 | FFD4 | 00000350 20 20 32 31 38 0d 20 20 20 20 20 20 20 20 20 4f | 218. O| 00000360 53 47 42 50 42 20 20 20 20 20 20 20 20 20 20 20 |SGBPB | 00000370 46 46 44 31 20 20 20 20 20 20 20 20 20 20 20 32 |FFD1 2| 00000380 31 41 0d 20 20 20 20 20 20 20 20 20 4f 53 46 49 |1A. OSFI| 00000390 4e 44 20 20 20 20 20 20 20 20 20 20 20 46 46 43 |ND FFC| 000003a0 45 20 20 20 20 20 20 20 20 20 20 20 32 31 43 0d |E 21C.| 000003b0 0d 20 20 20 20 20 20 20 20 20 4e 56 4f 53 57 52 |. NVOSWR| 000003c0 43 48 20 20 20 20 20 20 20 20 20 46 46 43 42 0d |CH FFCB.| 000003d0 20 20 20 20 20 20 20 20 20 4e 56 4f 53 52 44 43 | NVOSRDC| 000003e0 48 20 20 20 20 20 20 20 20 20 46 46 43 38 0d 20 |H FFC8. | 000003f0 20 20 20 20 20 20 20 20 47 53 52 45 41 44 20 20 | GSREAD | 00000400 20 20 20 20 20 20 20 20 20 46 46 43 35 20 0d 20 | FFC5 . | 00000410 20 20 20 20 20 20 20 20 47 53 49 4e 49 54 20 20 | GSINIT | 00000420 20 20 20 20 20 20 20 20 20 46 46 43 32 0d 20 20 | FFC2. | 00000430 20 20 20 20 20 20 20 4f 53 45 56 45 4e 20 20 20 | OSEVEN | 00000440 20 20 20 20 20 20 20 20 46 46 42 46 0d 20 20 20 | FFBF. | 00000450 20 20 20 20 20 20 4f 53 52 44 52 4d 20 20 20 20 | OSRDRM | 00000460 20 20 20 20 20 20 20 46 46 42 39 0d 0d 54 68 65 | FFB9..The| 00000470 73 65 20 61 72 65 20 61 6c 6c 20 73 75 62 72 6f |se are all subro| 00000480 75 74 69 6e 65 73 2c 20 74 6f 20 77 68 69 63 68 |utines, to which| 00000490 20 77 65 20 4a 53 52 20 61 6e 64 20 74 68 65 79 | we JSR and they| 000004a0 20 77 69 6c 6c 20 52 54 53 0d 62 61 63 6b 20 74 | will RTS.back t| 000004b0 6f 20 75 73 2e 20 20 4d 61 6e 79 20 6f 66 20 74 |o us. Many of t| 000004c0 68 65 6d 20 70 61 73 73 20 74 68 72 6f 75 67 68 |hem pass through| 000004d0 20 61 20 76 65 63 74 6f 72 2c 20 77 68 69 63 68 | a vector, which| 000004e0 20 69 73 20 74 6f 0d 73 61 79 20 74 68 65 79 20 | is to.say they | 000004f0 61 72 65 20 69 6e 64 69 72 65 63 74 65 64 2e 20 |are indirected. | 00000500 20 54 68 69 73 20 6d 65 61 6e 73 20 77 65 20 63 | This means we c| 00000510 61 6e 20 69 6e 74 65 72 63 65 70 74 20 74 68 65 |an intercept the| 00000520 0d 72 6f 75 74 69 6e 65 73 20 66 6f 72 20 6f 75 |.routines for ou| 00000530 72 20 6f 77 6e 20 70 75 72 70 6f 73 65 73 20 61 |r own purposes a| 00000540 73 20 77 65 20 73 68 61 6c 6c 20 73 65 65 20 69 |s we shall see i| 00000550 6e 20 61 20 6c 61 74 65 72 0d 6d 6f 64 75 6c 65 |n a later.module| 00000560 2e 20 20 4e 6f 74 65 20 74 68 61 74 20 74 68 65 |. Note that the| 00000570 20 61 62 6f 76 65 20 6c 69 73 74 20 69 73 20 6e | above list is n| 00000580 6f 74 20 65 78 68 61 75 73 74 69 76 65 2c 0d 70 |ot exhaustive,.p| 00000590 61 72 74 69 63 75 6c 61 72 6c 79 20 73 69 6e 63 |articularly sinc| 000005a0 65 20 6e 6f 74 20 61 6c 6c 20 4f 53 20 72 6f 75 |e not all OS rou| 000005b0 74 69 6e 65 73 20 61 72 65 20 64 6f 63 75 6d 65 |tines are docume| 000005c0 6e 74 65 64 2e 0d 0d 54 68 65 20 74 6f 70 20 62 |nted...The top b| 000005d0 61 74 63 68 20 6f 66 20 72 6f 75 74 69 6e 65 73 |atch of routines| 000005e0 2c 20 64 6f 77 6e 20 74 6f 20 4f 53 47 42 50 42 |, down to OSGBPB| 000005f0 20 61 72 65 20 77 68 61 74 20 79 6f 75 20 6d 69 | are what you mi| 00000600 67 68 74 0d 63 61 6c 6c 20 27 6c 65 67 61 6c 27 |ght.call 'legal'| 00000610 20 72 6f 75 74 69 6e 65 73 20 6f 6e 20 61 20 42 | routines on a B| 00000620 42 43 20 4d 69 63 72 6f 2c 20 77 68 69 63 68 20 |BC Micro, which | 00000630 69 73 20 74 6f 20 73 61 79 20 74 68 61 74 0d 41 |is to say that.A| 00000640 63 6f 72 6e 20 68 61 76 65 20 64 6f 63 75 6d 65 |corn have docume| 00000650 6e 74 65 64 20 74 68 65 6d 2e 20 20 41 73 20 74 |nted them. As t| 00000660 68 65 20 27 41 64 76 61 6e 63 65 64 20 55 73 65 |he 'Advanced Use| 00000670 72 20 47 75 69 64 65 27 0d 70 6f 69 6e 74 73 20 |r Guide'.points | 00000680 6f 75 74 20 73 6f 6d 65 20 6f 66 20 74 68 65 20 |out some of the | 00000690 75 6e 64 6f 63 75 6d 65 6e 74 65 64 20 63 61 6c |undocumented cal| 000006a0 6c 73 20 73 68 6f 75 6c 64 20 62 65 20 75 73 65 |ls should be use| 000006b0 64 0d 77 69 74 68 20 63 61 75 74 69 6f 6e 2e 20 |d.with caution. | 000006c0 20 49 6e 20 74 68 65 20 70 72 6f 67 72 61 6d 20 | In the program | 000006d0 69 6e 20 74 68 69 73 20 6d 6f 64 75 6c 65 20 49 |in this module I| 000006e0 20 68 61 76 65 0d 63 61 75 74 69 6f 75 73 6c 79 | have.cautiously| 000006f0 20 75 73 65 64 20 4f 53 52 44 52 4d 20 28 6f 72 | used OSRDRM (or| 00000700 20 4f 53 52 44 53 43 20 61 73 20 69 74 20 69 73 | OSRDSC as it is| 00000710 20 6b 6e 6f 77 6e 20 69 6e 20 74 68 65 0d 4d 61 | known in the.Ma| 00000720 73 74 65 72 20 4f 53 29 20 74 6f 20 72 65 61 64 |ster OS) to read| 00000730 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 66 72 6f | information fro| 00000740 6d 20 61 20 73 69 64 65 77 61 79 73 20 52 4f 4d |m a sideways ROM| 00000750 20 74 6f 20 61 6c 6c 6f 77 0d 75 73 20 74 6f 20 | to allow.us to | 00000760 70 72 69 6e 74 20 6f 75 74 20 74 68 65 20 74 69 |print out the ti| 00000770 74 6c 65 20 61 6e 64 20 63 6f 70 79 72 69 67 68 |tle and copyrigh| 00000780 74 20 64 61 74 65 2e 0d 0d 4c 65 74 27 73 20 67 |t date...Let's g| 00000790 6f 20 74 68 72 6f 75 67 68 20 74 68 65 20 6c 69 |o through the li| 000007a0 73 74 20 66 72 6f 6d 20 74 68 65 20 74 6f 70 2c |st from the top,| 000007b0 20 69 6e 20 63 61 6c 6c 20 61 64 64 72 65 73 73 | in call address| 000007c0 0d 6f 72 64 65 72 2e 0d 0d 0d 4f 53 43 4c 49 0d |.order....OSCLI.| 000007d0 0d 54 68 69 73 20 69 73 20 74 68 65 20 72 6f 75 |.This is the rou| 000007e0 74 69 6e 65 20 74 68 61 74 20 67 65 74 73 20 75 |tine that gets u| 000007f0 73 20 69 6e 74 6f 20 74 68 65 20 63 6f 6d 6d 61 |s into the comma| 00000800 6e 64 20 6c 69 6e 65 0d 69 6e 74 65 72 70 72 65 |nd line.interpre| 00000810 74 65 72 2e 20 20 42 61 73 69 63 61 6c 6c 79 20 |ter. Basically | 00000820 74 68 61 74 20 69 73 20 74 68 65 20 70 61 72 74 |that is the part| 00000830 20 6f 66 20 74 68 65 20 6f 70 65 72 61 74 69 6e | of the operatin| 00000840 67 0d 73 79 73 74 65 6d 20 74 68 61 74 20 74 61 |g.system that ta| 00000850 6b 65 73 20 61 20 2a 20 28 73 74 61 72 29 20 63 |kes a * (star) c| 00000860 6f 6d 6d 61 6e 64 20 61 6e 64 20 70 72 6f 63 65 |ommand and proce| 00000870 73 73 65 73 20 69 74 2e 20 20 49 66 0d 79 6f 75 |sses it. If.you| 00000880 20 68 61 76 65 20 42 41 53 49 43 20 32 20 6f 72 | have BASIC 2 or| 00000890 20 6c 61 74 65 72 20 79 6f 75 20 77 69 6c 6c 20 | later you will | 000008a0 68 61 76 65 20 61 6e 20 4f 53 43 4c 49 20 69 6e |have an OSCLI in| 000008b0 20 42 41 53 49 43 0d 74 68 61 74 20 64 6f 65 73 | BASIC.that does| 000008c0 20 74 68 65 20 73 61 6d 65 20 74 68 69 6e 67 2c | the same thing,| 000008d0 20 69 2e 65 2e 20 4f 53 43 4c 49 28 22 48 45 4c | i.e. OSCLI("HEL| 000008e0 50 22 29 20 69 73 20 65 71 75 69 76 61 6c 65 6e |P") is equivalen| 000008f0 74 0d 74 6f 20 2a 48 45 4c 50 2e 0d 0d 54 68 65 |t.to *HELP...The| 00000900 20 6c 69 6e 65 20 6f 66 20 74 65 78 74 20 79 6f | line of text yo| 00000910 75 20 77 69 73 68 20 74 6f 20 62 65 20 69 6e 74 |u wish to be int| 00000920 65 72 70 72 65 74 65 64 20 28 74 68 65 20 2a 20 |erpreted (the * | 00000930 63 6f 6d 6d 61 6e 64 0d 62 75 74 20 77 69 74 68 |command.but with| 00000940 6f 75 74 20 61 20 2a 20 61 74 20 69 74 73 20 68 |out a * at its h| 00000950 65 61 64 29 20 69 73 20 70 75 74 20 69 6e 20 6d |ead) is put in m| 00000960 65 6d 6f 72 79 20 61 6e 64 20 6f 6e 20 65 6e 74 |emory and on ent| 00000970 72 79 0d 74 6f 20 74 68 65 20 72 6f 75 74 69 6e |ry.to the routin| 00000980 65 20 58 20 61 6e 64 20 59 20 70 6f 69 6e 74 20 |e X and Y point | 00000990 74 6f 20 74 68 61 74 20 61 64 64 72 65 73 73 20 |to that address | 000009a0 28 58 3d 6c 6f 77 20 62 79 74 65 2c 0d 59 3d 68 |(X=low byte,.Y=h| 000009b0 69 67 68 20 62 79 74 65 29 20 69 6e 20 74 68 65 |igh byte) in the| 000009c0 20 73 61 6d 65 20 77 61 79 20 74 68 65 79 20 64 | same way they d| 000009d0 6f 20 77 69 74 68 20 4f 53 57 4f 52 44 2e 20 20 |o with OSWORD. | 000009e0 54 68 65 20 6c 69 6e 65 0d 6f 66 20 74 65 78 74 |The line.of text| 000009f0 20 6d 75 73 74 20 66 69 6e 69 73 68 20 77 69 74 | must finish wit| 00000a00 68 20 61 20 63 61 72 72 69 61 67 65 20 72 65 74 |h a carriage ret| 00000a10 75 72 6e 20 28 31 33 2f 26 30 44 29 2e 20 20 49 |urn (13/&0D). I| 00000a20 74 0d 64 6f 65 73 6e 27 74 20 6d 61 74 74 65 72 |t.doesn't matter| 00000a30 20 77 68 61 74 20 69 73 20 69 6e 20 41 2e 0d 0d | what is in A...| 00000a40 59 6f 75 20 63 61 6e 20 75 73 65 20 4f 53 43 4c |You can use OSCL| 00000a50 49 20 74 6f 20 61 63 63 65 73 73 20 73 6f 6d 65 |I to access some| 00000a60 20 6f 66 20 74 68 65 20 6f 74 68 65 72 20 72 6f | of the other ro| 00000a70 75 74 69 6e 65 73 20 69 6e 0d 74 68 69 73 20 6c |utines in.this l| 00000a80 69 73 74 20 61 6e 64 20 69 74 20 6d 61 79 20 62 |ist and it may b| 00000a90 65 20 65 61 73 69 65 72 20 74 6f 20 75 73 65 20 |e easier to use | 00000aa0 4f 53 43 4c 49 20 66 6f 72 20 74 68 69 73 0d 73 |OSCLI for this.s| 00000ab0 6f 6d 65 74 69 6d 65 73 2e 20 20 41 73 20 79 6f |ometimes. As yo| 00000ac0 75 20 6d 69 67 68 74 20 65 78 70 65 63 74 20 74 |u might expect t| 00000ad0 68 65 20 6c 69 6e 65 20 69 73 20 63 68 65 63 6b |he line is check| 00000ae0 65 64 20 62 79 20 74 68 65 0d 6f 70 65 72 61 74 |ed by the.operat| 00000af0 69 6e 67 20 73 79 73 74 65 6d 20 66 69 72 73 74 |ing system first| 00000b00 2e 20 20 41 6e 79 20 63 6f 6d 6d 61 6e 64 73 20 |. Any commands | 00000b10 69 74 20 64 6f 65 73 6e 27 74 20 72 65 63 6f 67 |it doesn't recog| 00000b20 6e 69 73 65 0d 61 72 65 20 74 68 65 6e 20 72 75 |nise.are then ru| 00000b30 6e 20 70 61 73 74 20 73 69 64 65 77 61 79 73 20 |n past sideways | 00000b40 52 4f 4d 53 20 74 6f 20 73 65 65 20 69 66 20 61 |ROMS to see if a| 00000b50 6e 79 20 6f 66 20 74 68 65 6d 20 77 69 6c 6c 0d |ny of them will.| 00000b60 70 69 63 6b 20 69 74 20 75 70 2e 20 20 46 69 6e |pick it up. Fin| 00000b70 61 6c 6c 79 20 69 74 20 69 73 20 73 65 6e 74 20 |ally it is sent | 00000b80 74 6f 20 74 68 65 20 63 75 72 72 65 6e 74 20 66 |to the current f| 00000b90 69 6c 69 6e 67 20 73 79 73 74 65 6d 0d 74 6f 20 |iling system.to | 00000ba0 73 65 65 20 69 66 20 69 74 20 63 6f 75 6c 64 20 |see if it could | 00000bb0 62 65 20 72 75 6e 20 66 72 6f 6d 20 64 69 73 63 |be run from disc| 00000bc0 20 28 66 6f 72 20 65 78 61 6d 70 6c 65 29 2e 0d | (for example)..| 00000bd0 0d 0d 4f 53 42 59 54 45 2c 20 4f 53 57 4f 52 44 |..OSBYTE, OSWORD| 00000be0 2c 20 4f 53 57 52 43 48 2c 20 4f 53 4e 45 57 4c |, OSWRCH, OSNEWL| 00000bf0 2c 20 4f 53 41 53 43 49 2c 20 4f 53 52 44 43 48 |, OSASCI, OSRDCH| 00000c00 0d 0d 54 68 65 73 65 20 49 20 68 61 76 65 20 63 |..These I have c| 00000c10 6f 76 65 72 65 64 20 69 6e 20 65 61 72 6c 69 65 |overed in earlie| 00000c20 72 20 6d 6f 64 75 6c 65 73 2e 0d 0d 0d 54 68 65 |r modules....The| 00000c30 20 6e 65 78 74 20 73 65 74 20 6f 66 20 72 6f 75 | next set of rou| 00000c40 74 69 6e 65 73 20 61 72 65 20 63 6f 6e 63 65 72 |tines are concer| 00000c50 6e 65 64 20 77 69 74 68 20 66 69 6c 69 6e 67 20 |ned with filing | 00000c60 73 79 73 74 65 6d 73 2c 0d 6c 69 6b 65 20 64 69 |systems,.like di| 00000c70 73 63 20 6f 72 20 74 61 70 65 20 6f 72 20 52 4f |sc or tape or RO| 00000c80 4d 20 6f 72 20 74 68 65 20 6e 65 74 77 6f 72 6b |M or the network| 00000c90 2e 20 20 49 20 64 6f 6e 27 74 20 70 72 6f 70 6f |. I don't propo| 00000ca0 73 65 20 74 6f 0d 67 6f 20 69 6e 74 6f 20 67 72 |se to.go into gr| 00000cb0 65 61 74 20 64 65 74 61 69 6c 20 68 65 72 65 20 |eat detail here | 00000cc0 62 65 63 61 75 73 65 20 74 68 65 20 66 69 6c 65 |because the file| 00000cd0 20 70 61 72 61 6d 65 74 65 72 73 20 74 68 61 74 | parameters that| 00000ce0 0d 63 61 6e 20 62 65 20 73 61 76 65 64 20 77 69 |.can be saved wi| 00000cf0 74 68 20 61 20 66 69 6c 65 20 63 61 6e 20 62 65 |th a file can be| 00000d00 20 6e 75 6d 65 72 6f 75 73 2e 20 20 49 20 73 75 | numerous. I su| 00000d10 67 67 65 73 74 20 79 6f 75 0d 72 65 66 65 72 20 |ggest you.refer | 00000d20 74 6f 20 79 6f 75 72 20 66 69 6c 69 6e 67 20 73 |to your filing s| 00000d30 79 73 74 65 6d 20 75 73 65 72 20 67 75 69 64 65 |ystem user guide| 00000d40 20 6f 72 20 41 64 76 61 6e 63 65 64 20 72 65 66 | or Advanced ref| 00000d50 65 72 65 6e 63 65 0d 67 75 69 64 65 20 66 6f 72 |erence.guide for| 00000d60 20 64 65 74 61 69 6c 65 64 20 69 6e 66 6f 72 6d | detailed inform| 00000d70 61 74 69 6f 6e 20 6f 6e 20 68 6f 77 20 74 6f 20 |ation on how to | 00000d80 6c 61 79 20 6f 75 74 20 70 61 72 61 6d 65 74 65 |lay out paramete| 00000d90 72 0d 62 6c 6f 63 6b 73 20 61 6e 64 20 74 68 65 |r.blocks and the| 00000da0 20 6c 69 6b 65 2e 0d 0d 4f 53 46 49 4c 45 0d 0d | like...OSFILE..| 00000db0 54 68 69 73 20 72 6f 75 74 69 6e 65 20 69 73 20 |This routine is | 00000dc0 74 68 65 20 4f 53 20 72 6f 75 74 69 6e 65 20 65 |the OS routine e| 00000dd0 71 75 69 76 61 6c 65 6e 74 20 6f 66 20 2a 53 41 |quivalent of *SA| 00000de0 56 45 20 61 6e 64 20 77 69 74 68 0d 69 74 20 79 |VE and with.it y| 00000df0 6f 75 20 72 65 61 64 20 6f 72 20 77 72 69 74 65 |ou read or write| 00000e00 20 61 20 77 68 6f 6c 65 20 66 69 6c 65 20 61 6e | a whole file an| 00000e10 64 2f 6f 72 20 69 74 73 20 61 74 74 72 69 62 75 |d/or its attribu| 00000e20 74 65 73 2e 20 20 41 0d 66 69 6c 65 27 73 20 61 |tes. A.file's a| 00000e30 74 74 72 69 62 75 74 65 73 20 61 72 65 20 73 75 |ttributes are su| 00000e40 63 68 20 74 68 69 6e 67 73 20 61 73 20 77 68 6f |ch things as who| 00000e50 20 63 61 6e 20 72 65 61 64 20 6f 72 20 77 72 69 | can read or wri| 00000e60 74 65 0d 74 6f 20 69 74 20 61 6e 64 20 69 74 73 |te.to it and its| 00000e70 20 6c 6f 61 64 20 61 6e 64 20 65 78 65 63 75 74 | load and execut| 00000e80 69 6f 6e 20 61 64 64 72 65 73 73 65 73 2e 0d 0d |ion addresses...| 00000e90 54 6f 20 75 73 65 20 61 20 66 69 6c 65 20 66 6f |To use a file fo| 00000ea0 72 20 72 61 6e 64 6f 6d 20 61 63 63 65 73 73 20 |r random access | 00000eb0 4f 53 46 49 4e 44 2c 20 4f 53 41 52 47 53 2c 20 |OSFIND, OSARGS, | 00000ec0 4f 53 42 50 55 54 20 61 6e 64 0d 4f 53 47 42 50 |OSBPUT and.OSGBP| 00000ed0 42 20 61 72 65 20 63 61 6c 6c 65 64 2e 0d 0d 4f |B are called...O| 00000ee0 53 46 49 4e 44 0d 0d 54 68 69 73 20 63 61 6c 6c |SFIND..This call| 00000ef0 20 69 73 20 73 69 6d 69 6c 61 72 20 74 6f 20 74 | is similar to t| 00000f00 68 65 20 4f 50 45 4e 20 63 6f 6d 6d 61 6e 64 73 |he OPEN commands| 00000f10 20 69 6e 20 42 41 53 49 43 20 69 6e 20 74 68 61 | in BASIC in tha| 00000f20 74 0d 69 74 20 69 73 20 75 73 65 64 20 74 6f 20 |t.it is used to | 00000f30 6f 70 65 6e 20 61 6e 64 20 63 6c 6f 73 65 20 66 |open and close f| 00000f40 69 6c 65 73 20 61 6e 64 20 74 6f 20 61 6c 6c 6f |iles and to allo| 00000f50 63 61 74 65 20 74 68 65 20 66 69 6c 65 0d 68 61 |cate the file.ha| 00000f60 6e 64 6c 65 20 28 61 20 6e 75 6d 62 65 72 29 20 |ndle (a number) | 00000f70 62 79 20 77 68 69 63 68 20 69 74 20 69 73 20 72 |by which it is r| 00000f80 65 63 6f 67 6e 69 73 65 64 2e 20 20 54 68 69 73 |ecognised. This| 00000f90 20 63 61 6c 6c 20 6d 75 73 74 0d 62 65 20 69 73 | call must.be is| 00000fa0 73 75 65 64 20 66 69 72 73 74 20 74 6f 20 6f 70 |sued first to op| 00000fb0 65 6e 20 61 20 66 69 6c 65 20 62 65 66 6f 72 65 |en a file before| 00000fc0 20 61 6e 79 20 6f 66 20 74 68 65 20 6f 74 68 65 | any of the othe| 00000fd0 72 0d 72 61 6e 64 6f 6d 20 61 63 63 65 73 73 20 |r.random access | 00000fe0 66 69 6c 69 6e 67 20 72 6f 75 74 69 6e 65 73 20 |filing routines | 00000ff0 63 61 6e 20 62 65 20 75 73 65 64 2e 0d 0d 4f 53 |can be used...OS| 00001000 41 52 47 53 0d 0d 54 68 69 73 20 72 6f 75 74 69 |ARGS..This routi| 00001010 6e 65 20 72 65 61 64 73 20 6f 72 20 77 72 69 74 |ne reads or writ| 00001020 65 73 20 74 68 65 20 61 74 74 72 69 62 75 74 65 |es the attribute| 00001030 73 20 6f 66 20 61 20 66 69 6c 65 2e 20 20 49 74 |s of a file. It| 00001040 0d 63 6f 75 6c 64 20 62 65 20 75 73 65 64 20 74 |.could be used t| 00001050 6f 20 66 69 6e 64 20 6f 75 74 20 77 68 65 72 65 |o find out where| 00001060 20 74 68 65 20 70 6f 69 6e 74 65 72 20 74 6f 20 | the pointer to | 00001070 74 68 65 20 66 69 6c 65 20 6c 69 65 73 0d 6f 72 |the file lies.or| 00001080 20 73 65 65 20 68 6f 77 20 6c 6f 6e 67 20 74 68 | see how long th| 00001090 65 20 66 69 6c 65 20 69 73 2e 0d 0d 4f 53 42 50 |e file is...OSBP| 000010a0 55 54 20 61 6e 64 20 4f 53 42 47 45 54 0d 0d 54 |UT and OSBGET..T| 000010b0 68 65 73 65 20 72 6f 75 74 69 6e 65 73 20 70 75 |hese routines pu| 000010c0 74 20 28 77 72 69 74 65 29 20 6f 72 20 67 65 74 |t (write) or get| 000010d0 20 28 72 65 61 64 29 20 61 20 73 69 6e 67 6c 65 | (read) a single| 000010e0 20 62 79 74 65 20 74 6f 20 6f 72 0d 66 72 6f 6d | byte to or.from| 000010f0 20 61 20 66 69 6c 65 2e 20 20 57 68 65 72 65 20 | a file. Where | 00001100 74 68 61 74 20 62 79 74 65 20 69 73 20 70 75 74 |that byte is put| 00001110 20 64 65 70 65 6e 64 73 20 6f 6e 20 74 68 65 0d | depends on the.| 00001120 73 65 71 75 65 6e 74 69 61 6c 20 70 6f 69 6e 74 |sequential point| 00001130 65 72 20 77 68 69 63 68 20 63 61 6e 20 62 65 20 |er which can be | 00001140 72 65 61 64 20 6f 72 20 63 68 61 6e 67 65 64 20 |read or changed | 00001150 75 73 69 6e 67 0d 4f 53 41 52 47 53 2e 0d 0d 4f |using.OSARGS...O| 00001160 53 47 42 50 42 20 20 28 73 6f 6d 65 74 69 6d 65 |SGBPB (sometime| 00001170 73 20 6b 6e 6f 77 6e 20 61 73 20 4f 53 20 48 65 |s known as OS He| 00001180 65 62 65 65 67 65 65 62 65 65 21 29 0d 0d 54 68 |ebeegeebee!)..Th| 00001190 69 73 20 72 6f 75 74 69 6e 65 20 69 73 20 61 20 |is routine is a | 000011a0 62 6c 6f 63 6b 20 76 65 72 73 69 6f 6e 20 6f 66 |block version of| 000011b0 20 4f 53 42 47 45 54 20 61 6e 64 20 4f 53 42 50 | OSBGET and OSBP| 000011c0 55 54 20 69 6e 20 74 68 61 74 0d 69 74 20 72 65 |UT in that.it re| 000011d0 61 64 73 20 6f 72 20 77 72 69 74 65 73 20 61 20 |ads or writes a | 000011e0 67 72 6f 75 70 20 6f 66 20 62 79 74 65 73 20 66 |group of bytes f| 000011f0 72 6f 6d 20 6f 72 20 74 6f 20 61 20 66 69 6c 65 |rom or to a file| 00001200 20 61 6e 64 0d 63 61 6e 20 61 6c 73 6f 20 73 69 | and.can also si| 00001210 6d 75 6c 74 61 6e 65 6f 75 73 6c 79 20 70 65 72 |multaneously per| 00001220 66 6f 72 6d 20 73 6f 6d 65 20 4f 53 41 52 47 53 |form some OSARGS| 00001230 20 66 75 6e 63 74 69 6f 6e 73 2e 20 20 49 74 0d | functions. It.| 00001240 69 73 20 70 61 72 74 69 63 75 6c 61 72 6c 79 20 |is particularly | 00001250 75 73 65 66 75 6c 20 77 69 74 68 20 45 63 6f 6e |useful with Econ| 00001260 65 74 20 77 68 65 72 65 20 74 68 65 20 72 6f 75 |et where the rou| 00001270 74 65 69 6e 67 20 62 79 74 65 73 0d 73 65 6e 74 |teing bytes.sent| 00001280 20 77 69 74 68 20 65 76 65 72 79 20 74 72 61 6e | with every tran| 00001290 73 6d 69 74 74 65 64 20 70 61 63 6b 61 67 65 20 |smitted package | 000012a0 77 69 6c 6c 20 73 65 72 69 6f 75 73 6c 79 20 73 |will seriously s| 000012b0 6c 6f 77 20 61 0d 64 61 74 61 20 74 72 61 6e 73 |low a.data trans| 000012c0 66 65 72 20 69 66 20 79 6f 75 20 61 72 65 20 6f |fer if you are o| 000012d0 6e 6c 79 20 73 65 6e 64 69 6e 67 20 62 79 74 65 |nly sending byte| 000012e0 73 20 6f 6e 65 20 61 74 20 61 20 74 69 6d 65 2e |s one at a time.| 000012f0 20 0d 59 6f 75 20 73 68 6f 75 6c 64 20 74 72 79 | .You should try| 00001300 20 72 65 61 64 69 6e 67 20 61 20 56 69 65 77 20 | reading a View | 00001310 66 69 6c 65 20 6f 76 65 72 20 45 63 6f 6e 65 74 |file over Econet| 00001320 20 61 6e 64 20 73 65 65 20 74 68 65 0d 70 72 6f | and see the.pro| 00001330 62 6c 65 6d 20 28 52 65 61 64 20 6e 6f 74 20 4c |blem (Read not L| 00001340 6f 61 64 2c 20 61 6e 64 20 74 68 65 79 27 76 65 |oad, and they've| 00001350 20 73 6f 6c 76 65 64 20 74 68 65 20 70 72 6f 62 | solved the prob| 00001360 6c 65 6d 20 77 69 74 68 0d 56 69 65 77 20 33 20 |lem with.View 3 | 00001370 49 20 61 6d 20 74 6f 6c 64 29 2e 20 20 54 68 69 |I am told). Thi| 00001380 73 20 72 6f 75 74 69 6e 65 20 69 73 20 6e 6f 74 |s routine is not| 00001390 20 69 6d 70 6c 65 6d 65 6e 74 65 64 20 77 69 74 | implemented wit| 000013a0 68 20 74 68 65 0d 63 61 73 73 65 74 74 65 20 66 |h the.cassette f| 000013b0 69 6c 69 6e 67 20 73 79 73 74 65 6d 2e 0d 0d 0d |iling system....| 000013c0 41 6e 64 20 73 6f 20 74 68 65 6e 20 74 6f 20 74 |And so then to t| 000013d0 68 65 20 75 6e 64 6f 63 75 6d 65 6e 74 65 64 20 |he undocumented | 000013e0 72 6f 75 74 69 6e 65 73 2c 0d 0d 4e 56 4f 53 57 |routines,..NVOSW| 000013f0 52 43 48 20 61 6e 64 20 4e 56 4f 53 52 44 43 48 |RCH and NVOSRDCH| 00001400 0d 0d 54 68 65 73 65 20 74 77 6f 20 6e 6f 6e 2d |..These two non-| 00001410 76 65 63 74 6f 72 65 64 20 49 2f 4f 20 72 6f 75 |vectored I/O rou| 00001420 74 69 6e 65 73 2c 20 6f 70 65 72 61 74 65 20 65 |tines, operate e| 00001430 78 61 63 74 6c 79 20 6c 69 6b 65 0d 74 68 65 69 |xactly like.thei| 00001440 72 20 76 65 63 74 6f 72 65 64 20 65 71 75 69 76 |r vectored equiv| 00001450 61 6c 65 6e 74 73 2e 20 20 57 65 20 77 69 6c 6c |alents. We will| 00001460 20 6d 61 6b 65 20 75 73 65 20 6f 66 20 4e 56 4f | make use of NVO| 00001470 53 57 52 43 48 20 69 6e 0d 61 20 6c 61 74 65 72 |SWRCH in.a later| 00001480 20 6d 6f 64 75 6c 65 2e 0d 0d 47 53 49 4e 49 54 | module...GSINIT| 00001490 20 61 6e 64 20 47 53 52 45 41 44 0d 0d 54 68 65 | and GSREAD..The| 000014a0 20 6f 70 65 72 61 74 69 6e 67 20 73 79 73 74 65 | operating syste| 000014b0 6d 20 70 72 6f 63 65 73 73 65 73 20 74 68 65 20 |m processes the | 000014c0 73 74 72 69 6e 67 73 20 75 73 65 64 20 66 6f 72 |strings used for| 000014d0 20 73 6f 6d 65 20 6f 66 0d 69 74 73 20 63 6f 6d | some of.its com| 000014e0 6d 61 6e 64 73 20 28 6c 69 6b 65 20 2a 4b 45 59 |mands (like *KEY| 000014f0 29 20 75 73 69 6e 67 20 74 68 65 73 65 20 74 77 |) using these tw| 00001500 6f 20 72 6f 75 74 69 6e 65 73 2c 20 6f 6e 65 0d |o routines, one.| 00001510 69 6e 69 74 69 61 6c 69 73 65 73 20 74 68 65 20 |initialises the | 00001520 73 74 72 69 6e 67 20 61 6e 64 20 74 68 65 20 6f |string and the o| 00001530 74 68 65 72 20 72 65 61 64 73 20 69 74 20 62 79 |ther reads it by| 00001540 74 65 20 62 79 20 62 79 74 65 2e 0d 0d 4f 53 45 |te by byte...OSE| 00001550 56 45 4e 0d 0d 49 20 68 61 76 65 6e 27 74 20 74 |VEN..I haven't t| 00001560 6f 6c 64 20 79 6f 75 20 61 62 6f 75 74 20 65 76 |old you about ev| 00001570 65 6e 74 73 20 79 65 74 2c 20 74 68 65 79 20 63 |ents yet, they c| 00001580 6f 6d 65 20 69 6e 20 61 20 6c 61 74 65 72 0d 6d |ome in a later.m| 00001590 6f 64 75 6c 65 2e 20 20 53 75 66 66 69 63 65 20 |odule. Suffice | 000015a0 69 74 20 74 6f 20 73 61 79 20 74 68 61 74 20 74 |it to say that t| 000015b0 68 69 73 20 72 6f 75 74 69 6e 65 20 63 61 6e 20 |his routine can | 000015c0 63 61 75 73 65 20 6f 6e 65 0d 61 6e 64 20 49 20 |cause one.and I | 000015d0 61 6d 20 72 61 74 68 65 72 20 75 6e 73 75 72 65 |am rather unsure| 000015e0 20 77 68 61 74 20 69 74 20 77 6f 75 6c 64 20 62 | what it would b| 000015f0 65 20 75 73 65 66 75 6c 20 66 6f 72 2e 0d 0d 4f |e useful for...O| 00001600 53 52 44 52 4d 0d 0d 57 69 74 68 20 74 68 69 73 |SRDRM..With this| 00001610 20 72 6f 75 74 69 6e 65 20 79 6f 75 20 63 61 6e | routine you can| 00001620 20 72 65 61 64 20 61 20 62 79 74 65 20 6f 75 74 | read a byte out| 00001630 20 6f 66 20 61 20 70 61 67 65 64 20 52 4f 4d 2e | of a paged ROM.| 00001640 20 0d 49 6e 20 74 68 65 20 4d 41 53 54 45 52 20 | .In the MASTER | 00001650 74 68 69 73 20 72 6f 75 74 69 6e 65 20 69 73 20 |this routine is | 00001660 63 61 6c 6c 65 64 20 4f 53 52 44 53 43 2c 20 6d |called OSRDSC, m| 00001670 65 61 6e 69 6e 67 20 4f 53 20 52 65 61 64 0d 53 |eaning OS Read.S| 00001680 63 72 65 65 6e 2c 20 61 6e 64 20 68 61 73 20 61 |creen, and has a| 00001690 20 63 6f 6d 70 61 6e 69 6f 6e 20 4f 53 57 52 53 | companion OSWRS| 000016a0 43 20 74 6f 20 77 72 69 74 65 20 74 6f 20 74 68 |C to write to th| 000016b0 65 20 73 63 72 65 65 6e 2e 0d 0d 49 74 20 63 61 |e screen...It ca| 000016c0 6e 6e 6f 74 20 62 65 20 63 61 6c 6c 65 64 20 66 |nnot be called f| 000016d0 72 6f 6d 20 74 68 65 20 73 65 63 6f 6e 64 20 70 |rom the second p| 000016e0 72 6f 63 65 73 73 6f 72 20 61 6e 64 20 69 73 20 |rocessor and is | 000016f0 73 65 74 20 75 70 0d 6c 69 6b 65 20 74 68 69 73 |set up.like this| 00001700 3a 0d 0d 59 20 63 6f 6e 74 61 69 6e 73 20 74 68 |:..Y contains th| 00001710 65 20 52 4f 4d 20 6e 75 6d 62 65 72 0d 26 46 36 |e ROM number.&F6| 00001720 20 61 6e 64 20 26 46 37 20 28 69 6e 20 49 2f 4f | and &F7 (in I/O| 00001730 20 6d 65 6d 6f 72 79 29 20 68 6f 6c 64 20 74 68 | memory) hold th| 00001740 65 20 61 64 64 72 65 73 73 20 6f 66 20 74 68 65 |e address of the| 00001750 20 62 79 74 65 20 74 6f 0d 62 65 20 72 65 61 64 | byte to.be read| 00001760 2c 20 6c 6f 77 20 62 79 74 65 20 66 69 72 73 74 |, low byte first| 00001770 20 61 73 20 75 73 75 61 6c 2e 0d 0d 4f 6e 20 65 | as usual...On e| 00001780 78 69 74 20 74 68 65 20 61 63 63 75 6d 75 6c 61 |xit the accumula| 00001790 74 6f 72 20 68 6f 6c 64 73 20 74 68 65 20 62 79 |tor holds the by| 000017a0 74 65 20 72 65 61 64 2e 0d 0d 54 68 65 20 70 72 |te read...The pr| 000017b0 6f 67 72 61 6d 20 69 6e 20 74 68 69 73 20 6d 6f |ogram in this mo| 000017c0 64 75 6c 65 2c 20 42 2f 6f 73 62 30 39 2c 20 75 |dule, B/osb09, u| 000017d0 73 65 73 20 4f 53 52 44 52 4d 20 74 6f 20 65 6e |ses OSRDRM to en| 000017e0 61 62 6c 65 0d 75 73 20 74 6f 20 62 75 69 6c 64 |able.us to build| 000017f0 20 75 70 20 61 20 6c 69 73 74 20 6f 66 20 74 68 | up a list of th| 00001800 65 20 68 65 61 64 65 72 73 20 66 72 6f 6d 20 74 |e headers from t| 00001810 68 65 20 73 69 64 65 77 61 79 73 20 52 4f 4d 73 |he sideways ROMs| 00001820 0d 69 6e 20 79 6f 75 72 20 6d 61 63 68 69 6e 65 |.in your machine| 00001830 2e 0d 0d 49 20 68 61 76 65 20 6d 61 64 65 20 61 |...I have made a| 00001840 6e 20 65 66 66 6f 72 74 20 74 6f 20 62 65 20 6d |n effort to be m| 00001850 6f 72 65 20 64 69 73 63 69 70 6c 69 6e 65 64 20 |ore disciplined | 00001860 69 6e 20 74 68 65 20 63 6f 64 65 0d 77 72 69 74 |in the code.writ| 00001870 69 6e 67 20 69 6e 20 74 68 69 73 20 6d 6f 64 75 |ing in this modu| 00001880 6c 65 2c 20 73 69 6e 63 65 20 69 74 20 69 73 20 |le, since it is | 00001890 73 74 61 72 74 69 6e 67 20 74 6f 20 62 65 63 6f |starting to beco| 000018a0 6d 65 0d 66 61 69 72 6c 79 20 63 6f 6d 70 6c 65 |me.fairly comple| 000018b0 78 2e 20 20 54 68 69 73 20 73 68 6f 75 6c 64 20 |x. This should | 000018c0 6d 61 6b 65 20 69 74 20 65 61 73 69 65 72 20 74 |make it easier t| 000018d0 6f 20 72 65 61 64 2c 20 61 6e 64 0d 65 61 73 69 |o read, and.easi| 000018e0 65 72 20 74 6f 20 6d 6f 64 69 66 79 20 6c 61 74 |er to modify lat| 000018f0 65 72 2e 0d 0d 49 6e 20 6c 69 6e 65 73 20 31 33 |er...In lines 13| 00001900 30 20 61 6e 64 20 31 34 30 20 49 20 68 61 76 65 |0 and 140 I have| 00001910 20 64 65 66 69 6e 65 64 20 77 68 61 74 20 61 72 | defined what ar| 00001920 65 20 63 61 6c 6c 65 64 20 6d 61 6e 69 66 65 73 |e called manifes| 00001930 74 0d 63 6f 6e 73 74 61 6e 74 73 2e 20 20 54 68 |t.constants. Th| 00001940 65 73 65 20 61 72 65 20 63 6f 6e 73 74 61 6e 74 |ese are constant| 00001950 73 20 49 20 77 69 6c 6c 20 75 73 65 20 77 69 74 |s I will use wit| 00001960 68 69 6e 20 74 68 65 0d 70 72 6f 67 72 61 6d 20 |hin the.program | 00001970 74 6f 20 64 65 66 69 6e 65 20 63 65 72 74 61 69 |to define certai| 00001980 6e 20 70 61 72 61 6d 65 74 65 72 73 2e 20 20 41 |n parameters. A| 00001990 6c 74 68 6f 75 67 68 20 74 68 65 79 20 63 6f 75 |lthough they cou| 000019a0 6c 64 0d 6a 75 73 74 20 61 73 20 65 61 73 69 6c |ld.just as easil| 000019b0 79 20 62 65 20 70 75 74 20 69 6e 74 6f 20 73 74 |y be put into st| 000019c0 61 74 65 6d 65 6e 74 73 2c 20 6c 69 6b 65 20 4c |atements, like L| 000019d0 44 41 20 23 33 20 69 6e 73 74 65 61 64 0d 6f 66 |DA #3 instead.of| 000019e0 20 4c 44 41 20 23 6e 75 6d 62 65 72 5f 6f 66 5f | LDA #number_of_| 000019f0 7a 65 72 6f 73 2c 20 69 74 20 6d 61 79 20 62 65 |zeros, it may be| 00001a00 20 74 68 61 74 20 74 68 65 79 20 77 6f 75 6c 64 | that they would| 00001a10 20 6f 63 63 75 72 0d 6d 6f 72 65 20 74 68 61 6e | occur.more than| 00001a20 20 6f 6e 63 65 2e 20 20 44 65 66 69 6e 69 6e 67 | once. Defining| 00001a30 20 74 68 65 6d 20 61 73 20 63 6f 6e 73 74 61 6e | them as constan| 00001a40 74 73 20 69 6e 20 74 68 69 73 20 77 61 79 20 28 |ts in this way (| 00001a50 62 79 2c 0d 72 61 74 68 65 72 20 63 6f 6e 66 75 |by,.rather confu| 00001a60 73 69 6e 67 6c 79 20 64 65 66 69 6e 69 6e 67 20 |singly defining | 00001a70 61 20 76 61 72 69 61 62 6c 65 21 29 20 61 76 6f |a variable!) avo| 00001a80 69 64 73 20 61 6e 79 20 72 69 73 6b 20 6f 66 0d |ids any risk of.| 00001a90 66 6f 72 67 65 74 74 69 6e 67 20 74 6f 20 63 68 |forgetting to ch| 00001aa0 61 6e 67 65 20 61 6c 6c 20 74 68 65 20 6f 63 63 |ange all the occ| 00001ab0 75 72 72 65 6e 63 65 73 20 6f 66 20 6f 6e 65 20 |urrences of one | 00001ac0 6f 66 20 74 68 65 6d 2e 20 20 49 74 0d 69 73 20 |of them. It.is | 00001ad0 67 6f 6f 64 20 70 72 61 63 74 69 63 65 20 61 6e |good practice an| 00001ae0 64 20 49 20 73 68 61 6c 6c 20 61 6c 73 6f 20 62 |d I shall also b| 00001af0 65 20 74 72 79 69 6e 67 20 74 6f 20 72 65 6d 65 |e trying to reme| 00001b00 6d 62 65 72 20 74 6f 0d 75 73 65 20 6d 61 6e 69 |mber to.use mani| 00001b10 66 65 73 74 20 63 6f 6e 73 74 61 6e 74 73 2e 20 |fest constants. | 00001b20 20 28 41 20 6e 65 77 20 79 65 61 72 73 20 72 65 | (A new years re| 00001b30 73 6f 6c 75 74 69 6f 6e 3f 29 0d 0d 49 20 73 68 |solution?)..I sh| 00001b40 61 6c 6c 20 75 73 65 20 61 20 63 6f 75 70 6c 65 |all use a couple| 00001b50 20 6f 66 20 62 79 74 65 73 20 6f 66 20 7a 65 72 | of bytes of zer| 00001b60 6f 20 70 61 67 65 20 66 6f 72 20 73 6f 6d 65 0d |o page for some.| 00001b70 70 6f 73 74 2d 69 6e 64 65 78 65 64 20 69 6e 64 |post-indexed ind| 00001b80 69 72 65 63 74 20 61 64 64 72 65 73 73 69 6e 67 |irect addressing| 00001b90 2e 20 20 54 68 6f 73 65 20 62 79 74 65 73 20 61 |. Those bytes a| 00001ba0 72 65 20 74 68 65 20 76 61 6c 75 65 0d 6f 66 20 |re the value.of | 00001bb0 7a 70 25 20 61 6e 64 20 7a 70 25 2b 31 2e 20 20 |zp% and zp%+1. | 00001bc0 7a 70 25 20 69 73 20 73 65 74 20 69 6e 20 6c 69 |zp% is set in li| 00001bd0 6e 65 20 31 35 30 20 61 6e 64 20 49 20 61 6d 20 |ne 150 and I am | 00001be0 75 73 69 6e 67 20 61 0d 62 69 74 20 6f 66 20 74 |using a.bit of t| 00001bf0 68 65 20 75 73 65 72 20 73 70 61 63 65 20 69 6e |he user space in| 00001c00 20 7a 65 72 6f 20 70 61 67 65 2e 20 20 49 6e 20 | zero page. In | 00001c10 66 61 63 74 20 61 6e 79 74 68 69 6e 67 20 69 6e |fact anything in| 00001c20 0d 74 68 65 72 65 20 73 68 6f 75 6c 64 20 62 65 |.there should be| 00001c30 20 73 61 66 65 20 62 65 63 61 75 73 65 20 74 68 | safe because th| 00001c40 65 20 63 6f 64 65 20 73 61 76 65 73 20 74 68 65 |e code saves the| 00001c50 20 63 6f 6e 74 65 6e 74 73 20 6f 66 0d 74 68 6f | contents of.tho| 00001c60 73 65 20 74 77 6f 20 62 79 74 65 73 20 6f 6e 20 |se two bytes on | 00001c70 74 68 65 20 73 74 61 63 6b 20 62 65 66 6f 72 65 |the stack before| 00001c80 20 72 75 6e 6e 69 6e 67 20 61 6e 64 20 72 65 73 | running and res| 00001c90 74 6f 72 65 73 0d 74 68 65 6d 20 61 66 74 65 72 |tores.them after| 00001ca0 77 61 72 64 73 2e 20 20 54 68 69 73 20 69 73 20 |wards. This is | 00001cb0 64 6f 6e 65 20 69 6e 20 6c 69 6e 65 73 20 32 35 |done in lines 25| 00001cc0 30 2d 32 38 30 20 61 6e 64 20 38 36 30 2d 38 39 |0-280 and 860-89| 00001cd0 30 2e 0d 54 68 65 20 6f 6e 6c 79 20 70 6f 73 73 |0..The only poss| 00001ce0 69 62 69 6c 69 74 79 20 6f 66 20 63 6f 72 72 75 |ibility of corru| 00001cf0 70 74 69 6f 6e 20 77 6f 75 6c 64 20 63 6f 6d 65 |ption would come| 00001d00 20 66 72 6f 6d 20 61 6e 0d 69 6e 74 65 72 72 75 | from an.interru| 00001d10 70 74 20 72 6f 75 74 69 6e 65 20 77 68 69 63 68 |pt routine which| 00001d20 20 75 73 65 73 20 74 68 6f 73 65 20 62 79 74 65 | uses those byte| 00001d30 73 20 61 6e 64 20 64 6f 65 73 20 6e 6f 74 20 73 |s and does not s| 00001d40 61 76 65 0d 61 6e 64 20 72 65 73 74 6f 72 65 20 |ave.and restore | 00001d50 70 72 6f 70 65 72 6c 79 2e 0d 0d 4c 69 6e 65 20 |properly...Line | 00001d60 31 37 30 20 69 73 20 61 20 73 61 66 65 67 75 61 |170 is a safegua| 00001d70 72 64 20 61 6e 64 20 69 73 20 74 68 65 72 65 20 |rd and is there | 00001d80 66 6f 72 20 74 77 6f 20 72 65 61 73 6f 6e 73 2e |for two reasons.| 00001d90 20 0d 46 69 72 73 74 6c 79 20 74 68 65 20 4f 53 | .Firstly the OS| 00001da0 20 72 6f 75 74 69 6e 65 20 77 65 20 61 72 65 20 | routine we are | 00001db0 67 6f 69 6e 67 20 74 6f 20 75 73 65 2c 20 4f 53 |going to use, OS| 00001dc0 52 44 52 4d 20 28 63 61 6c 6c 65 64 0d 4f 53 52 |RDRM (called.OSR| 00001dd0 44 53 43 20 6f 6e 20 74 68 65 20 4d 61 73 74 65 |DSC on the Maste| 00001de0 72 29 20 77 69 6c 6c 20 6f 6e 6c 79 20 77 6f 72 |r) will only wor| 00001df0 6b 20 69 6e 20 74 68 65 20 49 2f 4f 20 70 72 6f |k in the I/O pro| 00001e00 63 65 73 73 6f 72 2c 0d 6f 74 68 65 72 77 69 73 |cessor,.otherwis| 00001e10 65 20 6b 6e 6f 77 6e 20 61 73 20 61 6e 20 6f 72 |e known as an or| 00001e20 64 69 6e 61 72 79 20 75 6e 65 78 70 61 6e 64 65 |dinary unexpande| 00001e30 64 20 42 20 6f 72 20 42 2b 2c 20 6f 72 20 61 0d |d B or B+, or a.| 00001e40 4d 61 73 74 65 72 20 77 69 74 68 6f 75 74 20 61 |Master without a| 00001e50 20 63 6f 2d 70 72 6f 63 65 73 73 6f 72 2e 0d 0d | co-processor...| 00001e60 53 65 63 6f 6e 64 6c 79 20 49 20 69 6e 74 65 6e |Secondly I inten| 00001e70 64 20 70 69 6e 63 68 69 6e 67 20 61 20 70 61 67 |d pinching a pag| 00001e80 65 20 6f 66 20 4f 53 20 77 6f 72 6b 73 70 61 63 |e of OS workspac| 00001e90 65 20 66 6f 72 20 74 68 65 0d 72 6f 75 74 69 6e |e for the.routin| 00001ea0 65 20 61 6e 64 20 74 68 61 74 20 69 73 20 69 6e |e and that is in| 00001eb0 20 74 68 65 20 49 2f 4f 20 70 72 6f 63 65 73 73 | the I/O process| 00001ec0 6f 72 20 6f 66 20 63 6f 75 72 73 65 2e 20 20 4e |or of course. N| 00001ed0 6f 77 20 69 6e 0d 42 41 53 49 43 20 32 20 74 68 |ow in.BASIC 2 th| 00001ee0 65 72 65 20 69 73 20 61 20 6d 65 61 6e 73 20 6f |ere is a means o| 00001ef0 66 20 61 73 73 65 6d 62 6c 69 6e 67 20 63 6f 64 |f assembling cod| 00001f00 65 20 77 69 74 68 20 61 6e 20 6f 66 66 73 65 74 |e with an offset| 00001f10 0d 73 6f 20 79 6f 75 20 63 61 6e 20 75 73 65 20 |.so you can use | 00001f20 6f 72 64 69 6e 61 72 79 20 6d 65 6d 6f 72 79 20 |ordinary memory | 00001f30 77 68 69 6c 73 74 20 61 73 73 65 6d 62 6c 69 6e |whilst assemblin| 00001f40 67 20 66 6f 72 20 61 0d 73 70 65 63 69 61 6c 20 |g for a.special | 00001f50 70 69 65 63 65 20 6f 66 20 6d 65 6d 6f 72 79 2e |piece of memory.| 00001f60 20 20 49 20 77 6f 6e 27 74 20 75 73 65 20 74 68 | I won't use th| 00001f70 61 74 20 68 65 72 65 20 62 75 74 20 77 68 65 6e |at here but when| 00001f80 20 49 0d 63 6f 6d 65 20 6f 6e 74 6f 20 73 69 64 | I.come onto sid| 00001f90 65 77 61 79 73 20 52 4f 4d 53 20 49 20 77 69 6c |eways ROMS I wil| 00001fa0 6c 2e 20 20 28 49 66 20 6e 6f 74 20 62 65 66 6f |l. (If not befo| 00001fb0 72 65 2e 29 0d 0d 49 6e 20 74 68 65 20 63 6f 64 |re.)..In the cod| 00001fc0 65 20 61 73 20 62 72 6f 61 64 63 61 73 74 20 49 |e as broadcast I| 00001fd0 20 61 6d 20 75 73 69 6e 67 20 70 61 67 65 20 41 | am using page A| 00001fe0 20 77 68 69 63 68 20 69 73 20 74 68 65 0d 52 53 | which is the.RS| 00001ff0 34 32 33 20 61 6e 64 20 63 61 73 73 65 74 74 65 |423 and cassette| 00002000 20 69 6e 70 75 74 20 62 75 66 66 65 72 2e 20 20 | input buffer. | 00002010 54 68 69 73 20 63 6f 75 6c 64 20 63 61 75 73 65 |This could cause| 00002020 20 61 20 70 72 6f 62 6c 65 6d 0d 69 66 20 79 6f | a problem.if yo| 00002030 75 20 77 61 6e 74 20 74 6f 20 72 75 6e 20 74 68 |u want to run th| 00002040 65 20 66 69 6e 69 73 68 65 64 20 63 6f 64 65 20 |e finished code | 00002050 66 72 6f 6d 20 63 61 73 73 65 74 74 65 20 62 75 |from cassette bu| 00002060 74 20 69 66 0d 79 6f 75 20 68 61 76 65 20 6e 6f |t if.you have no| 00002070 20 64 69 73 63 20 66 69 6c 69 6e 67 20 73 79 73 | disc filing sys| 00002080 74 65 6d 20 74 68 65 6e 20 79 6f 75 20 63 61 6e |tem then you can| 00002090 20 75 73 65 20 70 61 67 65 20 44 20 28 74 68 65 | use page D (the| 000020a0 0d 4e 6f 6e 20 4d 61 73 6b 61 62 6c 65 20 49 6e |.Non Maskable In| 000020b0 74 65 72 72 75 70 74 20 77 6f 72 6b 73 70 61 63 |terrupt workspac| 000020c0 65 20 77 68 69 63 68 20 69 73 20 6e 6f 72 6d 61 |e which is norma| 000020d0 6c 6c 79 20 6f 6e 6c 79 20 75 73 65 64 0d 62 79 |lly only used.by| 000020e0 20 64 69 73 63 20 66 69 6c 69 6e 67 20 73 79 73 | disc filing sys| 000020f0 74 65 6d 73 2e 20 20 4f 74 68 65 72 20 6f 70 74 |tems. Other opt| 00002100 69 6f 6e 73 20 63 6f 75 6c 64 20 62 65 20 74 68 |ions could be th| 00002110 65 0d 65 71 75 69 76 61 6c 65 6e 74 20 6f 75 74 |e.equivalent out| 00002120 70 75 74 20 62 75 66 66 65 72 20 69 6e 20 70 61 |put buffer in pa| 00002130 67 65 20 39 2c 20 6f 72 20 74 68 65 20 75 73 65 |ge 9, or the use| 00002140 72 20 64 65 66 69 6e 65 64 0d 63 68 61 72 61 63 |r defined.charac| 00002150 74 65 72 20 62 75 66 66 65 72 20 69 6e 20 70 61 |ter buffer in pa| 00002160 67 65 20 43 2e 20 20 4f 72 20 74 68 65 72 65 20 |ge C. Or there | 00002170 69 73 20 61 6c 77 61 79 73 20 74 68 65 20 62 69 |is always the bi| 00002180 74 73 20 6f 66 0d 64 69 73 63 20 66 69 6c 69 6e |ts of.disc filin| 00002190 67 20 73 79 73 74 65 6d 20 73 70 61 63 65 20 73 |g system space s| 000021a0 75 63 68 20 61 73 20 70 61 67 65 20 31 32 20 6f |uch as page 12 o| 000021b0 72 20 31 33 2e 20 20 54 6f 20 63 68 61 6e 67 65 |r 13. To change| 000021c0 0d 74 68 65 20 70 6f 73 69 74 69 6f 6e 20 6f 66 |.the position of| 000021d0 20 74 68 65 20 63 6f 64 65 20 73 69 6d 70 6c 79 | the code simply| 000021e0 20 63 68 61 6e 67 65 20 74 68 65 20 76 61 6c 75 | change the valu| 000021f0 65 20 6f 66 20 63 6f 64 65 25 20 69 6e 0d 6c 69 |e of code% in.li| 00002200 6e 65 20 31 39 30 2e 0d 0d 49 66 20 79 6f 75 20 |ne 190...If you | 00002210 68 61 76 65 20 61 20 4d 61 73 74 65 72 20 74 68 |have a Master th| 00002220 69 6e 67 73 20 61 72 65 20 61 20 6c 69 74 74 6c |ings are a littl| 00002230 65 20 6d 6f 72 65 20 64 69 66 66 69 63 75 6c 74 |e more difficult| 00002240 2e 20 0d 59 6f 75 20 61 72 65 20 6e 6f 74 20 73 |. .You are not s| 00002250 75 70 70 6f 73 65 64 20 74 6f 20 75 73 65 20 61 |upposed to use a| 00002260 6e 79 20 6f 66 20 74 68 65 20 62 69 74 73 20 6f |ny of the bits o| 00002270 66 20 4f 53 20 77 6f 72 6b 73 70 61 63 65 0d 68 |f OS workspace.h| 00002280 65 72 65 20 65 69 74 68 65 72 20 61 6e 64 20 6f |ere either and o| 00002290 66 20 63 6f 75 72 73 65 20 74 68 65 20 64 69 73 |f course the dis| 000022a0 63 20 77 6f 72 6b 73 70 61 63 65 20 69 73 20 68 |c workspace is h| 000022b0 69 64 64 65 6e 20 69 6e 0d 70 72 69 76 61 74 65 |idden in.private| 000022c0 20 52 41 4d 2e 20 20 49 20 73 75 67 67 65 73 74 | RAM. I suggest| 000022d0 20 79 6f 75 20 75 73 65 20 70 61 67 65 20 42 20 | you use page B | 000022e0 6f 72 20 70 61 67 65 20 43 2e 20 20 54 68 65 73 |or page C. Thes| 000022f0 65 20 61 72 65 0d 61 6c 6c 6f 63 61 74 65 64 20 |e are.allocated | 00002300 66 6f 72 20 45 43 4f 4e 45 54 20 61 6e 64 20 69 |for ECONET and i| 00002310 66 20 79 6f 75 20 68 61 76 65 20 6e 6f 20 65 63 |f you have no ec| 00002320 6f 6e 65 74 20 74 68 65 79 20 73 68 6f 75 6c 64 |onet they should| 00002330 0d 62 65 20 75 73 65 61 62 6c 65 2e 20 20 49 66 |.be useable. If| 00002340 20 79 6f 75 20 68 61 76 65 20 65 63 6f 6e 65 74 | you have econet| 00002350 20 74 68 65 6e 20 77 68 79 20 6e 6f 74 20 73 74 | then why not st| 00002360 61 79 20 77 68 65 72 65 20 49 0d 70 75 74 20 74 |ay where I.put t| 00002370 68 65 20 63 6f 64 65 20 77 68 69 63 68 20 69 73 |he code which is| 00002380 20 69 6e 20 70 61 67 65 20 41 2e 20 20 4d 61 79 | in page A. May| 00002390 62 65 20 41 63 6f 72 6e 20 77 69 6c 6c 0d 65 76 |be Acorn will.ev| 000023a0 65 6e 74 75 61 6c 6c 79 20 70 72 6f 76 69 64 65 |entually provide| 000023b0 20 75 73 20 77 69 74 68 20 73 6f 6d 65 20 75 73 | us with some us| 000023c0 65 72 20 73 70 61 63 65 20 69 6e 20 74 68 65 69 |er space in thei| 000023d0 72 20 6d 69 63 72 6f 73 0d 69 6e 74 6f 20 77 68 |r micros.into wh| 000023e0 69 63 68 20 77 65 20 63 61 6e 20 70 75 74 20 63 |ich we can put c| 000023f0 6f 64 65 2e 0d 0d 49 20 73 68 6f 75 6c 64 20 6d |ode...I should m| 00002400 65 6e 74 69 6f 6e 20 74 68 61 74 20 74 68 65 20 |ention that the | 00002410 6c 65 67 61 6c 20 77 61 79 20 74 6f 20 64 6f 20 |legal way to do | 00002420 61 6c 6c 20 74 68 69 73 20 69 73 20 74 6f 0d 72 |all this is to.r| 00002430 65 73 65 74 20 50 41 47 45 20 6f 72 20 48 49 4d |eset PAGE or HIM| 00002440 45 4d 20 61 6e 64 20 74 75 63 6b 20 79 6f 75 72 |EM and tuck your| 00002450 20 63 6f 64 65 20 61 77 61 79 20 74 68 65 72 65 | code away there| 00002460 2c 20 62 75 74 20 74 68 61 74 0d 6e 65 67 61 74 |, but that.negat| 00002470 65 73 20 74 68 65 20 62 65 6e 65 66 69 74 20 6f |es the benefit o| 00002480 66 20 72 75 6e 6e 69 6e 67 20 74 68 69 73 20 6c |f running this l| 00002490 69 74 74 6c 65 20 72 6f 75 74 69 6e 65 20 66 72 |ittle routine fr| 000024a0 6f 6d 0d 64 69 73 63 2e 0d 0d 49 20 68 61 76 65 |om.disc...I have| 000024b0 20 61 6c 6c 6f 63 61 74 65 64 20 73 6f 6d 65 20 | allocated some | 000024c0 73 70 61 63 65 20 66 6f 72 20 76 61 72 69 61 62 |space for variab| 000024d0 6c 65 73 3b 20 74 68 69 73 20 69 73 20 69 6e 20 |les; this is in | 000024e0 6c 69 6e 65 73 0d 31 39 35 30 2d 31 39 38 30 2e |lines.1950-1980.| 000024f0 20 20 49 20 63 6f 75 6c 64 20 68 61 76 65 20 6a | I could have j| 00002500 75 73 74 20 70 75 74 20 61 20 42 52 4b 20 69 6e |ust put a BRK in| 00002510 73 74 72 75 63 74 69 6f 6e 20 6f 72 0d 6f 70 2d |struction or.op-| 00002520 63 6f 64 65 20 61 74 20 74 68 61 74 20 61 64 64 |code at that add| 00002530 72 65 73 73 20 62 75 74 20 6f 6e 20 74 68 69 73 |ress but on this| 00002540 20 6f 63 63 61 73 69 6f 6e 20 49 20 68 61 76 65 | occasion I have| 00002550 20 75 73 65 64 20 74 68 65 0d 45 51 55 20 66 75 | used the.EQU fu| 00002560 6e 63 74 69 6f 6e 73 2e 20 20 42 41 53 49 43 20 |nctions. BASIC | 00002570 32 20 75 73 65 72 73 20 63 61 6e 20 72 65 70 6c |2 users can repl| 00002580 61 63 65 20 74 68 6f 73 65 20 77 69 74 68 20 74 |ace those with t| 00002590 68 65 69 72 0d 62 75 69 6c 74 2d 69 6e 20 45 51 |heir.built-in EQ| 000025a0 55 20 70 73 65 75 64 6f 2d 6f 70 65 72 61 74 6f |U pseudo-operato| 000025b0 72 73 2e 0d 0d 4f 6e 65 20 74 68 69 6e 67 20 74 |rs...One thing t| 000025c0 6f 20 6e 6f 74 65 20 69 6e 20 70 61 73 73 69 6e |o note in passin| 000025d0 67 20 6c 69 6e 65 20 32 33 30 20 69 73 20 74 68 |g line 230 is th| 000025e0 65 20 65 66 66 65 63 74 20 6f 66 0d 70 75 74 74 |e effect of.putt| 000025f0 69 6e 67 20 74 68 65 20 4f 50 54 20 70 61 73 73 |ing the OPT pass| 00002600 25 20 6f 6e 20 74 68 65 20 73 61 6d 65 20 6c 69 |% on the same li| 00002610 6e 65 20 61 73 20 74 68 65 20 62 72 61 63 6b 65 |ne as the bracke| 00002620 74 2e 20 20 49 66 0d 79 6f 75 20 64 6f 20 6e 6f |t. If.you do no| 00002630 74 20 74 68 65 20 6d 61 63 68 69 6e 65 20 77 69 |t the machine wi| 00002640 6c 6c 20 61 6c 77 61 79 73 20 70 72 69 6e 74 20 |ll always print | 00002650 6f 75 74 20 74 68 65 20 73 74 61 72 74 0d 61 64 |out the start.ad| 00002660 64 72 65 73 73 20 6f 66 20 74 68 65 20 61 73 73 |dress of the ass| 00002670 65 6d 62 6c 79 20 77 68 65 6e 20 79 6f 75 20 61 |embly when you a| 00002680 73 73 65 6d 62 6c 65 2e 20 20 54 68 65 72 65 20 |ssemble. There | 00002690 69 73 20 6e 6f 20 77 61 79 0d 79 6f 75 20 63 61 |is no way.you ca| 000026a0 6e 20 73 74 6f 70 20 69 74 2e 0d 0d 53 6f 2c 20 |n stop it...So, | 000026b0 69 6e 74 6f 20 74 68 65 20 62 6f 64 79 20 6f 66 |into the body of| 000026c0 20 74 68 65 20 63 6f 64 65 2e 0d 0d 41 66 74 65 | the code...Afte| 000026d0 72 20 73 61 76 69 6e 67 20 74 68 65 20 7a 65 72 |r saving the zer| 000026e0 6f 20 70 61 67 65 20 77 6f 72 6b 73 70 61 63 65 |o page workspace| 000026f0 20 77 65 20 63 6c 65 61 72 20 74 68 65 20 73 63 | we clear the sc| 00002700 72 65 65 6e 20 61 6e 64 0d 70 72 69 6e 74 20 6f |reen and.print o| 00002710 75 74 20 61 20 6c 69 74 74 6c 65 20 74 69 74 6c |ut a little titl| 00002720 65 2c 20 73 61 79 69 6e 67 20 53 69 64 65 77 61 |e, saying Sidewa| 00002730 79 73 20 52 4f 4d 73 2e 20 20 59 6f 75 20 77 69 |ys ROMs. You wi| 00002740 6c 6c 0d 66 69 6e 64 20 74 68 65 20 77 6f 72 64 |ll.find the word| 00002750 69 6e 67 20 66 6f 72 20 74 68 65 20 74 69 74 6c |ing for the titl| 00002760 65 20 69 6e 20 6c 69 6e 65 20 31 39 34 30 20 62 |e in line 1940 b| 00002770 75 74 20 62 65 77 61 72 65 20 6f 66 0d 6c 65 6e |ut beware of.len| 00002780 67 74 68 65 6e 69 6e 67 20 69 74 20 62 79 20 6d |gthening it by m| 00002790 6f 72 65 20 74 68 61 6e 20 61 20 63 6f 75 70 6c |ore than a coupl| 000027a0 65 20 6f 66 20 62 79 74 65 73 20 62 65 63 61 75 |e of bytes becau| 000027b0 73 65 20 74 68 65 0d 63 6f 64 65 20 6c 65 6e 67 |se the.code leng| 000027c0 74 68 20 69 73 20 76 65 72 79 20 6e 65 61 72 6c |th is very nearl| 000027d0 79 20 61 20 77 68 6f 6c 65 20 70 61 67 65 20 28 |y a whole page (| 000027e0 32 35 36 20 62 79 74 65 73 29 2e 20 20 49 66 20 |256 bytes). If | 000027f0 79 6f 75 0d 64 6f 6e 27 74 20 77 61 6e 74 20 74 |you.don't want t| 00002800 6f 20 63 6c 65 61 72 20 74 68 65 20 73 63 72 65 |o clear the scre| 00002810 65 6e 20 6a 75 73 74 20 72 65 6d 6f 76 65 20 74 |en just remove t| 00002820 68 65 20 27 43 48 52 24 20 31 32 20 2b 27 0d 66 |he 'CHR$ 12 +'.f| 00002830 72 6f 6d 20 6c 69 6e 65 20 31 39 34 30 2e 0d 0d |rom line 1940...| 00002840 4f 53 42 59 54 45 20 31 37 30 20 69 73 20 63 61 |OSBYTE 170 is ca| 00002850 6c 6c 65 64 20 6e 65 78 74 20 74 6f 20 67 65 74 |lled next to get| 00002860 20 74 68 65 20 61 64 64 72 65 73 73 20 6f 66 20 | the address of | 00002870 74 68 65 20 74 61 62 6c 65 20 6f 66 0d 69 6e 66 |the table of.inf| 00002880 6f 72 6d 61 74 69 6f 6e 20 61 62 6f 75 74 20 74 |ormation about t| 00002890 68 65 20 73 69 64 65 77 61 79 73 20 52 4f 4d 53 |he sideways ROMS| 000028a0 2e 20 20 54 68 69 73 20 63 61 6c 6c 20 69 73 20 |. This call is | 000028b0 6f 6e 65 20 6f 66 20 61 0d 67 72 6f 75 70 20 6f |one of a.group o| 000028c0 66 20 4f 53 42 59 54 45 20 63 61 6c 6c 73 20 74 |f OSBYTE calls t| 000028d0 68 61 74 20 63 61 6e 20 72 65 61 64 20 6f 72 20 |hat can read or | 000028e0 77 72 69 74 65 2c 20 77 68 69 63 68 20 69 73 20 |write, which is | 000028f0 77 68 79 0d 77 65 20 73 65 74 20 59 20 74 6f 20 |why.we set Y to | 00002900 26 46 46 20 74 6f 20 64 65 66 69 6e 65 20 61 20 |&FF to define a | 00002910 72 65 61 64 2e 20 20 44 65 74 61 69 6c 73 20 69 |read. Details i| 00002920 6e 20 79 6f 75 72 20 41 64 76 61 6e 63 65 64 0d |n your Advanced.| 00002930 47 75 69 64 65 2e 20 20 4f 6e 20 65 78 69 74 20 |Guide. On exit | 00002940 66 72 6f 6d 20 74 68 69 73 20 63 61 6c 6c 20 74 |from this call t| 00002950 68 65 20 58 20 61 6e 64 20 59 20 72 65 67 69 73 |he X and Y regis| 00002960 74 65 72 73 20 68 6f 6c 64 0d 74 68 65 20 6c 6f |ters hold.the lo| 00002970 77 20 61 6e 64 20 68 69 67 68 20 62 79 74 65 73 |w and high bytes| 00002980 20 72 65 73 70 65 63 74 69 76 65 6c 79 20 6f 66 | respectively of| 00002990 20 74 68 65 20 6f 72 69 67 69 6e 20 6f 66 20 74 | the origin of t| 000029a0 68 65 0d 74 61 62 6c 65 2e 20 20 42 79 20 74 68 |he.table. By th| 000029b0 65 6e 20 74 72 61 6e 73 66 65 72 72 69 6e 67 20 |en transferring | 000029c0 74 68 65 73 65 20 74 6f 20 7a 70 25 20 61 6e 64 |these to zp% and| 000029d0 20 7a 70 25 2b 31 20 28 6f 75 72 20 74 77 6f 0d | zp%+1 (our two.| 000029e0 62 79 74 65 73 20 6f 66 20 7a 65 72 6f 20 70 61 |bytes of zero pa| 000029f0 67 65 20 77 6f 72 6b 73 70 61 63 65 29 20 77 65 |ge workspace) we| 00002a00 20 70 72 65 70 61 72 65 20 66 6f 72 20 69 6e 64 | prepare for ind| 00002a10 65 78 69 6e 67 20 6f 75 72 0d 77 61 79 20 74 68 |exing our.way th| 00002a20 72 6f 75 67 68 20 74 68 65 20 74 61 62 6c 65 20 |rough the table | 00002a30 6f 66 20 31 36 20 62 79 74 65 73 20 69 6e 20 6c |of 16 bytes in l| 00002a40 69 6e 65 20 34 34 30 2e 0d 0d 42 65 66 6f 72 65 |ine 440...Before| 00002a50 20 77 65 20 64 6f 20 74 68 6f 75 67 68 20 74 68 | we do though th| 00002a60 65 72 65 20 69 73 20 61 20 73 75 62 72 6f 75 74 |ere is a subrout| 00002a70 69 6e 65 20 77 68 69 63 68 20 6b 65 65 70 73 20 |ine which keeps | 00002a80 74 72 61 63 6b 0d 6f 66 20 77 68 69 63 68 20 52 |track.of which R| 00002a90 4f 4d 20 77 65 20 61 72 65 20 64 65 61 6c 69 6e |OM we are dealin| 00002aa0 67 20 77 69 74 68 20 28 66 72 6f 6d 20 30 20 74 |g with (from 0 t| 00002ab0 6f 20 31 35 29 20 61 6e 64 20 70 72 69 6e 74 73 |o 15) and prints| 00002ac0 0d 69 74 73 20 6e 75 6d 62 65 72 20 69 6e 20 48 |.its number in H| 00002ad0 65 78 20 28 30 2d 46 29 2e 20 20 57 65 20 75 73 |ex (0-F). We us| 00002ae0 65 20 61 6e 20 61 64 64 72 65 73 73 20 63 61 6c |e an address cal| 00002af0 6c 65 64 0d 27 72 6f 6d 6e 75 6d 62 65 72 27 20 |led.'romnumber' | 00002b00 74 6f 20 73 74 6f 72 65 20 74 68 65 20 6e 75 6d |to store the num| 00002b10 62 65 72 20 63 75 72 72 65 6e 74 6c 79 20 62 65 |ber currently be| 00002b20 69 6e 67 20 70 72 6f 63 65 73 73 65 64 2e 20 0d |ing processed. .| 00002b30 28 48 65 6e 63 65 20 73 65 74 74 69 6e 67 20 69 |(Hence setting i| 00002b40 74 20 74 6f 20 7a 65 72 6f 20 69 6e 20 6c 69 6e |t to zero in lin| 00002b50 65 20 33 31 30 2e 20 20 54 68 69 73 20 6d 61 6b |e 310. This mak| 00002b60 65 73 20 75 73 65 20 6f 66 0d 73 65 74 74 69 6e |es use of.settin| 00002b70 67 20 58 20 74 6f 20 7a 65 72 6f 20 62 65 66 6f |g X to zero befo| 00002b80 72 65 20 70 72 69 6e 74 69 6e 67 20 6f 75 74 20 |re printing out | 00002b90 74 68 65 20 68 65 61 64 69 6e 67 20 61 6e 64 20 |the heading and | 00002ba0 73 61 76 65 73 0d 61 20 63 6f 75 70 6c 65 20 6f |saves.a couple o| 00002bb0 66 20 62 79 74 65 73 2e 29 0d 0d 54 68 65 20 73 |f bytes.)..The s| 00002bc0 75 62 72 6f 75 74 69 6e 65 20 69 73 20 69 6e 20 |ubroutine is in | 00002bd0 6c 69 6e 65 73 20 31 30 36 30 2d 31 31 38 30 20 |lines 1060-1180 | 00002be0 61 6e 64 20 6d 61 6b 65 73 20 75 73 65 20 6f 66 |and makes use of| 00002bf0 20 74 68 65 0d 74 72 69 63 6b 20 77 69 74 68 20 | the.trick with | 00002c00 62 69 6e 61 72 79 20 63 6f 64 65 64 20 64 65 63 |binary coded dec| 00002c10 69 6d 61 6c 20 49 20 65 78 70 6c 61 69 6e 65 64 |imal I explained| 00002c20 20 69 6e 20 6d 6f 64 75 6c 65 20 36 2e 20 20 59 | in module 6. Y| 00002c30 0d 69 73 20 73 65 74 20 74 6f 20 74 68 65 20 63 |.is set to the c| 00002c40 75 72 72 65 6e 74 20 52 4f 4d 20 6e 75 6d 62 65 |urrent ROM numbe| 00002c50 72 20 64 75 72 69 6e 67 20 74 68 65 20 72 6f 75 |r during the rou| 00002c60 74 69 6e 65 2e 0d 0d 49 6e 20 6c 69 6e 65 20 34 |tine...In line 4| 00002c70 34 30 20 77 65 20 72 65 61 64 20 74 68 65 20 52 |40 we read the R| 00002c80 4f 4d 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 62 |OM information b| 00002c90 79 74 65 20 66 6f 72 20 74 68 65 20 63 75 72 72 |yte for the curr| 00002ca0 65 6e 74 0d 52 4f 4d 2e 20 20 49 66 20 74 68 69 |ent.ROM. If thi| 00002cb0 73 20 69 73 20 7a 65 72 6f 20 74 68 65 6e 20 74 |s is zero then t| 00002cc0 68 65 72 65 20 69 73 20 6e 6f 74 20 61 20 70 72 |here is not a pr| 00002cd0 6f 70 65 72 6c 79 20 66 6f 72 6d 61 74 74 65 64 |operly formatted| 00002ce0 0d 52 4f 4d 20 69 6e 20 74 68 61 74 20 73 6f 63 |.ROM in that soc| 00002cf0 6b 65 74 20 73 6f 20 77 65 20 63 61 6e 20 69 67 |ket so we can ig| 00002d00 6e 6f 72 65 20 69 74 2e 20 20 48 65 6e 63 65 20 |nore it. Hence | 00002d10 74 68 65 20 63 6f 64 65 20 68 65 72 65 0d 42 45 |the code here.BE| 00002d20 51 73 20 74 6f 20 61 20 6c 61 62 65 6c 20 77 68 |Qs to a label wh| 00002d30 65 72 65 20 77 65 20 68 61 76 65 20 66 69 6e 69 |ere we have fini| 00002d40 73 68 65 64 20 77 69 74 68 20 74 68 61 74 20 70 |shed with that p| 00002d50 61 72 74 69 63 75 6c 61 72 0d 52 4f 4d 2e 20 20 |articular.ROM. | 00002d60 49 66 20 74 68 65 20 52 4f 4d 20 69 6e 66 6f 20 |If the ROM info | 00002d70 62 79 74 65 20 69 73 20 6e 6f 74 20 7a 65 72 6f |byte is not zero| 00002d80 20 77 65 20 73 61 76 65 20 69 74 20 61 6e 64 20 | we save it and | 00002d90 67 6f 20 74 6f 0d 61 20 73 75 62 72 6f 75 74 69 |go to.a subrouti| 00002da0 6e 65 20 61 74 20 73 65 72 76 5f 6f 72 5f 6c 61 |ne at serv_or_la| 00002db0 6e 67 20 77 68 69 63 68 20 63 68 65 63 6b 73 20 |ng which checks | 00002dc0 74 6f 20 73 65 65 20 69 66 20 74 68 69 73 20 52 |to see if this R| 00002dd0 4f 4d 0d 68 61 73 20 61 20 73 65 72 76 69 63 65 |OM.has a service| 00002de0 20 61 6e 64 2f 6f 72 20 6c 61 6e 67 75 61 67 65 | and/or language| 00002df0 20 65 6e 74 72 79 20 70 6f 69 6e 74 2e 0d 0d 42 | entry point...B| 00002e00 61 73 69 63 61 6c 6c 79 20 69 66 20 61 20 52 4f |asically if a RO| 00002e10 4d 20 68 61 73 20 61 20 6c 61 6e 67 75 61 67 65 |M has a language| 00002e20 20 65 6e 74 72 79 20 70 6f 69 6e 74 20 69 74 20 | entry point it | 00002e30 77 69 6c 6c 20 72 75 6e 20 61 73 0d 61 20 6c 61 |will run as.a la| 00002e40 6e 67 75 61 67 65 2e 20 20 45 78 61 6d 70 6c 65 |nguage. Example| 00002e50 73 20 61 72 65 20 56 49 45 57 2c 20 42 41 53 49 |s are VIEW, BASI| 00002e60 43 2c 20 42 43 50 4c 2c 20 55 4c 54 52 41 43 41 |C, BCPL, ULTRACA| 00002e70 4c 43 2e 20 20 41 0d 73 65 72 76 69 63 65 20 65 |LC. A.service e| 00002e80 6e 74 72 79 20 70 6f 69 6e 74 20 65 6e 61 62 6c |ntry point enabl| 00002e90 65 73 20 74 68 65 20 52 4f 4d 20 74 6f 20 72 65 |es the ROM to re| 00002ea0 61 63 74 20 74 6f 20 2a 20 63 6f 6d 6d 61 6e 64 |act to * command| 00002eb0 73 2c 0d 69 6e 63 6c 75 64 69 6e 67 20 74 68 65 |s,.including the| 00002ec0 20 6f 6e 65 20 74 6f 20 73 65 6c 65 63 74 20 69 | one to select i| 00002ed0 74 73 65 6c 66 2e 20 20 45 76 65 72 79 20 52 4f |tself. Every RO| 00002ee0 4d 20 68 61 73 20 61 20 73 65 72 76 69 63 65 0d |M has a service.| 00002ef0 65 6e 74 72 79 20 70 6f 69 6e 74 20 65 78 63 65 |entry point exce| 00002f00 70 74 20 42 41 53 49 43 2e 20 20 54 68 65 20 63 |pt BASIC. The c| 00002f10 6f 6d 6d 61 6e 64 20 2a 42 41 53 49 43 20 69 73 |ommand *BASIC is| 00002f20 20 61 63 74 75 61 6c 6c 79 0d 70 61 72 74 20 6f | actually.part o| 00002f30 66 20 74 68 65 20 6f 70 65 72 61 74 69 6e 67 20 |f the operating | 00002f40 73 79 73 74 65 6d 2e 20 20 44 65 74 61 69 6c 73 |system. Details| 00002f50 20 6f 66 20 61 6c 6c 20 74 68 69 73 20 69 73 20 | of all this is | 00002f60 69 6e 20 74 68 65 0d 41 64 76 61 6e 63 65 64 20 |in the.Advanced | 00002f70 47 75 69 64 65 73 20 6f 66 20 63 6f 75 72 73 65 |Guides of course| 00002f80 2e 0d 0d 54 68 69 73 20 73 75 62 72 6f 75 74 69 |...This subrouti| 00002f90 6e 65 20 63 68 65 63 6b 73 20 74 6f 20 73 65 65 |ne checks to see| 00002fa0 20 69 66 20 62 69 74 20 36 20 69 73 20 73 65 74 | if bit 6 is set| 00002fb0 20 28 64 65 6e 6f 74 69 6e 67 20 61 0d 6c 61 6e | (denoting a.lan| 00002fc0 67 75 61 67 65 20 65 6e 74 72 79 20 70 6f 69 6e |guage entry poin| 00002fd0 74 29 20 6f 72 20 62 69 74 20 37 20 28 64 65 6e |t) or bit 7 (den| 00002fe0 6f 74 69 6e 67 20 61 20 73 65 72 76 69 63 65 20 |oting a service | 00002ff0 65 6e 74 72 79 0d 70 6f 69 6e 74 29 20 61 6e 64 |entry.point) and| 00003000 20 70 72 69 6e 74 73 20 61 6e 20 4c 20 6f 72 20 | prints an L or | 00003010 53 20 61 63 63 6f 72 64 69 6e 67 6c 79 2e 20 20 |S accordingly. | 00003020 54 68 69 73 20 63 68 65 63 6b 20 69 73 20 64 6f |This check is do| 00003030 6e 65 0d 75 73 69 6e 67 20 74 68 65 20 42 49 54 |ne.using the BIT| 00003040 20 6f 70 65 72 61 74 69 6f 6e 20 61 73 20 64 65 | operation as de| 00003050 73 63 72 69 62 65 64 20 69 6e 20 74 68 65 20 6c |scribed in the l| 00003060 61 73 74 20 6d 6f 64 75 6c 65 2e 0d 0d 46 72 6f |ast module...Fro| 00003070 6d 20 6c 69 6e 65 20 35 33 30 20 69 73 20 74 68 |m line 530 is th| 00003080 65 20 6d 61 69 6e 20 73 65 63 74 69 6f 6e 20 6f |e main section o| 00003090 66 20 74 68 65 20 72 6f 75 74 69 6e 65 2e 20 20 |f the routine. | 000030a0 4e 6f 77 20 74 68 69 73 0d 64 69 66 66 65 72 73 |Now this.differs| 000030b0 20 66 72 6f 6d 20 74 68 65 20 73 74 61 6e 64 61 | from the standa| 000030c0 72 64 20 52 4f 4d 20 6c 69 73 74 69 6e 67 20 72 |rd ROM listing r| 000030d0 6f 75 74 69 6e 65 20 69 6e 20 74 68 61 74 20 69 |outine in that i| 000030e0 74 0d 70 72 69 6e 74 73 20 6f 75 74 20 61 6c 6c |t.prints out all| 000030f0 20 74 68 65 20 52 4f 4d 20 68 65 61 64 65 72 2e | the ROM header.| 00003100 20 20 54 68 69 73 20 65 6e 61 62 6c 65 73 20 79 | This enables y| 00003110 6f 75 20 74 6f 20 73 65 65 20 77 68 61 74 0d 74 |ou to see what.t| 00003120 68 65 20 63 6f 70 79 72 69 67 68 74 20 79 65 61 |he copyright yea| 00003130 72 20 6f 66 20 79 6f 75 72 20 42 41 53 49 43 20 |r of your BASIC | 00003140 69 73 20 66 6f 72 20 65 78 61 6d 70 6c 65 20 28 |is for example (| 00003150 49 20 68 61 76 65 20 33 0d 76 65 72 73 69 6f 6e |I have 3.version| 00003160 73 20 6f 66 20 42 42 43 20 42 41 53 49 43 20 69 |s of BBC BASIC i| 00003170 6e 20 6d 79 20 6d 61 63 68 69 6e 65 29 2e 20 20 |n my machine). | 00003180 54 68 65 73 65 20 68 65 61 64 65 72 73 20 63 61 |These headers ca| 00003190 6e 20 62 65 0d 6c 6f 6e 67 20 61 6e 64 20 61 20 |n be.long and a | 000031a0 6c 69 6e 65 20 6c 65 6e 67 74 68 20 6f 66 20 37 |line length of 7| 000031b0 30 2c 20 73 65 74 20 69 6e 20 6c 69 6e 65 20 31 |0, set in line 1| 000031c0 33 30 2c 20 69 73 20 66 69 6e 65 20 66 6f 72 0d |30, is fine for.| 000031d0 38 30 20 63 6f 6c 75 6d 6e 20 6d 6f 64 65 73 2e |80 column modes.| 000031e0 20 20 49 66 20 79 6f 75 20 77 61 6e 74 20 74 6f | If you want to| 000031f0 20 75 73 65 20 74 68 65 20 72 6f 75 74 69 6e 65 | use the routine| 00003200 20 69 6e 20 61 20 34 30 0d 63 6f 6c 75 6d 6e 20 | in a 40.column | 00003210 6d 6f 64 65 20 28 6c 69 6b 65 20 4d 6f 64 65 20 |mode (like Mode | 00003220 37 29 20 74 68 65 6e 20 63 68 61 6e 67 65 20 6c |7) then change l| 00003230 69 6e 65 5f 6c 65 6e 67 74 68 20 74 6f 20 33 30 |ine_length to 30| 00003240 2e 0d 0d 41 66 74 65 72 20 73 65 74 74 69 6e 67 |...After setting| 00003250 20 74 68 65 20 63 6f 75 6e 74 65 72 73 20 66 6f | the counters fo| 00003260 72 20 7a 65 72 6f 73 20 61 6e 64 20 6c 65 74 74 |r zeros and lett| 00003270 65 72 73 20 70 72 69 6e 74 65 64 20 74 6f 0d 7a |ers printed to.z| 00003280 65 72 6f 20 77 65 20 65 6e 74 65 72 20 74 68 65 |ero we enter the| 00003290 20 6d 61 69 6e 20 6c 6f 6f 70 2e 20 20 49 6e 20 | main loop. In | 000032a0 74 68 65 20 6c 6f 6f 70 20 77 65 20 75 73 65 20 |the loop we use | 000032b0 4f 53 52 44 52 4d 20 74 6f 0d 67 65 74 20 74 68 |OSRDRM to.get th| 000032c0 65 20 62 79 74 65 73 20 66 72 6f 6d 20 74 68 65 |e bytes from the| 000032d0 20 68 65 61 64 65 72 20 6f 6e 65 20 61 74 20 61 | header one at a| 000032e0 20 74 69 6d 65 2e 20 20 54 68 65 20 68 65 61 64 | time. The head| 000032f0 65 72 0d 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 77 |er.information w| 00003300 65 20 77 61 6e 74 20 74 6f 20 72 65 61 64 20 73 |e want to read s| 00003310 74 61 72 74 73 20 61 74 20 26 38 30 30 39 20 73 |tarts at &8009 s| 00003320 6f 20 77 65 20 61 64 64 20 39 20 74 6f 0d 74 68 |o we add 9 to.th| 00003330 65 20 6c 65 74 74 65 72 20 63 6f 75 6e 74 65 72 |e letter counter| 00003340 20 61 6e 64 20 74 68 65 6e 20 69 6e 76 6f 6b 65 | and then invoke| 00003350 20 4f 53 52 44 52 4d 20 61 73 20 64 65 73 63 72 | OSRDRM as descr| 00003360 69 62 65 64 0d 65 61 72 6c 69 65 72 2e 0d 0d 4f |ibed.earlier...O| 00003370 6e 20 65 78 69 74 20 66 72 6f 6d 20 4f 53 52 44 |n exit from OSRD| 00003380 52 4d 20 77 65 20 68 61 76 65 20 74 68 65 20 62 |RM we have the b| 00003390 79 74 65 20 72 65 61 64 20 69 6e 20 74 68 65 20 |yte read in the | 000033a0 61 63 63 75 6d 75 6c 61 74 6f 72 0d 61 6e 64 20 |accumulator.and | 000033b0 77 65 20 63 61 6c 6c 20 61 20 73 75 62 72 6f 75 |we call a subrou| 000033c0 74 69 6e 65 20 61 74 20 61 64 64 72 65 73 73 20 |tine at address | 000033d0 27 74 65 73 74 27 2e 20 20 54 68 69 73 20 73 75 |'test'. This su| 000033e0 62 72 6f 75 74 69 6e 65 0d 63 68 65 63 6b 73 20 |broutine.checks | 000033f0 6f 75 74 20 74 68 65 20 62 79 74 65 2c 20 70 72 |out the byte, pr| 00003400 69 6e 74 73 20 69 74 20 69 66 20 69 74 20 69 73 |ints it if it is| 00003410 20 76 61 6c 69 64 2c 20 61 6e 64 20 65 78 69 74 | valid, and exit| 00003420 73 0d 77 69 74 68 20 74 68 65 20 63 61 72 72 79 |s.with the carry| 00003430 20 66 6c 61 67 20 63 6c 65 61 72 20 69 66 20 33 | flag clear if 3| 00003440 20 6e 75 6c 6c 73 20 28 7a 65 72 6f 73 29 20 68 | nulls (zeros) h| 00003450 61 76 65 20 62 65 65 6e 0d 63 6f 75 6e 74 65 64 |ave been.counted| 00003460 20 66 72 6f 6d 20 74 68 65 20 68 65 61 64 65 72 | from the header| 00003470 20 61 6e 64 20 77 69 74 68 20 74 68 65 20 63 68 | and with the ch| 00003480 61 72 61 63 74 65 72 20 74 6f 20 70 72 69 6e 74 |aracter to print| 00003490 20 69 6e 0d 74 68 65 20 61 63 63 75 6d 75 6c 61 | in.the accumula| 000034a0 74 6f 72 2e 20 20 41 66 74 65 72 20 33 20 6e 75 |tor. After 3 nu| 000034b0 6c 6c 73 20 74 68 65 72 65 20 73 68 6f 75 6c 64 |lls there should| 000034c0 20 62 65 20 6e 6f 20 6d 6f 72 65 0d 68 75 6d 61 | be no more.huma| 000034d0 6e 20 72 65 61 64 61 62 6c 65 20 69 6e 66 6f 72 |n readable infor| 000034e0 6d 61 74 69 6f 6e 20 6c 65 66 74 20 69 6e 20 74 |mation left in t| 000034f0 68 65 20 68 65 61 64 65 72 2e 20 20 54 68 69 73 |he header. This| 00003500 0d 73 75 62 72 6f 75 74 69 6e 65 20 73 74 61 72 |.subroutine star| 00003510 74 73 20 61 74 20 6c 69 6e 65 20 31 36 37 30 2e |ts at line 1670.| 00003520 0d 0d 57 68 79 20 64 6f 20 49 20 75 73 65 20 74 |..Why do I use t| 00003530 68 65 20 63 61 72 72 79 20 66 6c 61 67 20 74 6f |he carry flag to| 00003540 20 73 61 79 20 74 68 61 74 20 77 65 20 68 61 76 | say that we hav| 00003550 65 20 66 69 6e 69 73 68 65 64 20 74 68 65 0d 68 |e finished the.h| 00003560 65 61 64 65 72 3f 20 20 54 77 6f 20 72 65 61 73 |eader? Two reas| 00003570 6f 6e 73 2e 20 20 49 20 75 73 65 20 61 20 66 6c |ons. I use a fl| 00003580 61 67 20 61 74 20 61 6c 6c 20 62 65 63 61 75 73 |ag at all becaus| 00003590 65 20 77 65 20 63 61 6e 6e 6f 74 0d 62 72 61 6e |e we cannot.bran| 000035a0 63 68 20 64 69 72 65 63 74 6c 79 20 6f 75 74 20 |ch directly out | 000035b0 6f 66 20 61 20 73 75 62 72 6f 75 74 69 6e 65 20 |of a subroutine | 000035c0 77 69 74 68 6f 75 74 20 75 6e 62 61 6c 61 6e 63 |without unbalanc| 000035d0 69 6e 67 20 74 68 65 0d 73 74 61 63 6b 2e 20 20 |ing the.stack. | 000035e0 57 68 65 6e 20 79 6f 75 20 65 6e 74 65 72 20 61 |When you enter a| 000035f0 20 73 75 62 72 6f 75 74 69 6e 65 20 74 68 65 20 | subroutine the | 00003600 6d 69 63 72 6f 70 72 6f 63 65 73 73 6f 72 20 70 |microprocessor p| 00003610 75 74 73 0d 74 68 65 20 72 65 74 75 72 6e 20 61 |uts.the return a| 00003620 64 64 72 65 73 73 20 6f 6e 20 74 68 65 20 73 74 |ddress on the st| 00003630 61 63 6b 20 72 65 61 64 79 20 74 6f 20 62 65 20 |ack ready to be | 00003640 70 75 6c 6c 65 64 20 6f 66 66 20 77 68 65 6e 0d |pulled off when.| 00003650 61 6e 20 52 54 53 20 69 73 20 72 65 61 63 68 65 |an RTS is reache| 00003660 64 2e 20 20 49 66 20 79 6f 75 20 4a 4d 50 20 6f |d. If you JMP o| 00003670 72 20 42 52 61 6e 63 68 20 62 61 63 6b 20 69 6e |r BRanch back in| 00003680 73 74 65 61 64 20 74 68 61 74 0d 61 64 64 72 65 |stead that.addre| 00003690 73 73 20 72 65 6d 61 69 6e 73 20 6f 6e 20 74 68 |ss remains on th| 000036a0 65 20 73 74 61 63 6b 20 61 6e 64 20 6d 61 79 20 |e stack and may | 000036b0 63 6f 72 72 75 70 74 20 61 6e 79 20 73 74 61 63 |corrupt any stac| 000036c0 6b 0d 73 74 6f 72 61 67 65 20 79 6f 75 20 61 72 |k.storage you ar| 000036d0 65 20 75 73 69 6e 67 2e 20 20 49 6e 20 74 68 69 |e using. In thi| 000036e0 73 20 70 72 6f 67 72 61 6d 20 77 65 20 61 72 65 |s program we are| 000036f0 20 75 73 69 6e 67 20 74 68 65 0d 73 74 61 63 6b | using the.stack| 00003700 20 66 6f 72 20 73 74 6f 72 61 67 65 20 64 75 72 | for storage dur| 00003710 69 6e 67 20 74 68 65 20 77 68 6f 6c 65 20 72 6f |ing the whole ro| 00003720 75 74 69 6e 65 2e 0d 0d 54 68 65 20 63 61 72 72 |utine...The carr| 00003730 79 20 66 6c 61 67 20 69 73 20 75 73 65 64 20 62 |y flag is used b| 00003740 65 63 61 75 73 65 20 69 74 20 69 73 20 65 61 73 |ecause it is eas| 00003750 69 6c 79 20 73 65 74 20 6f 72 20 63 6c 65 61 72 |ily set or clear| 00003760 65 64 0d 28 53 45 43 20 6f 72 20 43 4c 43 29 2c |ed.(SEC or CLC),| 00003770 20 77 68 65 72 65 61 73 20 74 68 65 20 6f 76 65 | whereas the ove| 00003780 72 66 6c 6f 77 20 66 6c 61 67 20 63 61 6e 6e 6f |rflow flag canno| 00003790 74 20 62 65 20 64 69 72 65 63 74 6c 79 0d 61 66 |t be directly.af| 000037a0 66 65 63 74 65 64 20 6c 69 6b 65 20 74 68 69 73 |fected like this| 000037b0 2e 20 20 41 6c 73 6f 20 74 68 65 20 63 61 72 72 |. Also the carr| 000037c0 79 20 66 6c 61 67 20 69 73 20 6e 6f 74 20 61 66 |y flag is not af| 000037d0 66 65 63 74 65 64 20 62 79 0d 61 20 6c 6f 61 64 |fected by.a load| 000037e0 20 6f 72 20 73 61 76 65 20 63 6f 6d 6d 61 6e 64 | or save command| 000037f0 20 6c 69 6b 65 20 74 68 65 20 7a 65 72 6f 20 66 | like the zero f| 00003800 6c 61 67 20 77 6f 75 6c 64 20 62 65 2e 20 20 49 |lag would be. I| 00003810 20 68 61 76 65 0d 75 73 65 64 20 69 74 20 74 68 | have.used it th| 00003820 69 73 20 70 61 72 74 69 63 75 6c 61 72 20 77 61 |is particular wa| 00003830 79 20 61 72 6f 75 6e 64 20 74 6f 20 73 61 76 65 |y around to save| 00003840 20 61 20 63 6f 75 70 6c 65 20 6f 66 20 62 79 74 | a couple of byt| 00003850 65 73 0d 62 65 63 61 75 73 65 20 69 74 20 77 69 |es.because it wi| 00003860 6c 6c 20 61 6c 77 61 79 73 20 62 65 20 63 6c 65 |ll always be cle| 00003870 61 72 20 61 74 20 6c 69 6e 65 20 31 37 35 30 2e |ar at line 1750.| 00003880 0d 0d 44 75 72 69 6e 67 20 74 68 65 20 74 65 73 |..During the tes| 00003890 74 20 73 75 62 72 6f 75 74 69 6e 65 20 61 6e 79 |t subroutine any| 000038a0 20 63 6f 6e 74 72 6f 6c 20 63 6f 64 65 73 20 6f | control codes o| 000038b0 72 20 62 79 74 65 73 20 6f 76 65 72 0d 31 32 36 |r bytes over.126| 000038c0 20 61 72 65 20 72 65 70 6c 61 63 65 64 20 77 69 | are replaced wi| 000038d0 74 68 20 73 70 61 63 65 73 2e 0d 0d 4f 6e 20 65 |th spaces...On e| 000038e0 78 69 74 20 66 72 6f 6d 20 74 65 73 74 20 77 65 |xit from test we| 000038f0 20 66 69 6e 69 73 68 20 77 69 74 68 20 74 68 69 | finish with thi| 00003900 73 20 52 4f 4d 20 69 66 20 74 68 65 20 63 61 72 |s ROM if the car| 00003910 72 79 20 66 6c 61 67 0d 69 73 20 63 6c 65 61 72 |ry flag.is clear| 00003920 20 28 61 73 20 70 65 72 20 6c 69 6e 65 20 36 38 | (as per line 68| 00003930 30 29 2e 20 20 49 66 20 6e 6f 74 20 77 65 20 70 |0). If not we p| 00003940 72 69 6e 74 20 74 68 65 20 63 68 61 72 61 63 74 |rint the charact| 00003950 65 72 2c 0d 69 6e 63 72 65 61 73 65 20 74 68 65 |er,.increase the| 00003960 20 6c 65 74 74 65 72 20 63 6f 75 6e 74 65 72 20 | letter counter | 00003970 61 6e 64 20 63 68 65 63 6b 20 69 66 20 77 65 20 |and check if we | 00003980 61 72 65 20 6e 6f 77 20 6f 76 65 72 20 6f 75 72 |are now over our| 00003990 0d 61 6c 6c 6f 74 74 65 64 20 6c 65 6e 67 74 68 |.allotted length| 000039a0 2e 20 20 49 66 20 77 65 20 61 72 65 20 77 65 20 |. If we are we | 000039b0 67 6f 20 6f 6e 20 74 6f 20 74 68 65 20 6e 65 78 |go on to the nex| 000039c0 74 20 52 4f 4d 2c 20 69 66 20 6e 6f 74 0d 77 65 |t ROM, if not.we| 000039d0 20 6c 6f 6f 6b 20 61 74 20 74 68 65 20 6e 65 78 | look at the nex| 000039e0 74 20 6c 65 74 74 65 72 2e 0d 0d 4c 69 6e 65 20 |t letter...Line | 000039f0 37 35 30 20 69 73 20 74 68 65 20 61 64 64 72 65 |750 is the addre| 00003a00 73 73 20 27 72 6f 6d 5f 66 69 6e 69 73 68 65 64 |ss 'rom_finished| 00003a10 27 20 77 68 65 72 65 20 77 65 20 67 6f 20 77 68 |' where we go wh| 00003a20 65 6e 20 65 61 63 68 0d 52 4f 4d 20 68 61 73 20 |en each.ROM has | 00003a30 62 65 65 6e 20 72 65 61 64 2e 20 20 54 68 65 20 |been read. The | 00003a40 52 4f 4d 20 63 6f 75 6e 74 65 72 20 69 73 20 69 |ROM counter is i| 00003a50 6e 63 72 65 6d 65 6e 74 65 64 20 61 6e 64 20 77 |ncremented and w| 00003a60 65 0d 63 68 65 63 6b 20 74 6f 20 73 65 65 20 69 |e.check to see i| 00003a70 66 20 77 65 20 68 61 76 65 20 72 65 61 63 68 65 |f we have reache| 00003a80 64 20 31 36 20 61 6e 64 20 74 68 65 20 65 6e 64 |d 16 and the end| 00003a90 2c 20 69 66 20 6e 6f 74 20 72 6f 75 6e 64 0d 77 |, if not round.w| 00003aa0 65 20 67 6f 20 61 67 61 69 6e 2e 0d 0d 54 68 65 |e go again...The| 00003ab0 20 72 6f 75 74 69 6e 65 73 20 65 78 69 74 20 69 | routines exit i| 00003ac0 73 20 61 74 20 6c 69 6e 65 20 38 33 30 20 61 6e |s at line 830 an| 00003ad0 64 20 6e 6f 74 69 63 65 20 74 68 61 74 20 77 65 |d notice that we| 00003ae0 20 72 65 73 74 6f 72 65 0d 74 68 65 20 7a 65 72 | restore.the zer| 00003af0 6f 20 70 61 67 65 20 62 79 74 65 73 20 69 6e 20 |o page bytes in | 00003b00 72 65 76 65 72 73 65 20 6f 72 64 65 72 2e 20 20 |reverse order. | 00003b10 54 68 69 73 20 69 73 20 62 65 63 61 75 73 65 20 |This is because | 00003b20 74 68 65 0d 73 74 61 63 6b 20 6f 70 65 72 61 74 |the.stack operat| 00003b30 65 73 20 6c 61 73 74 2d 69 6e 2d 66 69 72 73 74 |es last-in-first| 00003b40 2d 6f 75 74 20 73 6f 20 79 6f 75 20 72 65 61 64 |-out so you read| 00003b50 20 6f 75 74 20 69 6e 20 74 68 65 0d 72 65 76 65 | out in the.reve| 00003b60 72 73 65 20 6f 72 64 65 72 20 74 6f 20 68 6f 77 |rse order to how| 00003b70 20 79 6f 75 20 70 75 74 20 69 6e 2e 0d 0d 54 68 | you put in...Th| 00003b80 65 20 72 65 73 74 20 6f 66 20 74 68 65 20 61 73 |e rest of the as| 00003b90 73 65 6d 62 6c 65 72 20 63 6f 64 65 20 63 6f 6e |sembler code con| 00003ba0 74 61 69 6e 73 20 74 68 65 20 73 75 62 72 6f 75 |tains the subrou| 00003bb0 74 69 6e 65 73 20 61 6e 64 0d 76 61 72 69 61 62 |tines and.variab| 00003bc0 6c 65 20 61 64 64 72 65 73 73 65 73 2e 20 20 54 |le addresses. T| 00003bd0 68 65 20 66 69 6e 61 6c 20 62 69 74 20 6f 66 20 |he final bit of | 00003be0 42 41 53 49 43 20 70 72 69 6e 74 73 20 6f 75 74 |BASIC prints out| 00003bf0 20 61 0d 6c 69 6e 65 20 79 6f 75 20 63 61 6e 20 | a.line you can | 00003c00 63 6f 70 79 20 77 69 74 68 20 74 68 65 20 63 75 |copy with the cu| 00003c10 72 73 6f 72 20 6b 65 79 73 20 74 6f 20 73 61 76 |rsor keys to sav| 00003c20 65 20 74 68 65 20 61 73 73 65 6d 62 6c 65 64 0d |e the assembled.| 00003c30 63 6f 64 65 2e 20 20 4e 6f 74 69 63 65 20 74 68 |code. Notice th| 00003c40 61 74 20 77 65 20 73 65 74 20 74 68 65 20 74 6f |at we set the to| 00003c50 70 20 31 36 20 62 69 74 73 20 6f 66 20 61 20 33 |p 16 bits of a 3| 00003c60 32 20 62 69 74 0d 61 64 64 72 65 73 73 20 74 6f |2 bit.address to| 00003c70 20 74 65 6c 6c 20 74 68 65 20 66 69 6c 69 6e 67 | tell the filing| 00003c80 20 73 79 73 74 65 6d 20 74 68 61 74 20 77 65 20 | system that we | 00003c90 61 72 65 20 69 6e 20 74 68 65 20 49 2f 4f 0d 70 |are in the I/O.p| 00003ca0 72 6f 63 65 73 73 6f 72 20 61 6e 64 20 77 61 6e |rocessor and wan| 00003cb0 74 20 74 68 65 20 63 6f 64 65 20 74 6f 20 72 75 |t the code to ru| 00003cc0 6e 20 74 68 65 72 65 2e 0d 0d 48 65 72 65 20 69 |n there...Here i| 00003cd0 73 20 74 68 65 20 6f 75 74 70 75 74 20 6f 66 20 |s the output of | 00003ce0 74 68 65 20 72 6f 75 74 69 6e 65 20 77 68 65 6e |the routine when| 00003cf0 20 49 20 72 61 6e 20 69 74 20 69 6e 20 6d 79 0d | I ran it in my.| 00003d00 6d 61 63 68 69 6e 65 2e 20 20 4e 6f 74 65 20 74 |machine. Note t| 00003d10 68 61 74 20 73 6f 63 6b 65 74 20 32 20 69 73 20 |hat socket 2 is | 00003d20 65 6d 70 74 79 20 61 6e 64 20 73 6f 63 6b 65 74 |empty and socket| 00003d30 20 46 20 68 61 73 20 52 41 4d 0d 69 6e 20 69 74 | F has RAM.in it| 00003d40 20 62 75 74 20 74 68 61 74 20 52 41 4d 20 63 6f | but that RAM co| 00003d50 6e 74 61 69 6e 65 64 20 6f 6e 6c 79 20 72 61 6e |ntained only ran| 00003d60 64 6f 6d 20 62 79 74 65 73 2e 20 20 4c 69 6e 65 |dom bytes. Line| 00003d70 73 20 35 20 61 6e 64 0d 43 20 68 61 76 65 20 62 |s 5 and.C have b| 00003d80 65 65 6e 20 74 72 75 6e 63 61 74 65 64 20 62 79 |een truncated by| 00003d90 20 6d 65 20 74 6f 20 6d 61 6b 65 20 74 68 65 6d | me to make them| 00003da0 20 66 69 74 20 68 65 72 65 2e 20 20 41 6c 73 6f | fit here. Also| 00003db0 0d 6e 6f 74 65 20 74 68 61 74 20 69 6e 20 73 6f |.note that in so| 00003dc0 63 6b 65 74 20 38 20 69 73 20 74 68 65 20 44 4e |cket 8 is the DN| 00003dd0 46 53 20 77 68 69 63 68 20 64 6f 65 73 20 6e 6f |FS which does no| 00003de0 74 20 63 6f 6e 74 61 69 6e 20 61 0d 70 72 6f 70 |t contain a.prop| 00003df0 65 72 20 63 6f 70 79 72 69 67 68 74 20 6d 65 73 |er copyright mes| 00003e00 73 61 67 65 20 69 6e 20 69 74 73 20 68 65 61 64 |sage in its head| 00003e10 65 72 2c 20 68 65 6e 63 65 20 74 68 65 20 67 69 |er, hence the gi| 00003e20 62 62 65 72 69 73 68 2e 20 0d 28 54 6f 20 73 61 |bberish. .(To sa| 00003e30 76 65 20 79 6f 75 20 61 73 6b 69 6e 67 2c 20 4d |ve you asking, M| 00003e40 69 63 72 6f 46 61 78 20 69 73 20 61 20 42 42 43 |icroFax is a BBC| 00003e50 20 63 68 69 70 20 74 6f 20 65 6e 61 62 6c 65 20 | chip to enable | 00003e60 6d 65 20 74 6f 0d 66 6f 72 6d 61 74 20 70 61 67 |me to.format pag| 00003e70 65 73 20 66 6f 72 20 43 45 45 46 41 58 2e 29 0d |es for CEEFAX.).| 00003e80 0d 0d 53 69 64 65 77 61 79 73 20 52 6f 6d 73 0d |..Sideways Roms.| 00003e90 0d 30 20 28 20 53 29 20 54 45 4c 45 54 45 58 54 |.0 ( S) TELETEXT| 00003ea0 20 20 32 2e 35 30 20 20 20 28 43 29 42 42 43 20 | 2.50 (C)BBC | 00003eb0 31 39 38 36 20 0d 31 20 28 4c 20 29 20 42 41 53 |1986 .1 (L ) BAS| 00003ec0 49 43 20 20 28 43 29 31 39 38 31 20 41 63 6f 72 |IC (C)1981 Acor| 00003ed0 6e 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |n | 00003ee0 20 20 20 20 20 20 20 0d 32 20 0d 33 20 28 20 53 | .2 .3 ( S| 00003ef0 29 20 54 4f 4f 4c 4b 49 54 20 20 31 2e 32 32 20 |) TOOLKIT 1.22 | 00003f00 20 28 43 29 31 39 38 33 20 42 65 65 62 75 67 20 | (C)1983 Beebug | 00003f10 0d 34 20 28 4c 53 29 20 56 49 45 57 20 20 41 32 |.4 (LS) VIEW A2| 00003f20 2e 31 20 20 28 43 29 20 31 39 38 32 20 50 72 6f |.1 (C) 1982 Pro| 00003f30 74 65 63 68 6e 69 63 20 0d 35 20 28 20 53 29 20 |technic .5 ( S) | 00003f40 57 61 74 66 6f 72 64 20 45 6c 65 63 74 72 6f 6e |Watford Electron| 00003f50 69 63 73 20 45 50 53 4f 4e 20 4e 4c 51 20 52 4f |ics EPSON NLQ RO| 00003f60 4d 20 56 31 2e 30 20 20 28 43 29 20 57 61 74 66 |M V1.0 (C) Watf| 00003f70 6f 72 64 0d 36 20 28 4c 53 29 20 4d 4f 4e 49 54 |ord.6 (LS) MONIT| 00003f80 4f 52 20 20 32 2e 30 31 20 20 20 28 43 29 31 39 |OR 2.01 (C)19| 00003f90 38 35 20 49 53 4d 45 43 20 0d 37 20 28 4c 53 29 |85 ISMEC .7 (LS)| 00003fa0 20 53 50 45 4c 4c 43 48 45 43 4b 20 49 49 20 20 | SPELLCHECK II | 00003fb0 76 31 2e 32 30 20 20 28 43 29 31 39 38 34 20 42 |v1.20 (C)1984 B| 00003fc0 45 45 42 55 47 53 4f 46 54 20 0d 38 20 28 20 53 |EEBUGSOFT .8 ( S| 00003fd0 29 20 44 46 53 2c 4e 45 54 20 20 28 43 29 52 4f |) DFS,NET (C)RO| 00003fe0 46 46 20 20 20 20 27 31 31 31 39 45 20 20 0d 39 |FF '1119E .9| 00003ff0 20 28 4c 53 29 20 55 6c 74 72 61 63 61 6c 63 20 | (LS) Ultracalc | 00004000 20 32 20 20 28 43 29 31 39 38 34 20 54 6f 70 65 | 2 (C)1984 Tope| 00004010 78 70 72 65 73 73 20 4c 69 6d 69 74 65 64 20 0d |xpress Limited .| 00004020 41 20 28 4c 53 29 20 42 43 50 4c 20 20 37 2e 30 |A (LS) BCPL 7.0| 00004030 20 20 28 43 29 20 31 39 38 32 20 52 49 43 48 41 | (C) 1982 RICHA| 00004040 52 44 53 20 43 4f 4d 50 55 54 45 52 20 50 52 4f |RDS COMPUTER PRO| 00004050 44 55 43 54 53 20 4c 54 44 2e 20 0d 42 20 28 4c |DUCTS LTD. .B (L| 00004060 53 29 20 4d 69 63 72 6f 46 61 78 20 20 34 2e 34 |S) MicroFax 4.4| 00004070 20 20 20 28 43 29 54 2e 45 2e 4b 65 6e 6e 69 6e | (C)T.E.Kennin| 00004080 67 74 6f 6e 20 31 39 38 35 20 0d 43 20 28 20 53 |gton 1985 .C ( S| 00004090 29 20 41 4d 58 20 4d 6f 75 73 65 20 53 75 70 70 |) AMX Mouse Supp| 000040a0 6f 72 74 20 20 20 20 28 43 29 31 39 38 34 20 41 |ort (C)1984 A| 000040b0 64 76 61 6e 63 65 64 20 4d 65 6d 6f 72 79 20 53 |dvanced Memory S| 000040c0 79 73 74 65 6d 73 0d 44 20 28 4c 20 29 20 42 41 |ystems.D (L ) BA| 000040d0 53 49 43 20 20 28 43 29 31 39 38 33 20 41 63 6f |SIC (C)1983 Aco| 000040e0 72 6e 20 20 20 20 20 0d 45 20 28 4c 20 29 20 42 |rn .E (L ) B| 000040f0 41 53 49 43 20 20 28 43 29 31 39 38 32 20 41 63 |ASIC (C)1982 Ac| 00004100 6f 72 6e 20 20 20 20 20 0d 46 20 0d 0d 0d 49 20 |orn .F ...I | 00004110 68 6f 70 65 20 79 6f 75 20 77 69 6c 6c 20 62 65 |hope you will be| 00004120 20 77 6f 6e 64 65 72 69 6e 67 20 77 68 79 20 49 | wondering why I| 00004130 20 75 73 65 64 20 73 75 62 72 6f 75 74 69 6e 65 | used subroutine| 00004140 73 20 69 6e 20 74 68 69 73 0d 63 6f 64 65 20 65 |s in this.code e| 00004150 76 65 6e 20 74 68 6f 75 67 68 20 74 68 65 20 72 |ven though the r| 00004160 6f 75 74 69 6e 65 73 20 77 65 72 65 20 6f 6e 6c |outines were onl| 00004170 79 20 63 61 6c 6c 65 64 20 6f 6e 63 65 2e 20 20 |y called once. | 00004180 4d 79 0d 67 65 6e 65 72 61 6c 20 72 75 6c 65 20 |My.general rule | 00004190 69 73 20 74 6f 20 74 72 79 20 74 6f 20 77 72 69 |is to try to wri| 000041a0 74 65 20 63 6f 64 65 20 77 69 74 68 20 74 68 65 |te code with the| 000041b0 73 65 20 73 6f 72 74 20 6f 66 0d 70 72 69 6f 72 |se sort of.prior| 000041c0 69 74 69 65 73 3a 0d 0d 46 69 72 73 74 6c 79 20 |ities:..Firstly | 000041d0 74 72 79 20 74 6f 20 6d 61 6b 65 20 69 74 20 61 |try to make it a| 000041e0 73 20 73 69 6d 70 6c 65 20 61 6e 64 20 72 65 61 |s simple and rea| 000041f0 64 61 62 6c 65 20 61 73 20 70 6f 73 73 69 62 6c |dable as possibl| 00004200 65 2e 20 0d 48 65 6e 63 65 20 73 75 62 72 6f 75 |e. .Hence subrou| 00004210 74 69 6e 65 73 20 61 6e 64 20 6c 6f 74 73 20 6f |tines and lots o| 00004220 66 20 63 6f 6d 6d 65 6e 74 73 2e 20 20 49 20 6d |f comments. I m| 00004230 61 79 20 68 61 76 65 20 74 6f 0d 6d 6f 64 69 66 |ay have to.modif| 00004240 79 20 74 68 65 20 70 72 6f 67 72 61 6d 20 61 20 |y the program a | 00004250 79 65 61 72 20 6f 72 20 74 77 6f 20 6c 61 74 65 |year or two late| 00004260 72 2e 0d 0d 53 65 63 6f 6e 64 6c 79 20 61 6e 79 |r...Secondly any| 00004270 20 70 69 65 63 65 20 6f 66 20 63 6f 64 65 20 74 | piece of code t| 00004280 68 61 74 20 69 73 20 75 73 65 64 20 69 6e 20 6d |hat is used in m| 00004290 6f 72 65 20 74 68 61 6e 20 6f 6e 65 0d 70 6c 61 |ore than one.pla| 000042a0 63 65 20 73 68 6f 75 6c 64 20 62 65 20 61 20 73 |ce should be a s| 000042b0 75 62 72 6f 75 74 69 6e 65 2e 20 20 54 68 69 73 |ubroutine. This| 000042c0 20 72 65 64 75 63 65 73 20 74 68 65 20 73 69 7a | reduces the siz| 000042d0 65 20 6f 66 20 74 68 65 0d 63 6f 64 65 2e 0d 0d |e of the.code...| 000042e0 54 68 69 72 64 6c 79 20 73 75 62 72 6f 75 74 69 |Thirdly subrouti| 000042f0 6e 65 73 20 73 6c 6f 77 20 64 6f 77 6e 20 63 6f |nes slow down co| 00004300 64 65 20 62 65 63 61 75 73 65 20 6f 66 20 74 68 |de because of th| 00004310 65 20 63 61 6c 6c 69 6e 67 0d 61 6e 64 20 70 75 |e calling.and pu| 00004320 74 74 69 6e 67 20 6f 66 20 72 65 74 75 72 6e 20 |tting of return | 00004330 61 64 64 72 65 73 73 65 64 20 6f 6e 20 74 68 65 |addressed on the| 00004340 20 73 74 61 63 6b 2e 20 20 53 6f 20 69 66 20 74 | stack. So if t| 00004350 69 6d 65 20 69 73 0d 76 65 72 79 20 63 72 69 74 |ime is.very crit| 00004360 69 63 61 6c 20 74 72 79 20 74 6f 20 61 76 6f 69 |ical try to avoi| 00004370 64 20 74 68 65 6d 2e 0d 0d 54 68 65 73 65 20 74 |d them...These t| 00004380 68 72 65 65 20 74 68 69 6e 67 73 20 64 6f 20 6e |hree things do n| 00004390 6f 74 20 61 6c 77 61 79 73 20 77 6f 72 6b 20 74 |ot always work t| 000043a0 6f 77 61 72 64 73 20 74 68 65 20 73 61 6d 65 20 |owards the same | 000043b0 65 6e 64 0d 61 6e 64 20 74 68 65 72 65 20 69 73 |end.and there is| 000043c0 20 6e 6f 74 20 75 73 75 61 6c 6c 79 20 61 20 73 | not usually a s| 000043d0 69 6e 67 6c 65 20 73 6f 6c 75 74 69 6f 6e 20 74 |ingle solution t| 000043e0 6f 20 61 20 70 72 6f 67 72 61 6d 6d 69 6e 67 0d |o a programming.| 000043f0 70 72 6f 62 6c 65 6d 20 28 74 68 61 6e 6b 20 67 |problem (thank g| 00004400 6f 6f 64 6e 65 73 73 29 2e 0d 0d 41 6e 64 20 77 |oodness)...And w| 00004410 68 61 74 20 61 62 6f 75 74 20 61 20 66 6c 6f 77 |hat about a flow| 00004420 20 63 68 61 72 74 2e 20 20 57 65 6c 6c 2c 20 74 | chart. Well, t| 00004430 6f 20 62 65 20 62 72 75 74 61 6c 6c 79 20 68 6f |o be brutally ho| 00004440 6e 65 73 74 0d 74 68 65 79 20 61 72 65 20 61 6c |nest.they are al| 00004450 6d 6f 73 74 20 69 6d 70 6f 73 73 69 62 6c 65 20 |most impossible | 00004460 74 6f 20 64 6f 20 62 79 20 74 65 6c 65 73 6f 66 |to do by telesof| 00004470 74 77 61 72 65 20 73 6f 20 49 20 61 6d 0d 75 6e |tware so I am.un| 00004480 61 62 6c 65 20 74 6f 20 73 65 6e 64 20 61 6e 79 |able to send any| 00004490 20 74 6f 20 79 6f 75 2e 20 20 49 6e 20 66 61 63 | to you. In fac| 000044a0 74 20 49 20 72 61 72 65 6c 79 20 66 6c 6f 77 63 |t I rarely flowc| 000044b0 68 61 72 74 20 61 0d 63 6f 6d 70 6c 65 74 65 20 |hart a.complete | 000044c0 70 72 6f 67 72 61 6d 20 6d 79 73 65 6c 66 20 28 |program myself (| 000044d0 77 68 69 63 68 20 69 73 20 70 6f 73 73 69 62 6c |which is possibl| 000044e0 79 20 77 68 79 20 74 72 69 61 6c 20 61 6e 64 0d |y why trial and.| 000044f0 65 72 72 6f 72 20 66 65 61 74 75 72 65 20 73 6f |error feature so| 00004500 20 6d 75 63 68 20 69 6e 20 6d 79 20 77 72 69 74 | much in my writ| 00004510 69 6e 67 29 20 61 6c 74 68 6f 75 67 68 20 69 66 |ing) although if| 00004520 20 49 20 68 61 76 65 20 61 0d 74 72 69 63 6b 79 | I have a.tricky| 00004530 20 62 69 74 20 6f 66 20 6c 6f 67 69 63 20 74 6f | bit of logic to| 00004540 20 73 6f 72 74 20 6f 75 74 20 61 20 66 6c 6f 77 | sort out a flow| 00004550 20 63 68 61 72 74 20 69 73 20 76 65 72 79 20 75 | chart is very u| 00004560 73 65 66 75 6c 2e 0d 0d 54 68 61 74 27 73 20 61 |seful...That's a| 00004570 6c 6c 20 66 6f 72 20 74 68 69 73 20 6d 6f 64 75 |ll for this modu| 00004580 6c 65 2c 20 6e 65 78 74 20 74 69 6d 65 20 49 27 |le, next time I'| 00004590 6c 6c 20 6c 6f 6f 6b 20 61 74 20 65 72 72 6f 72 |ll look at error| 000045a0 73 0d 61 6e 64 20 65 78 63 65 70 74 69 6f 6e 73 |s.and exceptions| 000045b0 20 77 68 69 63 68 20 62 65 63 6f 6d 65 20 76 65 | which become ve| 000045c0 72 79 20 69 6d 70 6f 72 74 61 6e 74 20 61 73 20 |ry important as | 000045d0 73 6f 6f 6e 20 61 73 20 79 6f 75 72 0d 70 72 6f |soon as your.pro| 000045e0 67 72 61 6d 73 20 72 65 71 75 69 72 65 20 70 65 |grams require pe| 000045f0 6f 70 6c 65 20 74 6f 20 69 6e 70 75 74 20 69 6e |ople to input in| 00004600 74 6f 20 74 68 65 6d 2e 20 20 41 6c 73 6f 20 61 |to them. Also a| 00004610 20 62 72 69 65 66 0d 6f 76 65 72 76 69 65 77 20 | brief.overview | 00004620 6f 66 20 74 68 65 20 36 35 30 32 20 6d 69 63 72 |of the 6502 micr| 00004630 6f 70 72 6f 63 65 73 73 6f 72 20 63 6f 6d 6d 61 |oprocessor comma| 00004640 6e 64 73 2c 20 6f 72 20 4f 50 43 4f 44 45 53 2c |nds, or OPCODES,| 00004650 0d 77 68 69 63 68 20 79 6f 75 20 63 61 6e 20 75 |.which you can u| 00004660 73 65 20 61 73 20 61 20 72 65 66 65 72 65 6e 63 |se as a referenc| 00004670 65 2e 0d |e..| 00004673