close
close

Dr. Scott M. Baker uses Anthropic’s Claude AI to write a Forth program for a vintage Micro

Dr. Scott M. Baker uses Anthropic’s Claude AI to write a Forth program for a vintage Micro

Vintage computing enthusiast Dr. Scott M. Baker had a little help with his latest project, writing a Forth-based version of Mary Had a Little Lamb for a Texas Instruments TM990 microcomputer: Anthropic’s Claude Large Language Model (LLM).

“I’ve been working on a new project for a TM990 computer and have built an AY-3-8910 sound generator board for it,” explains Baker. “My TM990 has a FIG-Forth running on it, so I thought I’d write a music player in Forth. But this time I’m not going to write it myself, I’m going to use my trusty AI (artificial intelligence) assistant Claude-3.5-sonnet from a website called Poe, which makes it easy to try out AI algorithms. I started with a simple request: ‘Write a Forth program to play Mary Had a Little Lamb on an AY-3-8910 sound chip.’ Within a few seconds, Claude responded.”

LLM-powered chatbots that help with programming tasks are a hot topic right now, but they are not only usable for modern languages. (📹: Dr. Scott. M. Baker)

As anyone who has experimented with large language models (LLMs) before will expect, Claude’s response was definitely answer-like — impressive considering how sparse Forth-based software sources were in the training data Anthropic used to create the model. “Claude made some assumptions about my hardware that didn’t match reality,” Baker noted, which required some back-and-forth to resolve the issues — starting with creating a replacement for a supposedly existing but missing “ms” word for the delay between notes.

What followed was a series of refinements, with Claude’s chatbot “apologising” each time a correction or revision was required – even when the revision was not part of the original request, such as ensuring the program was compatible with FIG-Forth. At each step, a careful, trained eye was required to spot areas where the program was making subtle errors – such as using the wrong register numbers or miscalculating the timing so that the song was slowed down to one-twentieth of its original speed, which then produced pitches one-third of the expected frequency.

Baker found that these errors were becoming more and more frequent. “Suffice it to say, we’re getting less right rather than more,” he noted after a “fix” that required a calculation that exceeded the 16-bit capabilities of the Texas Instruments TMS9900 CPU at the heart of the TM990. Eventually, however, Baker managed to get Claude to the right output: a working program written in FIG-Forth that, via a sound card add-on, causes the TM990 to play Mary Had a Little Lamb.

Baker’s full description, including the source code for the finished program, is available on his website.

Leave a Reply

Your email address will not be published. Required fields are marked *