Old Casio Calculator Learns New Tricks

[George Stagg] recently found himself stung by the burden of free time while in lockdown. Needing a project to keep him occupied, he decided to upgrade his 90s Casio CFX-9850G calculator to run custom machine code.

All [George] really wanted was for his vintage calculator to understand Reverse Polish Notation (RPN). The calculator in question can already run its own version of BASIC, however the bespoke Hitachi CPU struggles performance-wise with complex programs, and wouldn’t be a realistic way of using RPN on the calculator. An RPN interpreter written in assembly language would be much faster.

The first step in cracking this calculator wide open was a ROM dump, followed by writing a disassembler. Incredibly, the MAME framework already featured a ‘partial implementation’ of the calculator’s CPU, which was a much needed shot in the arm when it came time to write a full-featured emulator.

With the entire calculator emulated in software, the plan from here involved replacing one of the BASIC commands in ROM with new code that would jump to an address in RAM. With 32KB of RAM there ended up being plenty of room for experimentation, and uploading a program into RAM was simplified by using Casio’s original backup software to dump the RAM onto a PC. Here, the contents of RAM could be easily modified with custom code, then uploaded back into the calculator.

With RAM to burn, new routines were created to write custom characters to the screen, and a new font was created to squeeze more characters onto the display than normal. [George] ended up porting a Forth interpreter, which defaults to RPN style, to finally achieve his humble objective. He also managed to get a version of Conway’s Game Of Life running, check out the video after the break.

We can’t get enough of our calculator hacks here, so make sure to check out the CPU transplant on this vintage Soviet calculator.

Continue reading “Old Casio Calculator Learns New Tricks”

DIY Forth On Arduino

On a recent rainy afternoon, [Thanassis Tsiodras] decided to build his own Forth for the Arduino to relieve the boredom. One week of intense hacking later, he called it done and released his project as MiniForth on GitHub. [Thanassis] says he was inspired by our series of Forth articles from a few years back, and his goal was to build a Forth interpreter / compiler from scratch, put it into a Blue Pill microcontroller. That accomplished, he naturally decides to squeeze it into an Arduino Uno with only 2K of RAM.

Even if you are ambivalent about the Forth language, [Thanissis]’s project has some great ideas to check out. For example, he’s a big proponent of Makefile automation for repetitive tasks, and the project’s Makefile targets implements almost every task needed for development, building and testing his code.

Some development and testing tasks are easier to perform on the host computer. To that end, [Thanassis] tests his programs locally using the simavr simulator. The code is also portable, and he can compile it locally on the host and debug it using GDB along with Valgrind and AddressSanitizer to check for memory issues. He chose to write the program in C++ using only zero-cost abstractions, but found that compiling with the ArduinoSTL was too slow and used too much memory. No problem, [Thanassis] writes his own minimalist STL and implements several memory-saving hacks. As a final test, the Makefile can also execute a test suite of Forth commands, including a FizzBuzz algorithm, to check the resulting implementation.

Here’s a short video of MiniForth in action, blinking an LED on an UNO, and the video below the break shows each of the various Makefile tasks in operation. If you want to learn more, check out Elliot Williams’s Forth series which inspired [Thanassis] and this 2017 article discussing several different Forth implementations. Have you ever built your own compiler? Let us know in the comments below.

Continue reading “DIY Forth On Arduino”

Forth Module The Size Of A Stick Of Gum

Australian engineer [John Catsoulis] developed a small module called the Scamp2 dedicated to running Forth. The focus of his Udamonic project was not only to highlight Forth, but to make a module which was easy to use and doesn’t require any IDE on your computer. According to the website, these modules have found their niche in education as well as rapid prototyping for product development. His site has some good resources, including several Scamp/Forth example applications such as a model train controller or adding a real-time clock module.

The core of the module is a Microchip PIC24F64GB202 MCU with 64K Flash and 8K RAM. Of this, Forth takes up only 20K of Flash and 2K of RAM. [John] is using FlashForth, a version of Forth which came from [Mikael Nordman] at the University of Queensland almost ten years ago. FlashForth has been implemented on a wide variety of PIC and AVR ATmega processors and has apparently developed quite a following in Australia and elsewhere.

We estimate from the photo that the Scamp is about 80 mm long, just slightly longer than a standard piece of MIL-A-A-20175A Type II chewing gum ( 73 mm ). You can use it as-is, or with the header pins installed, the Scamp can be plugged into a breadboard for easy hacking. Regarding the interfacing of Scamp to other equipment, [John] says “Writing software to use other hardware is very easy, and fun.” We like his attitude.

Here is some more information from his Hackaday.io project page, and he also has a Tindie site. If you want a good overview of using Forth in embedded systems, check out Forth: The Hacker’s Language by our own Forth-guru [Elliot Williams]. Thanks to [Stephen Walters] for sending in the tip.

Continue reading “Forth Module The Size Of A Stick Of Gum”

Gaming In Different Languages

One of the perks of using older hardware is its comparative simplicity and extensive documentation. After years or decades of users programming on a platform, the amount of knowledge available for it can become extensive. This is certainly the case with the 6502 microprocessor, used in old Apple computers and some video game systems from the ’80s. The extensive amount of resources available make it a prime candidate in exploring various programming languages, and their advantages and disadvantage.

This project looks into those differences using a robot game, which has been programmed four different ways in three languages. [Joey] created the game in Python first and then began to port it to the 65C02, a CMOS variant of the 6502. The first iteration is its assembly language, and then a second iteration with optimized assembly code. From there, he ports it to C and then finally to Forth. Each version of the game is available to play in a browser using an emulator to run the 6502 hardware.

Since the games run in the browser, other tools are available to examine the way the game runs in each language. Registers can be viewed in real time, as well as the values stored in the memory. It’s an interesting look at an old piece of hardware and of its inner workings. For an even deeper dive into the 6502, it’s possible to build a working computer on breadboards using one.

Pocket Forth Invades Your TI Calculator

TI certainly have certainly seen off rivals such as HP or Casio to capture the lion’s share of the calculator market. The TI-84 is a real staple, and with as many units as there are out there, hacking them is a given. However, selecting an operating system for the machine can be a hassle. TI-OS is proprietary and doesn’t really want to let you do everything you’d like to. There are alternatives, but many of them won’t let you easily use your calculator to be — well — a calculator.

[Siraben] has zkeme80 which is essentially ANS Forth (mostly) with extensions for the TI hardware. You can easily extend the system, of course, because it is Forth. You can also use the machine for its intended purpose easily.

Continue reading “Pocket Forth Invades Your TI Calculator”

Web Pages Via Forth

Forth. You either love it or you hate it. If you have struggled to work on tiny microcontrollers, you probably are in the first camp. After all, bringing up a minimal Forth system is pretty simple and requires very little resources on the CPU. Once you have such an environment it is then easy to extend Forth in Forth. [Remko] decided he wanted to build a Forth compiler that uses WebAssembly and runs in your browser. Why? We’ve learned not to think about that question too much.

The world has changed a lot since the first introduction of the WorldWideWeb browser in 1990. What started out as a way to show text documents over the network has become — for better or worse — an application platform. JavaScript won the browser scripting language wars and security concerns pretty much killed Java applets and Flash. But JavaScript isn’t always fast. Sure, there are ways to do just in time compiling, such as Google’s V8 engine. But that compile step takes time, too. Enter WebAssembly (or Wasm).

Continue reading “Web Pages Via Forth”

Forth Version 1 Runs Again

Some people love Forth and some people hate it. However, you usually think of Forth as something running on a little computer such as an 8-bit microcomputer. When [Chuck Moore] developed the system back in the 1960s though, it ran on an IBM 1130. [Carl Claunch] took a scanned listing of the original code and got it running once again.

There are actually a few blog posts with details. Luckily, Forth is pretty simple — especially the core parts. However, there are a lot of differences from a modern Forth. The most obvious is that the dot keyword starts a definition and does not print the top of stack. However, internal details are different too — the system, for example, stores characters in packed EBCDIC — an ASCII-like code used by IBM computers.

Continue reading “Forth Version 1 Runs Again”