Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: I'm 17 and I created a Forth interpreter for the TI-84+ calculator
56 points by DogestFogey 3 months ago | hide | past | web | favorite | 15 comments

Hi HN!

For the past year I've been getting into programming in Z80 assembly (especially for the TI-84+). More recently I've been learning about the Forth programming language and after a lot of searching online (in vain) for a Forth interpreter for the TI-84, I decided to write one myself. It's been fun demoing this to others, because it's a very unexpected use of a calculator.

It's my largest project to date, and I'm interested to know what the HN community thinks, please feel free to critique my code!

-- Ben

Great work and accomplishment, but even better that you are giving Forth some much needed advertising boost: small, light and fast, it's ideal for embedded devices, which is why it has been used for running space ships and powering the OpenBoot PROM in Sun, IBM and Apple systems.

The computer industry needs more people like you.

I remember writing a text adventure game on my TI 83+ in high school, thinking I was a hacker extraordinaire. In reality it was just a bunch of If and Print statements.

What you did is truly incredible.

Hey, if you like forth, check out the GA144. It's amazing. You can do things with it you can't do with anything else, like make viruses in one word of memory, with several useful applications. Underrated, with a small community, but very fun and rewarding too.

> make viruses in one word of memory

OT, but with PDP-11 you could write 103737 (in octal), which propagated across memory (backwards).

10 means "move", first 37 means "from what R7 is pointing to, autodecrementing R7 before copying", second 37 is "to what R7 is poiting to, autodecrementing R7 before copying". R7 is the program counter, so this operation was copied one word (16 bits) before the executing instruction and then control was passed to that new word.

Of course, with GA144 you can have up to 4 commands in a single 18-bit long instruction, so opportunities are better...

I started my programming career on a TI 84+ SE. I bought it a year earlier than was required because I had friend in higher level math that had to have them and they showed my how you could program and run right on the device. My parents told me they wouldn't pay for it (it was over $100 IIRC) because I didn't need it yet but that if I did buy it they would reimburse me when I did need it. I wore the labels off the buttons of that thing (I still have it!) and the number of programs I wrote on it numbered in the 100s. I'd write games, solvers, utilities, etc, after some googling I even found some of things I actually posted online [0]. I was very active on a number of TI calculator programming forums and worked on an adventure game with my friend.

I still remember being amazed by xlib [1], a util to give you access to things only assembly programs could do in TI-BASIC. This meant you could do ALL your programming on the calculator itself but leverage things like clearing the screen, drawing a sprite, scroll the screen and more. This added capability blew my mind and I used it heavily in my development. After that I realized you could use this (very crappy, but I didn't know it at the time) "IDE" toolset from TI that ran on my computer. I remember the OS X and Windows versions didn't have feature parity and so I always liked using my friend's Mac because it was easier. Being able to code on the computer and push my code to my calculator was another huge step forward for me but I still loved being able to make tweaks on the go.

I never did jump into Z80 though, it was a little too arcane for me at the time and by this point I'd hit my 10th grade year (Sophomore in High School) and I could finally take the "Intro to Programming" class offered by my school where I learned Java. That really changed things for me, curly braces and the ability to group and abstract code crazy concepts to me but I picked them up fast enough.

I'm going to go ahead and stop here because I realize I've rambled on and this is a pretty off-topic comment as-is without me going into my history of programming.

[0] http://calcg.org/cgi-bin/files.cgi?action=autha&autha=Josh+S...

[1] http://tibasicdev.wikidot.com/xlib

I'm 17 and also _started_ writing a (Asm) forth interpreter, so well done for finishing it.

The code looks readable and pretty clean. Very cool.

If you want to continue down the Z80 route, and have too much time on your hands, I recommend designing a simple IR and building a little compiler/code generator for the Z80 (twas fun for me).

What instruction set are you building this for?

amd64/x86_64(Whatever): I was only really writing it on the bus as a distraction so I was relatively tempted to write it for MMIX (a la Knuth)

Rock on mate - I came from the same place 40 years ago. But. no language is ever complete for me unless I canz Space Invader. I guess your now onto lisp? Do the Space Invader first in your Forth. Chuck is a god.

I found out about Lisp a year before Forth! Working through SICP, watching the lectures and of course writing lots of Scheme programs have really helped me improve.

But it's weird. It's almost never useful at implementation. It's like Chuck and the guy from TLA+ say. The important thing is just asking THE question. Props to ADA Lovelace for basically inventing that.

I had many attempts at writing my language from the age of 14 to the age 17 with no success: the problem I did not any thing about theory (grammars, parsers, ...)!

The beauty of Forth is that parsing is trivial, just read a space-delimited word from the input buffer and do a simple string lookup through a linked list. The syntax is whatever you want it to be. For me, I modeled my interpreter/compiler heavily off of the jonesforth implementation in x86 assembly.

Cool, how about write some Z80 code for the Microbee computer, its an Australian computer which was very popular with schools in Australia in the 1980's

Grear work man, love seeing other young people building cool projects like this, it really shows the good the internet has done for us.

Applications are open for YC Summer 2019

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact