'Text to TI-BASIC Compiling
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.
Solution 1:[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:
- https://github.com/miselin/tibasic (Nov 2013), previously at http://tibasic.sourceforge.net/ I think. Command line app by pcmattman.
- It was then forked and improved at https://sourceforge.net/projects/tibasicc/ by Noah. The EXE did not appear to work on it’s own. I managed to compile my own EXE but the decompiler seemed quite buggy. Haven’t tested the compiler yet, but it seems to have pre-processing and comment-stripping functionality, in theory.
- https://github.com/Darmo117/TI-83_Compiler (Oct 2017), Java - buggy, couldn't get it to run on my programs.
- https://github.com/Lekensteyn/parse8xp - Written in Python. It garbled a lot of text, not working very well.
- https://github.com/SmellyModder/TI8xp - Java lib for compiling/decompiling. Couldn’t test it yet because I don’t know how to run it from command line.
Writing a compiler from scratch would involve:
Understanding the 8XP file format, see here
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
