TMS-9900 ASSEMBLY LANGUAGE WITH TI EXTENDED BASIC TI Extended BASIC has the capability, when used with the Memory Expansion accessory, to load and execute TMS-9900 Assembly Language subprograms. Assembly Language routines may be entered and assembled using the TI-99/4 UCSD PASCAL(tm) Development System. This document provides an overview of the capabilities, how they are accessed from TI Extended BASIC, and how assembly routines may be developed. Assembly Language routines called from Extended BASIC may be used to make algorithms execute more rapidly, or to provide complex control of the video screen or the sound chip. Assembly routines are normally loaded in a relocatable form into a dedicated 8K byte block of the Memory Expansion. Using relocatable code allows routines to be written and used independently of the actual loaded address in memory. Also, combinations of several routines may be used from one BASIC program without concern for the load address. Assembly routines are called from the BASIC program by name. The actual address of the routine is resolved during execution. One or more entry names for a routine are defined when the routine is written. The 8K byte reserved block of the Memory Expansion may be used by Assembly Language. In addition, a portion of the other 24K bytes in the Memory Expansion is available depending on the size of the BASIC program being run. An assembly routine may or may not return control to BASIC. It may actually take control of the TI-99/4 and act as an entire application. In this instance, the entire memory resources of the TI-99/4 are available for use by the assembly subprogram. A set of utility routines is provided for Assembly Language subprograms to easily access unique hardware resources such as the Video Display Processor, and to pick up the values of arguments or return values to the BASIC program. A set of subroutines may be linked with an assembly routine to provide access to peripherals. With these routines, an assembly subprogram may easily execute I/O to a diskette, RS-232 or other peripheral. Three statements in the Extended BASIC language (CALL INIT, CALL LOAD, and CALL LINK) are provided to support the Assembly Language capability. The BASIC subprogram CALL INIT is used to intitialize the RAM Expansion for assembly subprograms. This subprogram ensures that the Memory Expansion has been attached. It then loads a set of utilities from ROM memory in the Extended BASIC command TMS-9900 Assembly Language Page 2 with TI Extended BASIC module. into the Memory Expansion. CALL INIT also causes any pre- viously loaded assembly routines to be undefined. Any subsequently loaded routines will remain defined until another CALL INIT is executed or the Memory Expansion is turned off. The BASIC subprogram CALL LOAD is used to load an Assembly object file into the Memory Expansion. Alternatively, direct data may be specified in the form of addresses and data in the CALL LOAD statement. An object file may contain relocatable or absolute address code. Direct data may only be absolute. Because of the difficulty in defining the entry point name from direct data, it is not recommended for general use in an entire program. However, if this is necessary, we can provide technical assistance to help accomplish this. Examples of CALL LOAD statements follow: 1. CALL LOAD("CS1") 2. CALL LOAD("DSK1.MYOBJECT", "DSK1.OBJECT2") 3. CALL LOAD(12000,04,01,02,0,255,255) The first two are examples of loading from a file while the third uses direct data. The BASIC subprogram CALL LINK is used to link to an Assembly Language subprogram. This statement specifies the routine to be called and any arguments to that routine. For example CALL LINK("NSORT",A(,)) could be written to sort array elements in row A(2,n) so that elements in row A(1l,n) are in ascending order. In this example, NSORT is the name of the routine. One argument is passed as two dimensional array A. Values in this array are changed and returned to the BASIC program. Development of Assembly Language programs to run under Extended BASIC may be done on the PASCAL Development System. This system includes a powerful text editor, macroassembler, and link editor. A set of macros is provided during assembly to facilitate accessing specific TI-99/4 hardware features such as the Video Display Processor, or the sound chip. An I/0 utility is available which may be linked with an assembly routine to provide access to peripherals such as disk drive, RS-232, etc. Although the disk format of the PASCAL system is different from that used by Extended BASIC, a utility is provided to convert a PASCAL object file to the format required by Extended BASIC. **UCSD PASCAL is a trademark of the Regents of the University of California.