Basics Archives Community Services Programming
Hardware Help About Search Your Account
   Home :: Archives :: News :: Feature: TI-83 ASM Tutorial (Part 2)

Feature: TI-83 ASM Tutorial (Part 2)
Posted by Nick on 12 April 2000, 03:02 GMT

Jeff Chai takes the microphone once again in his second feature here at ticalc.org. Here, he elaborates a little more on some more intermediate TI-83 Plus ASM topics.

Tutorial 5
Assembling Asm Programs


You will learn the steps to assembling Asm programs using TASM.

Background Information

TASM stands for Telemark Cross Assembler. The TASM assembler assembles for the Intel 8080 processor. What!? But we're assembling for Zilog's Z80 processor! Don't worry =) When the Z80 was developed by Zilog (A renegade group of Intel engineers), it was highly based off of the Intel 8080. In fact. they are cross compatible! That's why we're using TASM to assemble our programs.

Checklist for Assembling

  • Is the program written in z80 Asm?
  • Does the program have a .z80 file extension?
  • Have you self checked it for errors?
  • Have you had a friend (or me) check it?
  • Have you properly installed all the software?
  • Have you backed up your calculator?

Once this checklist is completed, continue on.

Assembling Programs

Now, copy the program you've written from the "MyPrgms" folder to the "TASMassembler" folder. Next, in the "TASMassembler" folder, make sure if you used any include files that they're in the folder along with the written program. In the "TASMassembler" folder, create a new text file called "Start.bat". You may edit this file later by right clicking on it and clicking on edit. In the "start.bat" file type in asm progname. Where progname is the name of the program you've written. Do not include the .z80 extension when typing in the name. Now save it and close the file. Now, to start assembling the program, click on the "start.bat" file. If all goes well, the assembler should have outputted a .hex file. If it did go on. If the assembler gave you an error message, click here to try to debug it.

Sending and Running

Open the progname.hex file in the "TASMassembler" folder. Select the entire contents of the file and copy it. Then open the TI-Graph Link program and type in AsmPrgm in the new program editing area on the right. Paste the contents of the .hex file there. Give it a name and send it to RAM. Make sure if you're using a Graph Link, that the link is securely connected to one of the computers COM ports. Then, on the calculator, press [2nd] + [Catalog] . Then scroll down to Asm (. Hit enter to paste it to the home screen. Then hit [Prgm] then select your program. Hit Enter. The home screen should look like this:

Asm ( prgmprogname

Hit enter to execute the command. Your Asm program is now running! What if it Crashes?

If you don't have a Graph Link, create a new program on the TI-83 Plus. Paste the AsmPrgm token in the program. Then you'll have to hand copy each charater from the .hex file to the calculator.


To compile your program, paste the AsmComp( token from the catalog. Then paste the program you want to complile to the screen, then hit the , button. Then, from the catalog, paste the Prgm token to the screen. Then type in a name up to 8 characters long. It cannot be the same as the program you are compiling. Your calc screen should look like this:

AsmComp(prgmprogname, prgmprogname2

Hit enter and your program has now been compiled. You can run the program the same way as the program before you compiled it.

Tutorial 6
Moving the cursor to the next line


This is a seemingly worthless but none the less important tutorial on moving the cursor to the next line.

The Source Code

This code will move the cursor to the new line.

#define B_CALL(xxxx)	rst 28h \ .dw xxxx		 
#define B_JUMP(xxxx) call 50h \ .dw xxxx

_homeup =4558h
_newline =452Eh
_clrlcdfull =4540h

.org 9D95h

B_CALL(_homeup) ;Call up the home screen
B_CALL(_newline) ;Move cursor to next line
ret ;Return home



The screen should look like this after you run the program:

As you can see, there is an empty line on the top of the screen followed by a "Done" message and the blinking cursor on the next line. If it weren't for the "Done" message, the cursor would have been on the preceding line. The point is, the cursor isn't on the "First line". But rather on the next "empty" one.

New Commands

_newline - sets the cursor on the next "empty" line.

Related Commands

Did you know there is actually a ROM call that displays the "Done" message on the screen? Well that call is _DispDone (_DispDone = 45B5h). Try it out.

Tutorial 7
Displaying Text


This tutorial will show you how to make a program that will display normal and inverse (white on black) text.


The program below will display normal text on the home screen. The program uses the calls we have already learned, and adds some new ones. In a future tutorial, we will make a program that displays small text.

#define B_CALL(xxxx)	rst 28h \ .dw xxxx		 
#define B_JUMP(xxxx) call 50h \ .dw xxxx

_clrlcdfull =4540h ;The calls we will be using are defined here or use an include file
_homeup =4558h
_puts =450Ah

.org 9D95h

B_CALL(_clrlcdfull) ;Clear the screen
B_CALL(_homeup) ;Bring on the home screen
ld a,0 ;Load "a" register as zero
ld (CURCOL),a ;Load zero into the y coordinate
ld (CURROW),a ;Load zero into the x coordinate
ld hl,txtLabel ;Load text from label below
B_CALL(_puts) ;Put text on screen
B_CALL(_clrlcdfull) ;Clear screen
ret ;Return to OS
txtLabel: ;the "Label" can be replaced with any name you want
;as long as you change the one on the top
.db "This Program "
.db "displays text "
.db "on the home "
.db "screen. It can "
.db "be up to 16 char"
.db "long, it can "
.db "only be 8 lines "
.db "long. ",0

New Commands Used

(CURCOL) - the y coordinate of the cursor

(CURROW) - the x coordinate of the cursor

_puts - Puts the text on the screen. This command will bring the specified text to the screen.

_getkey - Detects a key press on the key pad

ld - z80 instruction fo loading something. In this program, it loads 0 (zero) to the "a" register. The syntax is - ld (register), (value#)


The calculator's memory is where nearly all data is stored. Unfortunately, memory access is relatively slow for the processor. So, when we want the processor to manipulate data, like add two numbers together, we don't want to do it in the memory. Instead, we load the data into special fast memory locations inside the processor itself called registers. In the normal text displaying program (above), the value "0" was saved into the "a" register. The value in the register was then in turn, loaded in to CURCOL and CURROW (the X and Y coordinates of the text). Registers are extremely important! If you don't understand them, I recommend that you read tutorial 4 in Andy S.' tutorials.

Inverse Text

Jeez, things just keep getting better. Inverse text is normal font text (white) on a black backround. This program will display the text "TI-83 Plus Asm" in inverse text. All you need to know to display inverse text is loading text coordinates and setting textinverse mode.

#define bcall(xxxx)	rst 28h \ .dw xxxx		 
#define bjump(xxxx) call 50h \ .dw xxxx

_clrlcdf =4540h
_homeup =4558h
_puts =450Ah
textinverse =3 ;See the new commands section for more information
textflags =5

.org 9D95h

set textInverse,(iy+textflags) ;Sets the textinverse mode
ld a,0 ;Load 0 to the "a" register
ld (CURCOL),a ;Setting Y coordinates
ld a,0 ;Loading 0 to the "a" register
ld (CURROW),a ;Setting X coordinates
ld hl,txtTIAsm ;Display text from the TIAsm label
bcall(_puts) ;Put text on screen
res textInverse,(iy+textflags) ;Resets the text inverse
ret ;Return to OS
.db " TI-83 Plus Asm ",0 ;Text to be displayed on screen

New Commands Used

set - z80 instruction that sets the characteristics of the TI

res - z80 instruction which will reset the characteristic

textinverse - Inverse text mode of the TI

textflags - You don't need to know this yet


Tutorial 8
Using Getkey to Detect Key presses


This will show you how to use the _getkey ROM call

What is _Getkey?

_Getkey is a ROM call similar to it's TI-Basic counterpart command, getkey. Getkey waits for a key press from the key pad. Then, depending on what you want to do, getkey can display the key code of the key pressed, execute another command, or act like a program pause.


This program will use _getkey as a program pause.

#define B_CALL(xxxx)	rst 28h \ .dw xxxx 
#define B_JUMP(xxxx) call 50h \ .dw xxxx

_clrlcdfull =4540h ;The ususal constants and defines, look at the
;New Commands section for more information
_homeup =4558h
_getkey =4972h

.org 9D95h

B_CALL(_homeup) ;Call up home screen
B_CALL(_getkey) ;Pause until next key press
B_CALL(_clrlcdfull) ;After key press, clear screen. Or you can use
;any other clear screen command (Tutorial 3)
ret ;Return to being a good old calculator


New Commands

_getkey - Detect key press, store key code if nessasary


We will make our own program that displays the Hex key code of the key pressed.The code for the program is here. It looks complicated, but it really isn't. I'll comment the program along the way so you don't get lost. An important concept is the "stack". The stack holds numbers for future use or reference. In this program, it holds the hex code of each key pressed.

#define B_CALL(xxxx)	rst 28h \ .dw xxxx 
#define B_JUMP(xxxx) call 50h \ .dw xxxx

_clrlcdf =4540h ;The ususal constants and defines, look at the
;New Commands section for more information
_homeup =4558h
_puts =450Ah
_putc =4504h
_getkey =4972h
_newline =452Eh

.org 9D95h

B_CALL(_clrlcdf) ; clear screen
B_CALL(_homeup) ; home the cursor
ld hl,txt1 ; Display the message at the txt1 label
B_CALL(_getkey) ; Detect key press
push af ; Save key press in register a
B_CALL(_clrlcdf) ; clear screen again
B_CALL(_homeup) ; home again
ld hl,txt2 ; Display msg2
B_CALL(_puts) ; Display text
pop af ; restore reg a
call dishex ; Follow commands at label dishex to find hex key code
B_CALL(_getkey) ; pause until next key press
B_CALL(_newline) ; Move cursor to next line
ret ;Return to TI-OS

dishex: push af ; keep copy of value
and 0F0h ; terminate lower nibble
rra ; shift nibble right 4
ld l,a ; Display the Key's hex code in Str1
ld h,0
ld de,hexStr
push de ; keep for other nibbler
add hl,de ; add offset to hexStr address
ld a,(hl) ; find correct ASCII character from string below to
; display hex code of key pressed.
bcall(_putc) ; display character
pop de
pop af
and 0Fh ; wipeout upper nibble
ld l,a
ld h,0
add hl,de
ld a,(hl)
ret ; Return to OS

hexStr .db "0123456789ABCDEF" ;These are the characters used to display
;the key's hex code
txt1 .db "Push a key.",0
txt2 .db "Key code: ",0


New Commands

_putc - Display character and advance cursor
push - Pushes a number on to the stack.
pop - Takes a number off the stack.
call - This looks like the TI-83 macro, and serves almost the same purpose, only for the TI-83 Plus, it jumps the program to a specified label.


This program wasn't exactly "lightning fast". That's because the _Getkey command was scanning the entire key pad for a key press. Later on, we will make a program like this one, only we'll narrow down the area in which _Getkey looks in for a keypress, making it faster.


The comments below are written by ticalc.org visitors. Their views are not necessarily those of ticalc.org, and ticalc.org takes no responsibility for their content.

Re: Feature: TI-83 ASM Tutorial (Part 2)
Reno  Account Info

are you going to cover using the ports for keypresses soon? I use them when I program little progs on my 86, and they seem better than getkey...

offtopic: lord help us now; someone's made a library shell for the 86....I'd be for it if the libraries were implemented from the beginning, but I don't particularly enjoy libraries anyways, and the 86 has enough memory to take away need for libraries....

     13 April 2000, 00:43 GMT

Re: Re: Feature: TI-83 ASM Tutorial (Part 2)
Alapanamo  Account Info

I hope to God that libraries for the 86 don't catch on. If they do, I may as well sell my calc and get an 89.

     13 April 2000, 01:20 GMT

Re: Re: Re: Feature: TI-83 ASM Tutorial (Part 2)
Jeff Meister  Account Info

Why does everyone hate libraries so much? They make a programmer's life a lot easier, and all you have to do is send a few more files with your OS... then again I don't have an 86, so I'm probably very wrong about everything :)

- Jeff

     17 April 2000, 14:23 GMT

Re: Re: Re: Feature: TI-83 ASM Tutorial (Part 2)
Jeff Meister  Account Info

Oh yea... you may as well sell your calc and get an 89 anyway. Come to think of it, smack yourself upside the head for not doing that already!

I think I'm done now.

- Jeff

     17 April 2000, 14:25 GMT

Re: Feature: TI-83 ASM Tutorial (Part 2)
Matthew Hernandez  Account Info
(Web Page)

Sorry to post something negative again, but I did find one *tiny* (that is a literal) mistake. In "Tutorial 7", it says that you can displays text 16 characters wide, and 8 rows down. However, when you display things in 8 rows, the very first row is pushed off the screen. Why? Because that is the way it is! So, in technicality, you can only display 7 rows, anything past there is pushed off the screen.

The information is VERY relevant and VERY well lain out...I think I will take note of some of the layout techniques for the the next version of IG (IonGuru)...if that isn't considered plagerism, however.
Matt H.

     13 April 2000, 02:49 GMT

Re: Re: Feature: TI-83 ASM Tutorial (Part 2)
Ciaran McCreesh  Account Info
(Web Page)

You can actually stop that. I would even tell you if I could remember how to do it for the ti83(+), I can do it on the ti86 no problem (there's a flag). Anyway, think about it, some of the OS screens (eg mode) use the bottom row...


     13 April 2000, 20:20 GMT

Re: Feature: TI-83 ASM Tutorial (Part 2)
KnightRT  Account Info
(Web Page)

Not bad. I still consider the ASM Guru Windows help file to be the best 83 ASM tutorial in existence.

http://www.ti-files.org/ archives/doc&util/asmguru.zip


     13 April 2000, 04:53 GMT

Re: Re: Feature: TI-83 ASM Tutorial (Part 2)
Jason Johnson  Account Info

I'm very good at BASIC programming, but don't know anything about ASM programming. is this ASMguru the best way to go if i'm a total beginner? this is for the 83 + btw, in case that matters.
thanx in advance.


     16 April 2000, 20:28 GMT

Re: Re: Re: Feature: TI-83 ASM Tutorial (Part 2)
David Hayes  Account Info
(Web Page)

ASMguru is for the plain 83, but it is probably the best ASM83 tutorial ever written. READ IT!!!

     24 April 2000, 06:06 GMT

Re: Feature: TI-83 ASM Tutorial (Part 2)
michael billiards

never posted b4, umm, i cant do asm. i tried. i suck. i like basic better, ive made some sweet programs for it....

     13 April 2000, 23:35 GMT

Re: Re: Feature: TI-83 ASM Tutorial (Part 2)
David Hayes  Account Info
(Web Page)

You need to learn ASM, it is much faster than basic.

     24 April 2000, 06:03 GMT
1  2  

You can change the number of comments per page in Account Preferences.

  Copyright © 1996-2012, the ticalc.org project. All rights reserved. | Contact Us | Disclaimer