8008 1k Tiny BASIC

Attempting to get a workable BASIC interpreter in 1k of 8008 assembler code.

Similar projects worth following
The 8008 is a very primitive 8 bit CPU and the first 8 bit CPU which was easily available to home computer designers.

It has one high level language, SCELBAL, which is 8k of code. I am writing a Tiny BASIC which will (hopefully) fit in 1k of 8008 code.

8008 code resembles 8080 code with half the instructions removed. Or a Z80 with 90% of them removed.

Current state : about 570 bytes, missing IF, Subroutine/Return, keyboard test command. Est final size, about 680 bytes.

As I don't own an 8008 machine it is running on an emulator which simulates very simple terminal I/O. Hence we have a serial UART driving a teletypewriter and 32 key keyboard with shift keys to generate ASCII codes, with 2 74151 multiplexers and assorted latches and counters to get keystrokes. (A bit odd, most keyboards of that era have ROMs in them)

I can't find a link option ; the project is hosted on github at

I'll upload the basic listing file to files when it is completed.


Assembly Listing

lst - 68.88 kB - 01/06/2017 at 20:30



Assembly Source

x-asm - 29.69 kB - 01/06/2017 at 20:30


  • Code Complete

    Paul Robson01/01/2017 at 15:50 0 comments

    What it says .... it's complete and apparently working okay. Code size is 722 bytes. Currently the source compiles to 725 bytes + some extra code after $400 ; this code allows me to put code in the assembly which is loaded on new - it's quicker than typing it in manually.

    The < 768 bytes would actually matter ; ROMs in these days were often 256 x 8 bytes, so it's the difference between 3 and 4 of them.

  • State of Play 1 Jan

    Paul Robson01/01/2017 at 11:21 0 comments

    Well, having sobered up after Christmas, the project is nearly completed. It is currently running at $000-$29C - 668 bytes. 3 of those are a 'hack' put in so I can load code in without typing it in, which wouldn't be in the final build.

    Currently implemented commands are FETCH, GOTO, IF, LET, NEW, OUT, PRINT, STOP, VIEW and XECUTE. The reason for the renaming is I decode on the first character only (so I can't have IF and INPUT). So FETCH is INPUT, VIEW is LIST and XECUTE is RUN.

    Currently outstanding are GOSUB/RETURN which means the interpreter is likely to come in in under 3 pages.

    In places it is horribly wasteful of CPU time and data memory, but then it's designed to minimise code memory.

    I appreciate the people who worked on the MCM/70 system - an 8008 APL Laptop from the early 1970s. It's an interesting machine to program for to put it mildly.

  • State of Play 15-Dec

    Paul Robson12/15/2016 at 22:02 0 comments

    The project is about 570 bytes long, which includes : program editing/listing, evaluation, assignment, GOTO, INPUT, PRINT.

    Outstanding are GOSUB/RETURN (will actually be CALL/RETURN), a conditional statement, and a command which is a bit like INKEY.

    Some things may be improved later if space permits ; the evaluator was written first and is about 110 bytes but needs some better error checking - it doesn't crash, it just accepts bad syntax.

    The project is very wasteful of RAM - deliberately to save program memory :)

View all 3 project logs

  • 1
    Step 1

    The simplest way to build it is using NETBEANS 8.2 ; it also requires SDL 2, but nothing else. To build the assembler you need Alfred Arnold's AS Cross Assembler.

View all instructions

Enjoy this project?



Thomas wrote 01/06/2017 at 21:01 point

This is really awesome! You made really interesting trade-offs (e.g. the tokenization). Chapeau!

The 8008 opcodes are surprisingly compact. I don't think that this could be done with the STM8  architecture - there are too many 2, 3, 4 and even 5 byte opcodes, and there aren't enough general purpose registers.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates