Forth for the Membership Card
Intro
Computers are machines just like the marionette. They must be told exactly what to do, in specific language. And so we need a language which possesses two seemingly opposite traits: On the one hand, it must be precise in its meaning to the computer, conveying all the information that the computer needs to know to perform the operation. On the other hand, it must be simple and easy-to-use by the programmer.

From chapter "Introduction for Beginners", Leo Brodie, Starting FORTH https://www.forth.com/starting-forth/

Rc/Forth and IDIOT Monitor for RaspiElf (Membership Card)

Rc/Forth and IDIOT Monitor for RaspiElf (Membership Card)

Mark Abene made FORTH work on the Membership Card.

forth.hex
Modified version of Mike Riley's Rc/Forth, ROM version. Changed to work with my modified version of IDIOT. Loads in at 0500h. You can get it from the COSMAC ELF yahoo group.
idiot_new.hex
New version of IDIOT with SCRT routines, along with TYPE, MSG, READ, and INPUT routines for basic console I/O. Loads in at 0000h. You can get it from the COSMAC ELF yahoo group. For details see http://www.retrotechnology.com/memship/mship_idiot.html

Concatenate this two files as mc-forth.hex and convert it to a binary file:

pi@cosmac:~/elf/forth $ cat idiot_new_qhi.hex forth.hex > mc-forth.hex
pi@cosmac:~/elf/forth $ hex2bin mc-forth.hex 
hex2bin v2.5, Copyright (C) 2017 Jacques Pelletier & contributors

Allocate_Memory_and_Rewind:
Lowest address:   00000000
Highest address:  00001633
Starting address: 00000000
Max Length:       5684

Binary file start = 00000000
Records start     = 00000000
Highest address   = 00001633
Pad Byte          = FF
pi@cosmac:~/elf/forth $ ls -l
insgesamt 40
-rw-r--r-- 1 pi pi 12132 Jan 13 12:36 forth.hex
-rw-r--r-- 1 pi pi  2890 Jan 13 12:36 idiot_new.hex
-rw-r--r-- 1 pi pi  5684 Jan 13 12:41 mc-forth.bin
-rw-r--r-- 1 pi pi 15022 Jan 13 12:36 mc-forth.hex

Now upload and start Rc/Forth (mc-forth.bin):

pi@cosmac:~/elf/forth $ bin2elf -w -r mc-forth.bin
0x1634 bytes written
clear high (8th) bit of input characters
pi@cosmac:~/elf/forth $ stty -F /dev/ttyS0 istrip
and start the terminal emulator (console):
pi@cosmac:~/elf/forth $ microcom -s 600
connected to /dev/ttyS0
Escape character: Ctrl-\
Type the escape character followed by c to get to the menu or q to quit
[CR]
IDIOT/4
*$P500
Rc/Forth 0.1
(c) copyright 2006 by Michael H. Riley
ok 15 5 + .
20 ok BYE

IDIOT/4
*
Rc/Forth and Chuck's Super Monitor for RaspiElf (Membership Card)

Rc/Forth and Chuck's Super Monitor for RaspiElf (Membership Card)

Mark Abene made Rc/Forth also work with Chuck's Super Monitor. I prefer this monitor because of its ability to communicate with 9600 baud.

mcsmp_rcforth.hex
Mike Riley's Rc/Forth, modified to work with Chuck Yakym's MCSMP20 firmware. You can get it from the COSMAC ELF yahoo group.
MCSMP20B.bin
Chuck's Super monitor. Loads in at 0000h. You can get it from the Lee A. Hart's website The COSMAC ELF Membership Card .

Create binary file and load it at 0x8000:

pi@cosmac:~/elf/forth $ hex2bin mcsmp_rcforth.hex
hex2bin v2.5, Copyright (C) 2017 Jacques Pelletier & contributors

Allocate_Memory_and_Rewind:
Lowest address:   00008000
Highest address:  000091DB
Starting address: 00008000
Max Length:       4572

Binary file start = 00008000
Records start     = 00008000
Highest address   = 000091DB
Pad Byte          = FF
pi@cosmac:~/elf/forth $ bin2elf -s 8000 mcsmp_rcforth.bin
0x11dc bytes written
Now upload and start the monitor, start the terminal program with 9600 baud:
pi@cosmac:~/elf/forth $ bin2elf -w -r MCSMP20B.bin
0x8000 bytes written
pi@cosmac:~/elf/forth $ microcom -s 9600
connected to /dev/ttyS0
Escape character: Ctrl-\
Type the escape character followed by c to get to the menu or q to quit
[CR]
Membership Card's Serial Monitor Program Ver. 2.0B
Enter "H" for Help.
>R8000
Currently running your program
Rc/Forth 0.1
(c) copyright 2006 by Michael H. Riley
ok 
Knight Rider in Rc/Forth

Knight Rider in Rc/Forth

See ChaseLighting for an assembler version (much faster of course).

Here a small test program for the Rc/Forth. It's a simple knight rider chase lighting, but it is using the MC LEDs (of course), the switches for setting the pace and the IN button to terminate the program.

Some interactive programming to find out how OUT is working:

ok 1 4 OUT
ok 4 1 OUT
ok 4 2 OUT
ok : LED! 4 SWAP OUT ;
ok 4 LED!

The rest of the program, every word can and should be tested interactively (e.g. 1 LEFT):

: SWITCH@ 4 INP ;
: DELAY 1 SWITCH@ + 0 DO LOOP ;
: LEFT 7 0 DO 2 * DUP LED! DELAY LOOP ;
: RIGHT 7 0 DO 2 / DUP LED! DELAY LOOP ;
: KNIGHTRIDER 1 DUP LED! BEGIN LEFT RIGHT EF 8 <> UNTIL DROP ;

Push the IN button to terminate the program.

FIG-Forth - CDP1802 IP - Lattice FPGA-Board

FIG-Forth - CDP1802 IP - Lattice FPGA-Board

C-H Ting, Juergen Pintaske and Steve Teal wrote the fine book FIG-Forth Manual: Documentation and Test in 1802 IP

I bought the book and the proposed Lattice FPGA board ICE40HX8K-B-EVN (e.g. from mouser, about $50). This FPGA can be programmed as an CDP1802 system with RAM, UART, Timer and I/O, the serial console is also implemented as USB CDC!

CDP1802 in VHDL

This project is an SOC (System on a Chip) coded in VHDL and implemented for the Lattice iCE40-hx8k dev board. The SOC contains the following components: 1802 CPU + UART + Timer + I/O Ports. Details and source see:

Some more resources:

Knight Rider

Sample LED chase program from: https://wiki.forth-ev.de/doku.php/projects:fig-forth-1802-fpga:start

I changed this program to a LED knight rider. Here is what you have to type in on the console to get blinking the LEDs on the Lattice FPGA board: forth-ev.de

COLD[CR]
1802 FIG-FORTH R0.4  3/16/81
: LED! 61440 C! ; [CR]  OK
: LED@ 61440 C@ ; [CR]  OK
: DELAY 3000 0 DO LOOP ;[CR]  OK
: LEFT 7 0 DO LED@ 2 * LED! DELAY LOOP ;[CR]  OK
: RIGHT 7 0 DO LED@ 2 / LED! DELAY LOOP ;[CR]  OK
: KNIGHTRIDER 1 LED! BEGIN LEFT RIGHT ?TERMINAL UNTIL ;[CR]  OK
KNIGHTRIDER[CR]
?TERMINAL does not seem to work as expected.

The system on chip coded in VHDL and implemented for the Lattice iCE40-hx8k dev board is about 150 times faster than the Membership Card. That's about 300 MHz clock for an original CDP1802.

Spare Time Gizmo’s ELF2K ROM for RaspiElf

Spare Time Gizmo’s ELF2K ROM for RaspiElf

For details see Herb Johnson's ELF 2K ROM for 1802 Membership Card

v88.hex from the Spare Time Gizmos web site.

pi@cosmac:~/elf/elf2k $ cp v88.hex v88.hex.org
pi@cosmac:~/elf/elf2k $ patch v88.hex v88-mc.patch
pi@cosmac:~/elf/elf2k $ hex2bin v88.hex
hex2bin v2.5, Copyright (C) 2017 Jacques Pelletier & contributors

Allocate_Memory_and_Rewind:
Lowest address:   00000000
Highest address:  00007FFF
Starting address: 00000000
Max Length:       32768

Binary file start = 00000000
Records start     = 00000000
Highest address   = 00007FFF
Pad Byte          = FF
pi@cosmac:~/elf/elf2k $ bin2elf -s 8000 v88.bin 
0x8000 bytes written
pi@cosmac:~/elf/elf2k $ bin2elf -w -r LBR_8000.bin
0x0003 bytes written
pi@cosmac:~/elf/elf2k $ 
But there is "Post Code 88" -> SRAM size wrong

My MC has 64 KiB RAM and no ROM. But the RAM Size Test (part of monitor) expects ROM from 0x8000.

Herb Johnson wrote:

Peter, hopefully you can take it from here, find the BOOTS.ASM code at the link below, and "patch" it to accept an appropriate area for RAM. More than I can figure out today.

http://www.sparetimegizmos.com/Downloads/v88-source.zip

-- Peter Schmid - 2019-01-13

Comments

Topic attachments
I Attachment History Action Size Date Who Comment
JPEGjpg forth-header.jpg r1 manage 42.9 K 2019-10-25 - 20:13 PeterSchmid  
PNGpng mc-eeprom-conn.png r3 r2 r1 manage 20.4 K 2019-01-19 - 23:12 PeterSchmid  
PNGpng mc-eeprom-u1.png r2 r1 manage 18.6 K 2019-01-23 - 21:26 PeterSchmid  
Unknown file formatpatch v88-mc.patch r1 manage 1.1 K 2019-01-20 - 10:36 PeterSchmid  
Edit | Attach | Watch | Print version | History: r25 < r24 < r23 < r22 < r21 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r25 - 2019-12-30 - PeterSchmid
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback