ti 84 plus : Compile and run an hello world C program

This is an howto about C compilation for ti83 calculator.

This is not very hard if you follow my instructions ;)

This topic will talk about C programming for TI83 regular (neither ti84+ nor ti83+).
As you will see, this is not really hard, there are only few things to know like “unsquishing” and “-startup=10″ for example…
I already done the same job for ti84+ or ti83+, this is even easier, let me know if you want a topic on it :)

There’s some kind of compiler for z80 platform, you can use sdcc or z88dk.
Here I only tested with z88dk.

Let’s start by downloading z88dk :

sudo apt-get install z88dk

(debian/ubuntu)

OR

wget http://sourceforge.net/projects/z88dk/files/z88dk/1.9/z88dk-src-1.9.tgz/download

OR

Simply click here : http://sourceforge.net/projects/z88dk/files/z88dk/1.9/z88dk-src-1.9.tgz/download]http://sourceforge.net/projects/z88dk/files/z88dk/1.9/z88dk-src-1.9.tgz/download

 

Then install it :)

You also need to get bin2bin83 as you will produce a noshell program.
You can get it here :
http://www.ticalc.org/pub/unix/bin2bin83.zip]http://www.ticalc.org/pub/unix/bin2bin83.zip

Compile it and put it in your path.

Do the same job for bin2var :
http://www.ticalc.org/archives/files/fileinfo/143/14394.html]http://www.ticalc.org/archives/files/fileinfo/143/14394.html

Ok now you have a compiler “zcc” or “z88dk-zcc” and a linker and even z80asm (which is a assembler for z80 like spasm or tasm)
If you want to do asm stuff, prefer spasm to z80asm.

There’s also a LPG soft called “zasm” but there’s some syntax differences and nobody use it (z80asm has a big community outside the calc community)

Let’s start by a small C file which should work (impossible to find a ti83 regular C hello world on the web so I done mine…)
We simply do a printf and a while loop.

The loop is to have the time to see the result before the program exit.

We test it.

1
2
3
4
5
6
7
8
#include <stdio.h>
main() {
 
      printf("hello world\n\n\n\n");
      while (1) {
           // loop forever
      }
}

We try to compile like the tutorial here : http://www.z88dk.org/wiki/doku.php?id=platform:ticalc]http://www.z88dk.org/wiki/doku.php?id=platform:ticalc

zcc +ti83 -lm -o hello -create-app hello.c

Some details about this command :
zcc : compiler
+ti83 : the target (the model which could be ti82, ti86 etc… or even zx spectrum ->”-zx”).
-lm : link and keep the file .map
-o hello : output filename
-create-app : do the bin2var job
hello.c : source file

When loading it, it doesn’t run (without shell)

Let’s study the code.

As there’s often some trouble to launch a file without shell using Send(8pgrmHELLO I will use my own tool to unsquish the code then use bin2var after that instead of using the embedded z88dk create application.

Just to see if it’s better… :p

Here’s the Makefile :

all:
zcc +ti83ansi -lm -o hello hello.c
bin2bin83 hello
bin2var output.bin OUTPUT.83p

clean:
rm *.83p

If we look inside the generated hex code, it’s better.
All seems OK (header, unsquished code, footer etc…) but when I run it, nothing appears.

We need something more : http://www.z88dk.org/wiki/doku.php?id=platform:ticalc#ti83]http://www.z88dk.org/wiki/doku.php?id=platform:ticalc#ti83

We need to specify which shell to use (here noshell is “TI OS”)

So we add “-startup=10″ to our command line.

Here’s the Makefile :

all:
zcc +ti83ansi -lm -startup=10 -o hello hello.c
bin2bin83 hello
bin2var output.bin OUTPUT.83p

clean:
rm *.83p

With our hello world which is simply the same code as before :

1
2
3
4
5
6
7
8
#include <stdio.h>
main() {
 
      printf("hello world\n\n\n\n");
      while (1) {
           // loop forever
      }
}

I do :

make

Then we load the file into the emulator like TilEm2.

Then on the calc type :

send(9pgrmHello

And we get :
hello-world-c

Victory !! ;)

I also have some more advanced code samples, tell me if you’re interested in.

Leave a Reply

© 2020 ti-84-plus.com. All Rights Reserved. Theme WP Castle by Saeed Salam.