2

So as a Year 10 Centre For Excellence student, we are required to buy ourselves a TI-84+ calculator. This is a Calculator by Texas Instruments. The company has created a high-level programming language by the name of TI-BASIC (after a quick google it is derived from the original language BASIC.) Now, I have been sifting through the internet, but I think I am only reaching the surface. I feel like I haven't even hit clay that's how vague I think I am on this topic. On that note, I'm sorry if my language isn't correct. :/

I have managed to come across many many compilers that compile a plain text document (.txt) right into a TI 8 Series Program document (.8Xp). So my questions are:

  • How does one create their own compiler?
  • What low-level language does the calculator read?
  • When converting I understand I would need to use regexes, but what do I convert it to?
  • Finally, do I just write it into TI-BASIC and plunk it onto the calculator?

Things seem to massively confuse me at this point. The topic has only reached the surface of my mind.

AstroCB
  • 12,337
  • 20
  • 57
  • 73
TheBrenny
  • 528
  • 3
  • 19
  • Why would you write your own compiler? Is that a goal of yours? I haven't used TI's calculators, but on Casio's graphing calculators you'd write the BASIC code directly on the calculator (there was a BASIC IDE on the calculator). The TI 84+ uses a Z80 CPU IIRC, and I think you can write programs for it in Z80 assembly if you want to. – Michael Feb 12 '14 at 12:44
  • So I would have to learn which Z80 commands are tied in with the TI-BASIC commands? See this is where my confusion comes from. I haven't played around with writing low-level code. I've always used high-level and compiled it. I've done a little more research, but things are conflicting in my mind. Couldn't I just convert the words into their respective 'tokens' defined by TI, save it as a .8xp and problem solved? – TheBrenny Feb 12 '14 at 14:28
  • If you program in TI-BASIC you only have to learn TI-BASIC. If you want to do more low-level programming you'll have to learn whatever language is suitable for the task (e.g. C or Z80 assembly). – Michael Feb 12 '14 at 14:33

2 Answers2

2

If you are truly trying to create a TI-BASIC "compiler" for the computer, you need to see what tokens everything has. TI-BASIC works on the idea that things like If, Disp are all actually 1 or 2 byte tokens that get parsed by the calculator when it is run, parsed meaning they each execute a series of instructions in real time which is a relatively slow process (like scripting). Heres the Token List. So really its just a matter of converting everything to their respective tokens. Past that I really have no idea how the .8xp file structure is formatted, and you would have to google that (plenty of people have done it, calculator forms like Omnimaga can help you there).

If you just want one on the computer to work with rather than making one, you can use TokenIDE which in my opinion is one of the best, but there are others.

Also, as the comments said the calculators base language is actually Z80 assembly (makes sense as the cpu is a Z80), and there are a few languages that actually go from calculator tokens into compiled assembly sort of like C++, the most popular and amazingly designed one being Axe Parser. This is helpful if you want to work with more low-level features of the calculator without actually learning assembly fully, but it does require you to learn the Axe language which can be tricky if you are not familiar with how pointers and how data is stored in the memory. Real assembly can be transferred directly to the calculator as .8xp but with a different format so it knows the data is actually opcodes rather than tokens, and will allow you to run it with the Asm( command.

Hope that helps.

Lemon Drop
  • 2,113
  • 2
  • 19
  • 34
  • I feel like I'm quick to judge to say that this is the right answer. But right now, it seems the most logical. I have been using TokenIDE but I just like the feeling you get when you actually complete something. I set standards too high for myself, so I never really get it. Thank you for the answer, though. It will most probably help me. :) – TheBrenny Feb 13 '14 at 10:49
  • Cemetech's tool [SourceCoder](https://www.cemetech.net/sc/) is also a good choice to develop in TI-BASIC, Axe, or z80 assembly, but it has its own syntax and requires registering an account. – lirtosiast Aug 17 '15 at 17:13
  • Spork Interactive has written a Python 2 script to convert between 8xp and sources: http://tibasicdev.wikidot.com/forum/t-184793/python-ti83-basic-converter – Lekensteyn Oct 20 '15 at 12:32
1

These days you can code TI-84+ programs using TI Connect CE and transfer it to your calculator easily, so there's less need for a standalone compiler.

However I was looking for a way to pre-process some of my programs to strip out comments, provide some extra syntactic-sugar, and optimize filesize.

In this case there's a need for a command-line 8XP compiler. I found several projects that attempted to do this but none of them really seem robust:

Writing a compiler from scratch would involve:

  1. Understanding the 8XP file format, see here

  2. Converting relevant text strings into binary "tokens". These pages explain the tokens and the hexadecimal bytes used for each of those tokens.

If anyone else has more information, it would be useful to document here.

Simon East
  • 55,742
  • 17
  • 139
  • 133