The Ultimate Guide Axe Parser

The Ultimate Guide

Introduction

If I had eight hours to chop down a tree, I'd spend six hours sharpening my Axe.

— Abraham Lincoln (1809–1865)

So you want to learn Axe, huh?

TI-BASIC ≠ Axe. Got it?

First of all, you need to know what it is. You may have heard that Axe is brilliant, that programs made in Axe are amazing and freakin' fast. That's all true, but most importantly, Axe is a language.

In other words, it's a different beast entirely from TI-BASIC. You may have heard of xLIB or Celtic III, which are libraries, generally applications that add extra functions to the BASIC parser. Axe is different. It's not just a library—it's a whole other language.

The best way to get this into your brain is to show you, so let's go ahead and make our first Axe program. Go into your calculator's program editor and create a program called AHELLO with the following in it:

PROGRAM:AHELLO
:.HELLO My first Axe program!
:"Hello, world!"→Str1
:Disp Str1
:Return

Looks familiar, doesn't it? (It should. We highly recommend learning TI-BASIC first to get a good feel for how the calculator works before starting out in Axe.) Now open Axe and go into Options. Press 2nd once so Shell changes to Ion. We'll keep the settings like this for now on—the reason will be explained later in this tutorial.

Now press CLEAR to go back to the main menu, and select Compile. AHELLO should be listed; select it.

 COMPILE Ion
>:AHELLO

Wait, that was new. What did that do? Well, that's my point, and it's going to be our first Big Point of these lessons (since I couldn't come up with a better name):

✓ Big Point #1

Axe is a language, completely distinct from BASIC.

One of the ways it's different is that it needs to be compiled. Like in any good language except Python, what you see is what you write, but the processor can't read it—it needs to be converted first. Press PRGM and you'll see what I mean.

EXEC EDIT NEW
1:AHELLO
2:HELLO

You'll notice that Axe has created a new program called HELLO. This is the compiled program, the executable, which is in a form the calculator can use. Run the program with the line Asm(prgmHELLO). The Asm( token is found in 2ND > [CATALOG].

Asm(prgmHELLO
Hello, worldDone

Well, it did what was expected, but it felt different, didn't it? Time to break it down.

The first line of your program started with .HELLO. This tells Axe to name the executable program HELLO. Everything that comes after it (My first Axe program!, in this case) is a description that appears when you run the program from a shell. It's not required, but it makes your program look better.

The second line was "Hello, world!"→Str1, which stores Hello, world! to the static variable Str1. (It's called "static" because you can't directly change its value once it's defined—more on this later.)

The third line simply displayed each character stored at Str1. Seems easy enough, but it's really different from the way Disp works in BASIC. You'll see this soon enough.

Finally, the program ends with Return. Like in BASIC, it tells the program to quit. Again like in BASIC, it's not required, but you should always include it anyway—it makes your code more structured and much easier to understand, and it becomes important when you start using subroutines.

That's all what you typed in the program editor. It's not something the calculator understands, though. You can try running it as a normal program, and it'll give you a syntax error at the .HELLO, as expected. Axe is a compiler, and what it does is it reads your source code and spits out an ASM version. That's right, program HELLO pure assembly. You can now send it to any other calculator, and it'll run fine with Asm(. Better yet, since you compiled it for Ion (which uses a format supported by virtually every popular shell), you can now run the program from MirageOS or DoorsCS, just like all those other great games out there! Okay, not really.

x Big Trap #1

Don't forget to compile after you update a program.

So, what do you think? Go on to lesson 1 and start learning Axe!

« Table of contents »