Friday, November 19, 2004

Apple I/Replica I and FORTH


The Apple I started as a hobbyist's project in 1976, and turned into one of the early catalysts of the personal computer revolution. The simple elegance of the WOZ monitor (only 256 bytes!) and readily available parts made this computer accessible to everyone. Unfortunately, today only a few survive.

Below I have links to the original documentation that came with the Apple I, including the hand typed basic manual and owner's manuals. Browsing these, you really get the feel that this was a hobbyist's project, not the beginning of a billion dollar company!

Apple I User's Guide
Apple I BASIC Manual
Apple fritter
Apple I Owner's Club

Replica I
The Replica I is a single board computer that is a functional replica of the groundbreaking Apple I from the 70's. The primary difference is that some of the parts are implemented with modern components. However, it still uses the venerable 6502 and contains the original Woz monitor and Woz's hand assembled BASIC!

My Replica I is using a standard modern PC power supply, a PS/2 style keyboard, and Apple //c 9" monitor. Some of my projects for the Replica I include creating a program loader to allow easy loading/saving programs to an attached PC, and porting one of my favorite old languages, FORTH, to the Replica I/Apple I.

You can buy a Replica I in kit form or ready built from Vince Briel, a hobbyist and fan of the original Apple I.

FORTH
Forth is a fast, powerful, and portable high level language that was popular in the early days of micro computing because of its ability to easily manipulate hardware details while retaining many benefits of a high level language. It is a "stack oriented" language and thus maps efficiently to an 8-bit microprocessor.

Forth has a small kernel of "words" that are implemented in the native assembler of the target platform. The balance of the language consists of further word definitions made up of "address" references to these kernel words. In this way, only a small part of the assembler listing is dependent on the host platform, making this a very portable language (even in assembler!).

This is a figFORTH 1.1 port originally distributed by W. F. Ragsdale for the Rockwell AIM65 back in the late seventies. I have taken this listing and made a port to the Apple I/Replica I, resulting in a powerful programming environment for experimentation or computer control applications. FORTH is still popular today and is found in such diverse applications as embedded controllers and PDA's to NASA applications on the Space Shuttle!

FORTH is compact, only 7 Kbytes for the kernel. While fully functional now on the POM Apple I emulator, I still need to implement block storage in memory so that programs can be loaded and saved independent of the kernel itself with the cassette interface. You can download the current version below.

Note: There is currently an issue in the Pom1 emulator that results in ASCII $1F being used to represent [space] where the Apple I/Replica I expect $20. This must be changed in the listing and recompiled depending on the platform you chose to run on.

If you want to learn more about FORTH, The best place to start is Leo Brodie's book Starting FORTH which is conveniently online. Also, if you wish to change my port for the Apple I/Replica I, you will need the CC65 C Compiler and Macro Assembler/Cross Compiler for the 6502. More enhancements to follow...

Micro Chess
One of the most fun things I have done with my new Replica I was to load and run Peter Jennings' original Microchess written in 1976. The excitement of seeing this vintage early program come to life on my just assembled Replica was probably much like early Apple I users back in the 70's would have felt on powering up this landmark program the first time. This program was a wonderful accomplishment for several thousand bytes of code!

5 comments:

  1. Hello,

    I've just got my Replica I, and I'm also working with FORTH for 6502 machines. FIG-FORTH is a little outdated today, I'm working on an more modern Open Source Forth System, that can be turned into ANSI Forth or Forth 83 Standard Forth.

    My plan is to also port this (new) Forth System to the Apple I / Replica I.

    If you're intersted in Forth Programming on 6502 Machines, take a look at my Forth page at
    http://www.strotmann.de/twiki/bin/view/APG/LangForth

    It would also be nice to get the GNU-Forth 6502 cross-compile target running again.

    Carsten _at_ strotmann.de

    ReplyDelete
  2. Carsten, Porting a more powerful FORTH to the Replica 1 would be a great idea. It is really the perfect language for the 6502 and a lot of fun!

    FIG-FORTH 1.1 is very outdated, but I chose it as a version that was developed around the same time as the Apple I. It is really simple to understand and port to different environments.

    In fact, this port really demonstrates the effectiveness of the Woz Monitor, as the total amount of code required to support the specifics of the Apple I architecture is very small. This block is from the end of my listing and is the only Apple 1 specific code segment:

    ;
    ;********************************************************
    ;
    ; Apple 1 specific i/o routines
    ;
    ;********************************************************
    ;
    ; input one ASCII char. to term.
    ;
    INCH: LDA KBDCR ; Ready to read?
    BPL INCH
    LDA KBD
    EOR #$80 ; clear high order bit
    RTS
    ;
    ; Print CR
    ;
    TCR: LDA #$8D ; CR
    JSR ECHO
    ; LDA #$0A ; LF
    ; JSR ECHO
    RTS
    ;
    ; print one blank
    ;
    XBLANK: LDA #$20 ; SP
    JSR ECHO
    RTS
    ;
    ; wait for keystroke
    ;
    ONEKEY: LDA KBDCR ; keystroke?
    BPL ONEKEY
    LDA KBD ; throw away key
    RTS
    ;

    ReplyDelete
  3. This comment has been removed by a blog administrator.

    ReplyDelete
  4. I received a request recently for the original listing of FIG-FORTH. I believe this is Ragsdale's original listing:

    https://sites.google.com/site/8bitsunplugged/FIG6502.ASM

    and documentation:

    https://sites.google.com/site/8bitsunplugged/figinst.txt

    Will

    ReplyDelete