Tutorial 20
Using an Include File

Overview

Now that you are familiar with Z80 Asm, I will now introduce the concept of Include files. An Include file is simply a file with predefined ROM calls in it. In other words, you won't have to define every ROM call you use in your programs because they will have already been defined! This tutorial will cover how to use an include file and what is in an include file.

The Include File

To include an include file or any other file in to your program, you must use the #include statement. Those of you who are familiar with C or C++ will know that #include statement simply includes a file into the program. To use the include file, you must also define equ, EQU, end, and END. TASM is case sensitive about these things. This simply tells the assembler that EQU is the same thing as equ, and end is the same thing as END! Now, when using the Include file, the HEADER and DEFINES and EQUATES part of your program must be left out because they are included in the include file. I recommend that you use the TI83PlusAsm.inc file included with this help file. It is the TI83Plus include file provided by TI only adapted for use with TASM and optimized for TI-83 Plus Assembler programming by me. You must also type .NOLIST and .LIST before and after the the header. This is what the start of a program would look like if you used an Include file:

.NOLIST
#define     equ              .equ
#define     EQU             .equ
#define     END             .end
#include "Ti83PlusAsm.inc"              ;assuming you used my include file
.LIST

Remeber, the above source will replace the HEADER and DEFINES and EQUATES section, there is no need to include them anymore. Although you still need the PROGRAM START, BODY, and END.

Example

Here is an example of a program that uses and include file:

.NOLIST
#define     equ              .equ
#define     EQU             .equ
#define     END             .end
#include "Ti83PlusAsm.inc"      
.LIST

        .org    9D95h                   ;This tells the calculator that the program will start at the mem adress 9D95h

        B_CALL(_homeup)         ;Bringing up the home screen
        B_CALL(_clrlcdfull)                     ;Clearing the screen
        ret                             ;Returning to TI-OS

.end
END

Conclusion

The #include statement isn't always used to include include files. It can also be used any where in the program to include picture source, other programs, etc. For example, in tutorial 15, we used it to include the source for the title screen. Using include files will help us because now that you are more comftorable with Asm, we will learn even more ROM calls. Who has time to define each one by hand?