Site hosted by Angelfire.com: Build your free website today!

WherzWaldo's TI-86 ASM Guide
David J. Waldo


Before you start to program ASM, you will need the following programs/resources:
1. A standard text editor (i.e. DOS E editor)
It is best to not use a word processor. A word processor puts special formatting on text, and that will be a pain when compiling your program. And I do not recommend using Windows Notepad for very long, complex programs, as it can't open files bigger than about 20k. However, for your first ASM program, Notepad would be fine.
2. ASM86 by Alan Bailey; includes ASM86 (ROM calls) and TASM3.01 (compiles your program)

Extract asm86all.zip to a directory called c:\tasm or whatever you want. Then run your text editor. Again, I recommend the DOS E Editor (with PC DOS 7.0), because you will have to be in DOS anyway to compile your program.

Here's the program you will type. It will be explained both inside the program and under the program.

----------------------
;your first ASM program

#include "asm86.h" ;#include "" tells the compiler to include these files, which
#include "ti86asm.inc" ;contain all the ROM functions and calls
#include "ti86ops.inc" ;they don't necessarily have to be in this order
#include "ti86math.inc"
#include "ti86abs.inc"

.org _asm_exec_ram ;signals the beginning of an ASM program

nop ;this section will show a program description in an ASM shell
jp MainProg
.dw $0000
.dw Description

MainProg: ;the main section of the program
call _runindicoff ;turns the annoying run indicator off
call _clrLCDfull ;clears the screen and deletes all screen variables
ld $0000,hl
ld (_curRow),hl ;prepares to write text to the screen
ld $0000,hl
ld (_curCol),hl
ld hl,hello1 ;loads the first text label into register HL
call _puts ;...and puts it on the screen
call _newline ;skips down a line
call _getkey ;waits for a keypress
jp Prog2 ;and then jumps to label Prog2

hello1:
.db "86 ASM is easy",0
.end

Prog2:
ld $0000,hl ;again, prepares to write text to the screen
ld (_curRow),hl
ld $0000,hl
ld (_curCol),hl
set 3,(iy+$05) ;sets a flag for white-on-black text
ld hl,hello2 ;stores hello2 into HL
call _puts ;and puts it on the screen (line 2)
res 3,(iy+$05) ;resets text to black-on-white
call _newline ;skips down a line
ret ;ends the program - Calculator will crash w/o it

hello2:
.db "Inverted text!",0
.end

Description:
.db "My first ASM program",0
.end
END

------------------------

ow, let's take this one line at a time. As you can tell, the first line of the program was a comment. Comments always begin with semi-colons. Unlike programming languages like C, C++, and Turbo 6, there are no "comment blocks"; these are only one-line comments. Anytime the compiler encounters a semi-colon in a program (except in .db statements), that character and any characters after it on that line will be ignored.

The next thing is the include files. The Turbo Assembler compiler that comes with ASM86 is dumb. It doesn't know what will work on your calculator. That's why you have to tell it what your program uses. Then it will "learn" the commands and tell you what will work and what won't. There are 5 include files that come with ASM86: ti86asm.inc is Texas Instruments' "standard" include file; the rest are made by Alan Bailey.

The next block of text (4 lines) is your program's description. This is basically a short description of your program. Some Assembly shells, like ASE and AShell, support program descriptions. Bill Nagel came up with this routine, so I don't really understand how it works. :)

Next, the real program starts. I have commented every line so I don't have to explain it down here. :)

For a change, you can change _curRow to _penRow, _curCol to _penCol, and _puts to _vputs. This will display text in the variable-width font (like the Basic Text( command) rather than the 5x7 font (like the Basic Outpt( and Disp commands). You must change all of them for it to work correctly.

Now save the file as asmprog1.asm. Make sure your editor doesn't save it as asmprog1.asm.txt or something else.

Now to compile it. At a DOS prompt (either in DOS or a DOS window), change to your TASM directory. Do the following.

c:\tasm301\>tasm -i -80 asmprog1.asm

This will start the TASM compiler. The compiler makes two passes. The first pass is to check the validity of the #include statements, and to make sure the program has ".org _asm_exec_ram" and "ret" somewhere. Then the second pass is to check syntax, validity of ROM calls, and to make sure all the labels work. If all goes well, you will see "Number of errors: 0". Then you've got the Go to make your ASM source file a TI-86 program. After all, you can't send *.asm files to the calculator. Do the following.

c:\tasm301\make86p asmprog1

Be sure to leave off the .asm extension. This program will give the file the once-over with the compiler, and then, if everything checks out, it will take the ASM file and make it a .86p file. When you get the message ***asmprog1.86p created successfully***, all you need to do is send the program to your calculator, by whatever means you use. When the program is on your calculator, type

Asm(asmprog1

to run the program. The program then should run perfectly. :) Congratulations! You have written your first Assembly program!

I'll probably do another guide sometime in the future.

Disclaimer:
I do not accept responsibility for any damage done to your calculator. I am only a freshman in high school, and I don't know a lot about ASM. If your calculator locks up, use the following steps to get use of your calc back.
1. Remove the battery cover.
2. Remove the 4th battery.
3. Press and hold [ON].
4. While holding [ON], replace the battery, and then release [ON].
5. Turn the calculator on.
This method is only recommended as a last resort, when nothing else will work. Using this method, there is a greater than 90% chance that your memory will be cleared.


Now, I never said this was the greatest ASM tutorial for the 86 out there on the Internet. You can find other 86 ASM resources at the following web sites:
TI-Philes - Check out the Assembly Programming Column.
TICalc.org - Check out the Assembly-86 Message Board.
Ahmed's TI-86 Page - Ahmed El-Helw has his two tutorials as well as two others in his Programming section.

If you find something seriously wrong with this tutorial (except that it sucks), please E-mail me at the following address (no flames, plz).

WherzWaldo's ASM Guide (c) 1998 David J. Waldo
E-mail: djwaldo@mindspring.com (primary) Web: http://djwaldo.home.mindspring.com/
waldo@lbjhs.austin.isd.tenet.edu
IRC: djwaldo SubSpace handles: WherzWaldo???, David J. Waldo