ENGLISH ERROR MESSAGES As promised, I am going to explain how to do something practical. Have you ever wondered what a two letter error code meant? I have; many times. I solved this problem some time ago by writing the routine I am now going to present to you. Before you will be able to understand it, I will have to explain how the CoCo accesses its extra memory. The GIME chip has a device called an MMU which can switch memory into and out of the CPU's memory block. In a 128K machine, there is an 8K block which is unused (page 311 of the basic manual will confirm this). This is ideal for storing long tables such as a table of english error messages! (how convenient, eh?). The problem with switching MMU blocks around is making sure you always have the proper code in the CPU's memory block. I am not going to go into detail on this at the; you are going to have to trust me that it works. Next, we do not want to take memory away from our BASIC programs so we must find another memory location. How about at the top end of the Disk BASIC ROM area? Do not worry; this will work with both DECB2.0 and 2.1. The source code for the routine appears as follows: DF5C 00010 ORG $DF5C DF5C BD AD33 00020 ERRORS JSR >AD33 DF5F B6 C004 00030 LDA >C004 DF62 34 04 00040 PSHS B DF64 81 D7 00050 CMPA #D7 DF66 27 08 00060 BEQ ERRS01 DF68 BD D1E5 00070 JSR >D1E5 DF6B BD CA3B 00080 JSR >CA3B DF6E 20 06 00090 BRA ERRS02 DF70 BD D2D2 00100 ERRS01 JSR >D2D2 DF73 BD CAE9 00110 JSR >CAE9 DF76 35 04 00120 ERRS02 PULS B DF78 BD A7E9 00130 JSR >A7E9 DF7B BD A974 00140 JSR >A974 DF7E 0F 6F 00150 CLR <6F DF80 BD B95C 00160 JSR >B95C DF83 5C 00170 INCB DF84 B6 FFA2 00180 LDA >FFA2 DF87 34 02 00190 PSHS A DF89 86 37 00200 LDA #37 DF8B B7 FFA2 00210 STA >FFA2 DF8E 8E 4000 00220 LDX #4000 DF91 5A 00230 ERRS03 DECB DF92 27 06 00240 BEQ ERRS05 DF94 A6 80 00250 ERRS04 LDA ,X+ DF96/cy FC 00260 BPL ERRS04 DF98 20 F7 00270 BRA ERRS03 DF9A FF DFBF 00280 ERRS05 LDU #ERRBUF DF9D A6 84 00290 ERRS06 LDA ,X DF9F 84 7F 00300 ANDA #7F DFA1 A7 C0 00310 STA ,U+ DFA3 6D 80 00320 TST ,X+ DFA5 2A F6 00330 BPL ERRS06 DFA7 6F C4 00340 CLR ,U DFA9 35 02 00350 PULS A DFAB B7 FFA2 00360 STA >FFA2 DFAE 8E DFBE 00370 LDX #ERRBUF-1 DFB1 BD B99C 00380 JSR >B99C DFB4 96 68 00390 LDA <68 DFB6 4C 00400 INCA DFB7 27 03 00410 BEQ ERRS07 DFB9 BD BDC5 00420 JSR >BDC5 DFBC 7E AC73 00430 ERRS07 JMP >AC73 DFBF 00440 ERRBUF RMB 65 0000 00450 END Do not be alarmed by the length. This code actually works; I have tested it. Lines 20-160 do the preliminaries which BASIC does in various ROMs. These can be uncovered by tracing the error processor from $AC46. Since there is a discrepancy between disk 2.0 and 2.1, I have used a check to discover which routines to call; I have Disk 2.1 but my DECB Unravelled provided the proper numbers for 2.0. The next chunk of code (170-220) set up for the search through the table of error messages. MMU block $37 is moved to loaction $4000 in logical address space and X is loaded with this location. Accumulator B is incremented by one to compensate for the search routine (the first error # in BASIC is 0 but this routine requires 1--the error number must also be divided by two before entering the routine if it is coming from BASIC.) The next chunk of code (230-270) points X to the proper text entry (the end of a text entry is signalled by bit 7 being set.) Lines 280-340 move the message from the text table to a temporary buffer. This is to prevent conflicts with the memory. Each byte has bit 7 masked off, is stored, then the original is tested. If it was set, a zero is written at the end of the buffer to signify the end of the text. Lines 350 & 360 get the origingal value from the MMU register and put it back. Lines 370-380 set the X register to one before the buffer and then print it on the screen. The remaining lines display the IN XXXX message if necessary and go to BASIC's direct mode. Now we must find a way to interface this routine with BASIC. First, we must load our machine code into memory. We also have to load in the Error Message table. The program ERRORS.BAS included will create the M/L in a file called ERRS.BIN and the error messages in ERRORMS.BIN. You may not understand how the latter part works, but I assure you that it does. You must run this program first. To change what an error message displays, locate the appropriate message in the DATA statements and change the entry (entries can be a MAXIMUM of 64 characters long). What's this UNTIL without REPEAT you ask? This program is compatable with BASIC+ by GEOFF FRIESEN. We must get ERRORMS into MMU block $37 and our ERRS program into memory. We could use a line as follows: 1010 LOADM"ERRS":POKE&HFFA2,&H37:LOADM"ERRORMS":POKE&HFFA2, &H3A Now we must divide the error number by two since on entry to the error routine, BASIC's number is multiplied by two. We'll use an ASRB or $57. We then must JMP to our new error processor--JMP $DF5C. We may also NOP out the extra bytes of the original instruction: 1020 POKE&HAC46,&H57:POKE&HAC47,&H7E:POKE&HAC48,&HDF:POKE&H AC49,&H5C:POKE&HAC4A,&H12:POKE&HAC4A,&H12 We also do not wish to lose our modification on pressing RESET. To prevent this, a common patch is as follows: ORG $148 RESET NOP STA $FFDF JMP XXXX where XXXX is the system reset address. The following basic code will install a reset patch: 1030 'RESET PATCH 1040 IFPEEK(&H72)=1ANDPEEK(&H73)=&H48THEN1060 DO NOT INSTAL L IF ALREADY THERE. 1050 POKE&H148,&H12:POKE&H149,&HB7:POKE&H14A,&HFF:POKE&H14B &HDF:POKE&H14C,&H7E:POKE&H14D,PEEK(&H72):POKR&H14E,PEEK(&H7 3):POKE&H72,&H01:POKE&H73,&H48 1060 rest of program We also do not want IN in upper case if our messages are in lower case. We change this by pokeing $69 and $6E into $ABE9 and $ABEA respectively. We can make our installation program erase itself after it is installed as well by adding a NEW statement at the end of the program. The program we built here is included as ERRSINST.BAS (actually, it is a similar program--the one above will not allow a reinstallination; the one on the disk will. See if you can spot the difference.) This wraps up my series on assembly language programming. If you have any questions, please write to me. Please enclose a money order for $1.00 CDN if you wish a reply directly otherwise, I will try to respond in CFDM. (There is no guarantee I will be able to answer your question, but I will give it a try. My address in included in the Magazine/Side of this issue.) I hope you enjoy this modification to BASIC. I may write a few other patches if time permits.