{"id":15639911,"url":"https://github.com/siraben/ti84-forth","last_synced_at":"2026-04-02T01:32:07.168Z","repository":{"id":55125790,"uuid":"149642759","full_name":"siraben/ti84-forth","owner":"siraben","description":"A Forth implementation for the TI-84+ calculator.","archived":false,"fork":false,"pushed_at":"2024-05-23T06:58:37.000Z","size":218,"stargazers_count":100,"open_issues_count":2,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-02-04T11:08:31.159Z","etag":null,"topics":["assembly","calculator","forth","ti84","z80"],"latest_commit_sha":null,"homepage":"","language":"Assembly","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/siraben.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-20T17:01:41.000Z","updated_at":"2026-01-31T02:47:08.000Z","dependencies_parsed_at":"2024-10-22T21:37:29.388Z","dependency_job_id":null,"html_url":"https://github.com/siraben/ti84-forth","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/siraben/ti84-forth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siraben%2Fti84-forth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siraben%2Fti84-forth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siraben%2Fti84-forth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siraben%2Fti84-forth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/siraben","download_url":"https://codeload.github.com/siraben/ti84-forth/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siraben%2Fti84-forth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31293924,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T01:05:07.454Z","status":"ssl_error","status_checked_at":"2026-04-02T00:56:46.496Z","response_time":53,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assembly","calculator","forth","ti84","z80"],"created_at":"2024-10-03T11:28:12.668Z","updated_at":"2026-04-02T01:32:07.141Z","avatar_url":"https://github.com/siraben.png","language":"Assembly","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Forth implementation for the TI-84+ calculator\n![Defining DOUBLE](images/double-def.png)\n\n## Features\n- A 16-bit Forth on an 8-bit chip\n  - Contains ~225 words (and counting) for everything from memory\n  management to drawing pixels, decompilation, and even playing sounds\n  over the I/O port.\n- Support for writeback (persistent data across program runs). Use\n  `SIMG` (save image) and `LIMG` (load image) to save the words you've\n  defined in a session.\n- Highly readable and customizable implementation, see `forth.asm`.\n\n## Getting the interpreter\nDownload the latest binary from the\n[Releases](https://github.com/siraben/ti84-forth/releases) page or get\nthe bleeding edge output from the [GitHub Actions\nCI](https://github.com/siraben/ti84-forth/actions).\n\n### The Real Thing\n- A TI-84+ calculator!\n- [TI Connect CE](https://education.ti.com/en/products/computer-software/ti-connect-ce-sw)\n- (Optional) A 2.5 mm to 3.5 mm audio cable to connect the I/O port\n  with a speaker.\n\nFlash `forth.8xp` to your calculator. Make sure there's enough space\nand that you have backed up your calculator! An easy way to back up\nRAM contents is by creating a group, refer to the manual on how to do\nthis.\n\n## Why TI-84+?\nThis is a calculator that is more or less ubiquitous among high school\nand university students throughout the world. It's not going extinct\nanytime soon (except perhaps to newer models such as the TI-84 CE).\nBut let's face it. TI-BASIC is not a nice language; it's slow and\nsuffers from lack of low-level bindings. There's no REPL. We want a\nlanguage that gives the programmer the full power of the\ncalculator—treating it as the computer it is. In fact, people already\ndo, by writing assembly programs, but assembly has its share of\ndisadvantages.\n\n## Why Forth?\nAssembly is painful to program in. Programs crash at the slightest\nhint of error. Development is a slow process, and you have to keep\nreinventing the wheel with each program.\n\nWouldn't it be great to have a programming language on the TI-84+\nthat's much faster than TI-BASIC but easier to understand and as low\nlevel as assembly? Forth is just that. (Read _Starting FORTH_ for an\nexcellent introduction to Forth). It's low level, it's simple, but\nalso _easy to type_, especially when you're on a calculator with a\nnon-QWERTY keyboard. It is a very powerful language, allowing you to\ndo things like change the syntax of the language itself. `IF`,\n`WHILE`, `CONSTANT` etc. statements are all implemented in Forth!\nThink of it as an untyped C with a REPL and the power of Lisp macros.\n\nIt's also easy to implement incrementally through continuous testing.\nIn fact, once the base REPL was implemented, most of the programming\nand testing happened _on_ the calculator itself!\n\n## Building\n### Nix\n```sh\nnix build\n```\n### Mac/Linux\n- [spasm-ng Z80 assembler](https://github.com/alberthdev/spasm-ng)\n  - If you're on a Mac, you will need to install `openssl` as a\n    dependency, for instance on Homebrew:\n```shell\nbrew install openssl\ncd /usr/local/include\nln -s ../opt/openssl/include/openssl .\n```\n  - Compile the assembler with `make` (check required packages for\n    your system).\n\nCopy `forth.asm` into the cloned folder. Then run:\n\n```shell\n./spasm forth.asm forth.8xp\n```\n\n### Emulated\nThere are many emulators out there, one that doesn't require\ninstallation is\n[jsTIfied](https://www.cemetech.net/projects/jstified/). Read the\nwebsite's details for more information. You'll need to obtain a ROM\nimage as well, which I can't provide here, but a simple web search\nmight help.\n\n## Using the Interpreter\nRun the program with `Asm(prgmFORTH)`, hit `2nd` then `ALPHA` to enter\nalpha lock mode, and now you can type the characters from `A-Z`. Here\nare a couple of things to keep in mind.\n\n- Left and right arrows are bound to character delete and space insert\n  respectively.\n- Hitting `CLEAR` clears the current input line.\n- Hitting `ENTER` sends it over to the interpreter.\n\nIf you want to see the keymap, find the label `key_table` in\n`forth.asm`. This table maps the keys received by `KEY` to the\nappropriate character.\n\n### Typing ASCII Characters\nSee the `2nd` or `ALPHA` key combos (in blue on the calculator) for\ninformation on how to type the following characters: `[]{}\"?:`.\n\n| Character | Key Sequence  |\n| :---:     | :---:         |\n| `;`       | `2nd .`       |\n| `!`       | `2nd PRGM`    |\n| `@`       | `2nd APPS`    |\n| `=`       | `2nd MATH`    |\n| `'`       | `2nd +`       |\n| `\u003c`       | `2nd X,T,Θ,n` |\n| `\u003e`       | `2nd STAT`    |\n| `\\`       | `2nd ÷`       |\n| `_`       | `2nd VARS`    |\n\n## Exiting the Interpreter\nType `BYE` and hit `ENTER`.\n\nHere is the more concise \"Loading Forth Programs onto the Calculator\" section:\n\n## Loading Forth Programs onto the Calculator\n\nUse the provided `fmake.py` script to convert Forth source files to the TI-84+ executable format.\n\nRun the script to generate the assembly file:\n\n```sh\npython fmake.py hello.fs\n```\n\nTo also assemble it to a `.8xp` executable, add the `--assemble` flag:\n\n```sh\npython fmake.py hello.fs --assemble\n```\n\nTransfer `hello.8xp` to your calculator using [TI Connect CE](https://education.ti.com/en/products/computer-software/ti-connect-ce-sw) and load it into the interpreter by running `LOAD HELLO` in the Forth REPL on your calculator.\n\n## Example Programs\nSee `programs/` for program samples, including practical ones.\n\n## Available Words\n```text\nEXIT DUP + - AND OR XOR \u003c\u003c \u003e\u003e INVERT DROP SWAP OVER ROT -ROT 2DROP\n2DUP 2SWAP 1+ 1- 2+ 2- \u003eR R\u003e R@ 2\u003eR 2R\u003e RDROP 2RDROP LIT LITSTR S\" .Q\nTELL STRLEN STRCHR !  @ +!  -!  C!  C@ C@C!  CMOVE EXECUTE BASE PREC\nSTATE LATEST SP0 [ ] ?SE HERE DOCOL BUF BUFSZ WBUFP WBUF WBUFSZ RP0 H0\nF_IMMED F_HIDDEN F_LENMASK SCR ABS PLOTSS ' , C, SP@ SP!  RP@ RP!\nBRANCH 0BRANCH ?DUP = \u003c\u003e \u003e= \u003c= \u003c \u003e 0= KEY KEYC EMIT T.  ?  AKEY\nTO_ASCII * /MOD SQRT FRAND F.  FREAD F* FSQUARE F= FDUP FDROP FSWAP F+\nF/ FRCI F- FSQRT MD5 D/MOD UM* D+ M+ DS SPACE CR AT-XY PUTS PUTLN GETS\nGETC UNGETC WORD ?IMMED IMMED \u003eNFA \u003eCFA STR= FIND WB USED SIMG LIMG\n\u003eDFA CREATE DOCOL_H : ; (DOES\u003e) DOES\u003e PAGE HIDDEN ?HIDDEN MOD / NEGATE\nTRUE FALSE NOT LITERAL NIP TUCK ID.  HIDE IF THEN ELSE BEGIN UNTIL\nAGAIN WHILE REPEAT CHAR (COMP) CONST ALLOT CELLS RECURSE VAR DO LOOP\n+LOOP FORGET '0' '9' WITHIN NUM?  CFA\u003e PICK U.  UWIDTH SPACES U.R U.\n.  DEPTH .S HEX DEC SEE WORDS CASE OF ENDOF ENDCASE I J CSCR CBLK FBLK\nRUN LOAD SMIT PLOT WR PN BYE STAR\n```\nNote that floating point routines are commented out by default to save space.\n\n## Screenshots\n### Combine words in powerful, practical ways\nCombine low-level memory words with drawing words and user input words\nto create an arrow-key scrollable screen for viewing RAM memory. See\nthe 20 (or less) lines of code at `programs/memview.fs`.\n\n![What forth.asm looks like loaded into RAM](images/ram-screenshot.png)\n\n### TI-84+ inside\n![key-prog program](images/demo2.png)\n\n### Load programs\nSimple unfinished modal text editor with a scrollable screen.\n\n![Unfinished text editor](images/editor/1.png)\n\n## Design Notes\n### Use of Macros\nJudicious use of macros has greatly improved the readability of the code.\nThis was directly inspired by the _jonesforth_ implementation (see\nReading List).\n### Register Allocation\nOne notable feature of this Forth is the use of a register to keep\ntrack of the top element in the stack.\n\n| Z80 Register | Forth VM Register             |\n| :---:        | :---:                         |\n| DE           | Instruction pointer (IP)      |\n| HL           | Working register (W)          |\n| BC           | Top of stack (TOS)            |\n| IX           | Return stack pointer (RSP)    |\n| SP           | Parameter stack pointer (PSP) |\n\n### Reading List\nDocumentation can vary from very well-documented to resorting to\nhaving to read the source code of `spasm-ng` to figure out how\n`#macro` worked. See examples such as `defcode` and `defword`. I\ncouldn't make `defconst` or `defvar`, however, but this was fixed by\nwriting it out manually.\n\n- [General Z80 guide](http://jgmalcolm.com/z80/#advanced)\n- [Moving Forth](http://www.bradrodriguez.com/papers/moving1.htm)\n- [Learn TI-83 Plus Assembly In 28 Days](http://tutorials.eeems.ca/ASMin28Days/welcome.html)\n- [KnightOS Kernel](https://github.com/KnightOS/kernel)\n- [Starting FORTH](https://www.forth.com/starting-forth/)\n- [Jonesforth](http://git.annexia.org/?p=jonesforth.git)\n\n## To be Implemented\n- [x] Ability to read/write programs\n  - [x] `WB` word to write back ~~2048~~ 400 (see *Current Limitations*)\n         bytes of data starting from the address of `SCRATCH`.\n  - [x] Ability to \"execute\" strings (so that programs can be\n        interpreted).\n- [x] User input\n  - [x] String reading routines\n  - [x] Number reading routines (possible with `programs/number.fs`)\n- [x] Output\n  - [x] Displaying strings\n- [x] Proper support for compile/interpret mode\n- [x] Assembler to convert Forth words into `.dw` data segments to be\npasted into the program.\n- [x] Ability to switch to a \"plot\"\n- [x] REPL\n  - [x] Basic Read/Eval/Print/Loop\n  - [x] Allowing more than one word at a time input\n  - [x] Respect hidden flag to avoid infinite looping. (`:` makes the\n        word hidden).\n  - [x] Reading numbers (support for 0-10 inclusive hardcoded, but not\n        a general algorithm). See `programs/number.fs`\n- [ ] Document Forth words (partially done)\n- [ ] Add Z80 assembler in Forth (so ASM programs can be made!)\n- [x] Implement `DOES\u003e`\n- [x] Implement `SIMG` (save image) and `LIMG` (load image) to save\n      and load sessions.\n- [x] Add sound capabilities\n- [x] Add a way to put data on the screen as pixels (for export via\n      screenshots).\n- [ ] Add computer program to allow the user to select the words for a\n      custom Forth system.\n- [x] Implement `extract.py` to extract and decode binary data from a PNG image, allowing analysis and debugging of the stored image data.\n\n## Current Limitations\n- [x] REPL prints out \"ok\" at the end of each word parsed, `QUIT` not\n      implemented.\n- [ ] Indirect threading means we cannot use scratch space in addresses\n      higher than `$C000` as if the program counter exceeds `$C000` it\n      crashes the OS.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiraben%2Fti84-forth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsiraben%2Fti84-forth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiraben%2Fti84-forth/lists"}