ticalc.org
Basics Archives Community Services Programming
Hardware Help About Search Your Account
   Home :: Programming :: Columns and Tutorials :: TI-83 Assembly Logs Vol. 4
TI-83 Assembly Logs Vol. 4

by Phil

Editor's note: The information contained in this article may be outdated and/or inaccurate.

INTRODUCTION

Well, today we're learning about a very important element in any ASM program, or in ANY program that is. We're learning about display functions. First, I'll be talking a little about labels again, just to refresh you, and then I'll be getting into text display commands.

RECAP ON LABELS

Now, I hope you remember how to use labels. If not, here's a small reminder:

LABEL_ONE:
        ld a,6
        jp LABEL_ONE

Lables work the same way in ASM as they do in BASIC, except for the way you 'Goto' them. Labels in ASM require a 'jp' command. If you forgot about the 'jp' command, I suggest you read my previous logs, or just pretend you know and continue.

TEXT DISPLAY

Now that was short, wasn't it? That should be all you need to know, because I am going to tell you of a new way to call labels. first, I'll show you a simple load command:

        ld a,5

This loads the number 5 into 'a', right? Good. Now, here is a little more complicated rutine (or command, I'll refer to them as either):

        ld (currow),a

I effect, if the accumulator, or 'a', were set to 5 as stated above, this will load 'a', or 5, into the variable '(currow)'. "What is (currow), Phil?" you ask? Well, on the home screen, each letter or number takes up one block. You can fit 8 of these blocks along the side of the screen, going down, right? This means there are 8 rows on the home screen, or the "cursor" screen. CURsor ROW. CURROW. '(currow)', get it? Now that the '(currow)' is set to 5, the cursor will move there, ready to print something.

Here's another load rutine:

        ld a,6
        ld (curcol),a

You might be asking, "Phil, I know what '(currow)' is now, but what is '(curcol)'?" Well, it is very similer to '(currow)'. If you were looking at the home screen, or cursor screen, you will see that you can fit 16 numbers or letters (or symbols) in a row. This means that there are 16 columns on the cursor screen. CURsor COLumn. CURCOL. '(curcol)', get it? Good.

Now we have selected the cursor to be at (5,6). On the 83, that would look like this:

   1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6
 « - - - - - - - - - - - - - - - - »
1|                                 |
2|                                 |
3|                                 |
4|                                |
5|                                 |
6|                                 |
7|                                 |
8|                                 |
 « - - - - - - - - - - - - - - - - »

Now that's pretty easy to understand if you know how to use BASIC's 'Output(' command. The problem is, if you use BASIC's 'Output(' command like this...

Output(5,6

...you will get an error. What you need is something to say, something to write on the screen. That's where labels come in.

Now, the command that you would use to display (I'll talk about it later) needs an input of '(currow)', '(curcol)', and 'hl', kind of like how 'Output(' needs a X coordinate, a Y coordinate, and a string to output. If you wanted to do this in basic...

Output(5,6,Str1)

...you would need to define 'Str1' somewhere in the program before this point. In ASM, though, you can define strings anywhere you want to in the program, because the program treats them as labels.

I want my program to say "Hi there!", so I need someway a getting that into 'hl'. Here's how. I would first make a label called, oh lets call it 'STRING_ONE' for the hell of it. This is that label:

STRING_ONE:

Now, I need to write the string. The command for doing this is '.db'. I don't know, what '.db' stands for, and I don't really care as long as it gets the job done. Anything after '.db' on a line is considered a string. So I'll put my string in.

STRING_ONE:
        .db "Hi there!"

The only thing is, you have to tell the program when the string is over. To do so, just add a comma and a 0 after the text.

STRING_ONE
        .db "Hi there!",0

(If you can't make it out, that's a zero, not an "oh")

Now, I need to get all of this into 'hl'. This is really easy. All I have to do is load the label into the variable, and viola! This is done like so:

        ld hl,STRING_ONE

"Now I'm done, right Phil?" Nope. There's one more thing that has to be done. You have the X variable, the Y variable, and the string, but I haven't told you the command to display the message on the screen yet. The command is '_puts', and you have to call it like '_clrLCDFull'. As a little hint, all commands that start with an underscore are required to be called, with the 'call' command. Here's that command:

        call _puts

Alright. We have the X variable, the Y variable, the String, and we've displayed the string on the screen. The program is complete. Here, now, for you to view, is the entire program from start to finish. I will add some notes to the source too, just so you can understand each line.

.NOLIST                 ;You ought to know what this is by now.
#define equ .equ
#define EQU .equ
#define end .end
#include "ti83asm.inc"
#include "tokens.inc"
.LIST
.org 9327h
        call _clrLCDFull        ;Clear the screen
        ld a,5                  ;load 5 into acc.
        ld (currow),a           ;load acc. (5) into (currow)
        ld a,6                  ;load 6 into acc.
        ld (curcol),a           ;load acc. (6) into (curcol)
        ld hl,STRING_ONE        ;load string STRING_ONE into hl
        call _puts              ;displays
        ret                     ;returns to origional program
STRING_ONE:                     ;Label STRING_ONE follows
        .db "Hi there!",0       ;defines string as "Hi there!"
.end
end                             ;ends program

Cool. Now assemble it as I told you in the first volume, and have a great time. Change the location of the text! Change the message! Whoopee!

Thanks just about everyone. If you've read the others, you know em' pretty well by now.

Thanks for your time, and I'll see you in the ASM Log 5! -Phil

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