Hello World!

A common approach to learning a new language is to show how to build a program that prints "Hello World" on the screen. Well, guess what? I'm not deviating from that approach! :) It works, but only if presented in the right manner. Here goes...

What do I want to do?

"Well, I want to 'build a program that shows "Hello World" on the screen.'"

Can I do what I want?

"No, I can't because I don't know the first step of making an assembly program. How do I do it?"

Well, the general, universal, steps are:

What do I have to do to prepare? / What do I have to work with?

"So, how do I start this assembling and linking stuff? What tools are available?"

First off, you need an assembler and a linker, so get them, whether it be by download or by CD or by USB thumb drive (floppy drive anyone? :)). The most popular assembler is TASM (shareware even after all these years) and the most popular linker is devpac8x. You want to use these programs (...right?), so read the documentation (for TASM, it's tasmman.htm). To cut to the chase (for the sake of time), the most simple usage of these two programs are:

tasm -80 -b %1.z80 %1.bin
devpac8x %1

Where %1 is the name of your program.

You might be wondering where these two lines go. They go on something called a command-line (e.g. DOS) on a computer. In my opinion, this is where an operating system comes alive. The command-line can be thought of as a platform, a base, a skeleton, where by adding programs and executables, it suddenly becomes a foreign structure/language of its own, which compels you to explore and exploit it in order to be able to use it to its full potential, to its theoretical, but abstracted maximum. The best way to know is to experience, so open up a console by clicking [Start], go to "Run..." and type in command.com (for Windows 98/ME) or cmd.exe (for Windows NT/2000/XP). Usually, a black background with white text showing your current folder (directory) appears. Type something, and you'll see it appear. Pressing enter will attempt to execute the command you just typed. However, don't press enter unless you know what you are doing! Otherwise, Something Bad might happen! :o

The easiest way to assemble a program is to keep everything (source file, assembler, linker, includes) in one folder (so you don't have to worry about the console finding a command - it's in the same directory). We'll start by creating this directory. Make a folder in your root drive (usually, that's C:) called Asm. It should be seen as C:\Asm, where C: is the drive and \Asm is the folder. Now put tasm.exe, devpac8x.com and tasm80.tab in that folder.

Now, let's say you have a source file "hello.z80" and you want to assemble it? Using this setup, make sure it's located in C:\Asm and go to that lovely black-and-white console. ;) The basis behind the console finding a program is it first searches inside the current directory. If it's not there, it looks in a search path, and if it still isn't there, it'll stop searching and tell you that (an error occurred). We want it to find TASM and devpac8x in the current directory, but (!) the current directory isn't necessarily going to always be C:\Asm. Therefore, you must change it to be so, with the following commands:

cd \
cd Asm

The command 'cd' is short for change directory. The first command changes to the upper-most parent/root directory (C:) and the second finds a child directory Asm and goes inside it. If you aren't sure what a command does, it's a good idea to get the default help, usually by just typing the command by itself, or appending a /?, -help, --help (or whatever works). So to get help on cd, you would type "cd /?" and a list of help syntax will show.

Now that you finally have everything set up, you can enter the commands, one once another finishes:

tasm -80 -b hello.z80 hello.bin
devpac8x hello

Ultimately, a hello.8xp will be generated that you can use with your linking program to send to your calculator.

Adapt...

Do these options not do what you need? Use the extra features. Don't know what they do? Research and read the documentation, and if all else fails, ask. Yes, don't be afraid to ask. Others might benefit from your question too! Remember, you're learning all this command-line technical stuff as a part of the process. Make sure you're doing your part of the work.

Now, can I do what I want?

1) "Almost. I know how to assemble, link, and send, but what about writing the source in the first place?"
2) "I entered the commands above but there's an error like "source file hello.z80 not found"? What's going on?"

To the first 'response', exactly. To the second 'response', are you realizing what you are doing? In more blatant terms, do you know why you are reading this guide? You are trying to convert a non-existant hello.z80 file source to .bin and then to .8xp. Well duh! You can't make something out of nothing! Don't over-chase yourself. Rather, pace yourself. Be ready and fluid.

While I'd like to get started on writing the programs, it's not quite the time yet, but we're almost there! That's because you need to make sure that the setup works. You need some source code to assemble. To make things easier (I'll explain later), you need to download an include file, ti83plus.inc, and place it inside the \Asm folder. Copy and paste the following into a new Notepad session ([Start], go to Run..., and type in "notepad"):

.nolist
#include "ti83plus.inc"
.list

.org userMem-2
	.db t2ByteTok,tasmCmp

	ld a,$00
	ld (curRow),a
	ld (curCol),a
	ld hl,hello_world
	B_CALL(_PutS)
	ret

hello_world:
	.db "Hello world!",$00
.end

Don't bother understanding it just yet - I'll get to that in good time. :) Save this file as hello.z80 inside your \Asm folder. What you are trying to do now is check if the assembling process works, not how the program works. Therefore, go to a console, change to the directory, and assemble+link the program. If you get a hello.8xp file, congrats! Send it to your calculator (make sure you back everything up! [disclaimer]) and run it.

"... huh?"

Not showing up in MirageOS? That's because MirageOS can't detect it without an Ion/MirageOS header. So how to run it? Fortunately, TI was nice enough to include a non-hackish way to run assembly programs on this calculator (in contrast to the TI-85 and TI-73). Go to the catalog (by pressing [2nd][0]) and select Asm(. Then, go to the program menu, select HELLO and execute the program. You should get something like this, in nice, big, TI-font letters:

Hello World!

Cool! So you now know how to assemble, link, transfer, and execute a program. :)

Is it effective?

The neatness of all this is that you can put your own self into the process and use whatever you think fits you. That is, I'm teaching you the concepts; you're supposed to see what works for you. If you think all this is fine, then you're set! If you feel that you want to use another assembler, use it! Notepad lacking features? Find another editor! Eww, all programs in one folder? Separate them! Too much typing? Is the 'asm name' syntax easier? Well, then use it! Don't restrict yourself to any style or way, for that's when you stop growing. Programming is an art - express yourself.

Continue...

Up to Table of Contents