GENEVA BASIC/Z80 DRIVER PACKAGE 9/4/84 George Damusis INTRODUCTION: This software package consists of a pair of program modules, GENDRV.COM and GENDRV.BAS, that represent a software interface between PX-8 Interpretive BASIC and Z80 Machine code. Since many programmers feel the need to perform certain specific driver routines in machine code while doing most of their programming in Interpretive BASIC, it is useful for them to have a simple means of interfacing between the two languages. This package provides a programmer-friendly method of doing just that. The major features of the software are these. The program GENDRV.COM is called from CP/M and then it takes over to load the BASIC Interpreter BASIC.COM from the default disk along with the companion BASIC program GENDRV.BAS. The GENDRV.BAS program then asks the user to specify the application program the user wants to run. It is this user program that will interface to the Z80 subroutines previously assembled in GENDRV.COM. As of this date, this software package is only useful as a demonstration kit, as no I/O routines of real substance have yet been written. To see this package in action the following four programs must be present on the same disk: GENDRV.COM, GENDRV.BAS, BASIC.COM, GUSER.BAS . When the GENDRV.BAS program requests the title of the user's program, type in GUSER, and GUSER.BAS will be chained in and overlayed on top of the GENDRV.BAS program. The GUSER.BAS program will then make four calls to the BSOUND routine in GENDRV.COM to play the speaker, and finish with a call to the BADCVRT routine to read the battery voltage. A bar graph of the voltage is then drawn. Please note that in a departure from the normal practice of using the Interpreter to load in a BASIC program that uses the POKE instruction to laboriously store Machine code subroutines into the desired memory locations, this package reverses the process. A previously assembled Machine language driver program is used to automatically load in the BASIC Interpreter and all the other necessary software via one simple CP/M keyboard entry. DETAILED DESCRIPTION: For the following discussion to make more sense, hard copies of these files should be used: GENDRV.MAC or GENDRV.PRN, GENDRV.BAS, and GUSER.BAS. The GENDRV.COM program is the M80 Assembler/L80 Linker output of the GENDRV.MAC source file. This program was designed to perform several functions. 1) To relocate itself in upper memory, just under BDOS, thus maximizing the BASIC memory space below it. 2) To save the start address of the BASIC interface table at 6CH for use by the user's BASIC application program. 3) To automatically load in both the BASIC Interpreter and the GENDRV.BAS program. 4) To contain whatever driver subroutines a developer might want to write. The GENDRV.BAS program is the necessary companion to GENDRV.COM, and has the following functions: 1) To equate all the absolute GENDRV.COM routine addresses to BASIC variables. Specifically these absolute addresses are all derived from the BASINT label address in GENDRV.COM. 2) To load the BASIC user apps. program using the CHAIN command, which passes the interface variables to this user program. Load the GUSER.BAS program here to see how it all works. The sequence of events that must take place in developing new software using this package are the following. Obtain a copy of M80 (Microsoft Macroassembler), L80 (Linking Loader) and a copy of GENDRV.MAC and GENDRV.BAS. Make copies of both GENDRV programs under different titles for development purposes, and to protect against corruption of the original models. GENDRV.MAC NOTES: Note in GENDRV.MAC that for programming purposes it is fair to change the address after the .PHASE directive. This address specifies the start address of relocation and can be set to any value desired above 8000H. Any change here, however, will require a change at the BTAIL label to the string "GENDRV/M:&HDA00" to reflect the new top of BASIC memory space. The BASINT label in GENDRV.MAC is an all important address as it contains a 10 byte space for future CALL return parameters, if any, and also a table of driver subroutine addresses. Any and all subroutine creations will require a corresponding label entry in this table. This entry will then be referred to by the GENDRV.BAS program to create the equivalent BASIC variable name and thus complete the interface to GENDRV.COM. Hence, any change to GENDRV.COM will necessitate a corresponding change or addition to the GENDRV.BAS program to reflect the absolute location of the new routine. As an added benefit, one can easily change the source disk that the BASIC.COM program is loaded from by changing the BDSK label contents to 2 from the current 0. This 2 will point to drive B: and allow the Interpreter, normally in ROM capsule here, to be loaded into memory much more quickly than from an external drive. When the desired changes have been installed in a copy of GENDRV.MAC, assemble it this way: M80 =B:GENDRV/L This creates the files GENDRV.REL and GENDRV.PRN. To create the COM file use L80: L80 B:GENDRV,B:GENDRV/N/E The next job is to adjust GENDRV.BAS. GENDRV.BAS NOTES: The most important thing to remember about this program is that its purpose is to provide absolute address variables to allow CALL instruction interfacing to GENDRV.COM. This activity is accomplished in the lowest line number area of the program. Notice that lines 1 through 4 revolve around the value of BASINT as extracted from the 6CH location used by GENDRV.MAC to store the BASINT table address. Hence, any subroutine additions to GENDRV.MAC will require the new label addresses generated to be defined in the low line number section of GENDRV.BAS. The reason for keeping these line numbers as low in value as possible is to allow the MERGEing of the user program into the same BASIC memory space. This will prevent the loss of the common variables needed for CALLs if the user program is run a second time. Think about it. The MERGE implication here is that the user program start at a line number greater than the highest low line number in the GENDRV.BAS program. The line numbers at 60000 and above were purposely chosen to be out of range of the average user program to be MERGEd. Immediately after the CHAIN instruction these lines of 60000 and above are deleted anyway to prevent loss of valuable memory space. FINAL NOTE: The PX-8 BASIC Interpreter is very powerful and already contains many of the extended I/O routines needed for efficient BASIC programming. For these cases no advantage is gained in reinventing these subroutines in Machine code format. However, when calls to machine code are in order, please refer to the PX-8 BASIC Reference Manual for more detailed information on the use of Machine Language Subroutines. The protocol for the CALL instruction is highly dependent on the number of parameters being passed, and there's hardly enough information about this in the GENDRV.MAC file.