Feature: TI-83 ASM Tutorial (Part 1) Posted by Nick on 5 April 2000, 01:10 GMT
Looks like Jeff Chai just slapped me upside my afro-ensconced head regarding assembly tutorials. These are the first four in a set of twenty(!!!) that he sent me. I'll probably run these as frequently as I can without it getting too boring, but there's a lot of interesting stuff in there. Enjoy. :)
What you need to Write TI-83 Plus Asm programs
In this tutorial, I will be showing you what is needed to make/assemble Asm programs. We'll even learn some DOS commands!
The following items are needed to create/run Asm programs:
- TI-83 Plus (this is kind of important) - TI-Graph Link or Equivalent (actually optional) - IBM compatible PC
The following programs are needed to write/assemble Asm programs:
-TI-Graph link software (only if using TI-Graph Link) -*TASM cross assembler/linker -**Objhex (Objhex is a program I made in C that converts Binary files to hexadecimal code) -*Virtual TI (optional, I'll show you how to use it later) -**Asm.bat (a batch file I will show you how to make, don't worry about it yet) -Any word processor (Notepad is prefered) -Windows 3.x, 95, 98, 2000, or greater *Available at www.ticalc.org, www.calc.org, or other calculator websites. Your best bet is to look in their program archives. **Included with this Help File
What is this?
If you are new to Asm programming, you have probably never heard of the software mentioned above. The TASM assembler/linker assembles the program you've written in z80 assembly language. No body would have heard of ObjHex because I made it (It is programmed in C). The only reason I use it is because I have never used Obj83 (I just recently found out what it was for:). They both do the same thing, but I'd prefer you use ObjHex because I worked hard on it. If you want proof that it isn't just a renamed Obj83, give me an e-mail, I'll show you the source code for it! Virtual TI is a calculator emulator, I'll tell you how to use it later. If you don't know what Windows is, you probably shouldn't be using this help file, because you wouldn't be able to. Notepad is a word processor, we will type in the source code for our programs here.
What we're going to do
Now, we need to organize the files into folders ("Directory" is the DOS term for folder). Create a new folder called "LearnAsm". You may call this folder anything you want as long as you know what it is. Now, inside this folder, create four more new folders, name them: "TASMassembler", "ObjHex", "Virtual TI", and "MyPrgms". Extract the contents of the TASM zip file to "TASMassembler", the ObjHex zip file to "ObjHex", and so forth with the rest of them. Leave the "MyPrgms" folder alone for now, we will save all the programs you make to this folder. Now copy the contents of "ObjHex" to "TASMassembler". Before we get to the batch file, make sure if you're using the TI-Graph Link software that it's installed correctly in it's own seperate folder.
Now, here's the batch file. Open the "LearnAsm" folder. Now right click and select New, then click on text document. Name it "asm.bat". Note the file extension is .bat. Now open it. Copy and paste the following text into it.
@echo off echo ----- Assembling %1 for the TI-83 Plus... tasm -80 -i -b %1.z80 %1.bin if errorlevel 1 goto ERRORS echo ObjHex Converter Version 1.2 echo Copyright (C) 2000 Jeff Chai objhex %1.bin %1.hex echo ----- Converting to hexadecimal format... echo ObjHex: HexaDecimal version is %1.hex echo ObjHex: Task Complete! goto DONE :ERRORS echo ----- Errors were found! :DONE echo ----- Done
Just to let you know, these are MS-DOS commands (Microsoft Disk Operating System). DOS was developed by Microsoft in the late 80's. It is simple to use if you know how. What do these commands mean? Well, look below:
@echo off - prepares OS to display text echo - command that displays anything typed after it, always preceded by @echo off goto
Save the file and then move it to the "TASMassembler" folder ("Directory" is the DOS term for folder for those who are DOS illiterate...). Take a look at the batch file. Try to understand it, know what it is doing at a specific point in time. It'll make things a lot clearer.
Assembly programs must be written in z80 assembly language. Though to be sent to the calculator, they must be assembled and converted to ASCII (Hexadecimal code). Once on the calculator, they may be run as is, or compiled in to the calc's native language.
Key Differences - TI-83 vs. TI-83 Plus
Overview (Part 1)
In this tutorial, you should learn the key differences between programming for the TI-83 and TI-83 Plus and the Z80 CPU.
Compare and Contrast
Over all, programming in Asm for both calculators is not all that different. In fact, most TI-83 Asm Programs will work on the TI-83 Plus, and vice versa (With some porting of course). The TI-83 Plus was designed with applications in mind. So to utilize that function, some changes in it's Asm programming were made. You should know what the differences are when programming the TI-83 Plus in Asm after reading this tutorial.
The TI-83 Plus uses the B_Call() macro for ROM calls instead of the regular call macro.
Asm programs (Not Applications) written in Asm are limited to 8K in size.
Most (Some) TI-83 Asm programs will run on the TI-83 Plus provided that a few minor changes be done. They require that the original source code be re-assembled for the specific memory addresses for the TI-83 Plus.
ex. TI-83 ROM call: call _clrLCDFull ex. TI-83 ROM call address: clrLCDFull =4755h
ex. TI-83 Plus ROM call: B_CALL(_clrlcdfull) ex. TI-83 Plus ROM call address: _clrlcdfull =4540h
TI-83 Plus programs only need to slightly changed to run on the TI-83, and vice versa. But since the TI-83 Plus has more SafeRAM areas, TI-83 Plus programs using these SafeRAM areas may not be run on a TI-83.
We're going to recognize and identify the parts of a program.
What belongs where in a program?
Look at the format of an Asm program, just follow along. Just to let you know a ; (semicolon) means anything on that line is a remark. Remarks are used to make comments in a program. Remarks are not read by the assembler or calculator. A note when writing Asm programs, indentaions are required, they help the TASM assembler read the program so it can understand.
; ; ; ;DEFINES AND EQUATES(Part of the HEADER) ; ; ;
.org 9D95h ;THE PROGRAM START
; ; ;THE BODY ; ;
.end ;THE END END
There is not much to know about this section except that it goes into every Asm program you write. what you should know about this section is that it defines the two macros b_Call and bjump. These macros call ROM calls. If you use an include file, this section is not nessesary. In the headers I will be using, I will name the B_Call macro "bcall" because it is easier to type. You may name it anything you want as long as it is defined in the HEADER or include file.
The DEFINES AND EQUATES (Part of the HEADER)
This section allows you to define each call you use in your program. Again, if you use an include file and know that the commands you are using are covered in there, you do not have to define them again. To incorporate an include file to define calls, type in #include "XXX.inc". Where XXX is the name of the include file. An include file is a file that has ROM calls or routines defined in them. The #include statement just saves you time by copying the contents of the include file to the program.
The PRGOGRAM START
This tells the calculator where to start running the program in memory. With the TI-83 Plus, the program always starts at the address 9D95h.
The body of the program is where you write the calls and functions (routines) you want the program to do. It can be as long as you want. You must call each call or function using the bcall(xxxx) statement. Where xxxx is the command you wish to run. Make sure you define each ROM call in the Defines and Equates section when you use them in your program. Or make sure that the specific ROM call is in the include file if you are using one.
Simply stated. The END of the program. This must always be at the end of every program. Don't change anything in this section, all you need is the .end and END.
First Program-Clearing the Screen
In this tutorial, we will be learning how to clear the screen, the Asm way of course.
The code in the following program will clear the screen on the calculator. This is your first program, so I will lead you step by step. Open the "MyPrgms" folder and create a new text file. Name it "Clrscreen.z80". Note that the file extension is .z80. Open it and copy the following program into it. I recommend that instead of copying and pasting it, you should print it out and copy it by hand, you'll get used to the program format and will thus learn to program faster.
#define B_CALL(xxxx) rst 28h \ .dw xxxx ;This defines the two macros, bcall and bjump #define B_JUMP(xxxx) call 50h \ .dw xxxx ;Don't worry about bjump too much because you won't you use it very often
_clrlcdfull =4540h ;The calls we will be using are defined here _homeup =4558h
.org 9D95h ;This tells the calculator that the program will start at the mem address 9D95h
B_CALL(_homeup) ;Bringing up the home screen B_CALL(_clrlcdfull) ;Clearing the screen ret ;Returning to TI-OS .end ;End of program END
_clrlcdf - This command will clear the entire lcd display. When using this call alone in a program, it will clear the entire screen. But don't forget to include a ret call at the end or else the calculator won't return back to the OS forcing it to crash and reset. The same goes with all ROM calls.
_homeup - This call brings up the home screen.
ret - A standard z80 Asm instruction that takes you back to the TI-OS
.end and END - z80 instructions that tell the calculator that that is the end of the program.
Assembling the Program
To assemble this program, go on to tutorial 5
Other Clear Commands
Other commands such as _ClrLcd (_ClrLcd = 4543h) will clear the display while _Clrlcdf will clear the display ignoring any split screen modes. _ClrScrn (_ClrScrn = 4549h) will clear the screen and any text shading along with it. _ClrScrnFull (_ClrScrnFull = 4546h) will clear the screen and text shading ignoring split screen modes. _ClrTxtShd ( _ClrTxtShd = 454Ch)will clear the text shade buffer. To use any of these calls in the program above, define the call and call it to the program using the B_CALL() macro.
For example, to use the _ClrScrnFull ROM call, this is what the program would look like:
My first first comment!!! Now I have to learn assembly.
Oh yeah, I haven't looked at all, so don't mock me, but is there a place to easily search these features? Seems like they should have a search thing for them as we get a lot. Again I haven't looked at all so if there is such a place don't make too much fun of me.
I hate to sound prudent (if that is the right word), but aren't all these tutorials turning out to be the EXACT same thing? I mean, look at the past three released...they portray the EXACT same information, EXACT same layout (in terms of easy to read/understand), and EXACT same purpose? I mean, what it personally looks like is a mere read one persons tutorial, then write one yourself about the same stuff! But, maybe I am assuming too much, and not giving enough credit to the people writing these. But, does anyone feel the same way I do? And I know this probably puts me in a bad light because I wrote the first 83+ asm tutorial, but I am saying this not in the eyes of someone who has written a tutorial themself, but in the light of a neutral person's eyes (??? Make sense ???).
5 April 2000, 02:57 GMT
Re: Re: Feature: TI-83 ASM Tutorial (Part 1)
I have to agree. The old Asm Guru was the last good and original tutorial.
You're too young to be cynical.
Seriously, I'd like to see some more advanced asm (like a asm getkey and move sprite routines.), so anyoune who is thinking of doing an introduction to asm ought to be doing a little more advanced stuff
(forgive me, but I'm still high on asm-I learned it 2 hours ago)
Hey guys, calm down. I agree too, Asmguru is the BEST Z80 Asm documentation available. This is just part one. When the others come out (3 days), you'll soon be graphing, and eventually making an Asm game of Tic Tac Toe!
You also have to understand that some people just can't take the information from Asmguru and apply it to TI-83 Plus Asm. They are either inexperienced or just don't wnt to try. So this is the easier way out. Soon, these tutorials will be available in Windows's help file format.
And Matt, Ionguru is great! I've used it before and the information is really something of high quality. Keep up the good work! =)
I know Jeff is trying to keep the tutorials as original and useful as possible, but you have to understand that he's not an ASM god who can just have the code leap into his head one day and say "hey! I know everything now!". The author of ASMGuru can do that... I wish I could. I'm pretty sure Jeff's getting most of his information from TI's include files, ASMGuru, IONGuru, guess and check, and maybe the file that comes with that application maker thingy from TI. It's kinda like writing a report for school (research, not proving or inventing something, a point that has already been proven)... you go get some books, or in this case tutorials, read up, and put it in your own words. And hope that someone will understand and use it.
You're absoultely right! Except I looked in Asmguru for help on Displaying Small text. Most everything else I got from Z80 programming books from the Gaithersburg public library. Are you going to judge my tutorials based on the first 4 that you see? Hey, you havn't seen anything exciting yet!
Whose side are you on? I thought you were my "friend". I'll see you in math class! =)
In response to this comment and the preceding one, tutorial 8 is an Asm Getkey program and Tutorial 15 is an Asm version of Tic Tac Toe! Just keep patient, make sure you have the basics knocked down. Look out for the help file with all these tutorials soon. If you need ObjHex, I'm adding it to the archives so you cab easily download it from there. Look in the DOS programs folder.
5 April 2000, 23:28 GMT
Re: Feature: TI-83 ASM Tutorial (Part 1)
Cool... any plans in progress for other calcs? We could be seeing a surge in ASM programs with cool tutorials like these...
I was wondering if you could adapt your tutorials to Ion, Jeff. Seeing as how Ion has emerged as the defacto standard and there are very few tutorials. Ion tends to have many more options than 83+ Asm. Please keep me informed on this! I appreciate the straightforward manner in which these are written. Aren't you the WinCIH 95 Guy?