Implementing Forth on an RC6502 SBC

Topics relating to various Forth models on the 6502, 65816, and related microprocessors and microcontrollers.
RegH
Posts: 19
Joined: 19 May 2022
Location: Felixstowe, UK

Implementing Forth on an RC6502 SBC

Post by RegH »

Hi,

Have just completed an RC6502 SBC build (standard 6502 processor, 1MHz) and am looking to implement Forth on it.
Has anyone done this before?

The SBC currently has a single 64Kb EEPROM with Wozmon/Krusader/Basic. I could possibly replace it with Forth on another
64Kb and boot directly into Forth or perhaps use a 256Kb and manually page it via the A13/A14 jumpers to boot (if possible).
I guess the correct way is to add a ROM board for Forth somewhere above $8000; that keeps Wozmon etc and can run from there.
I have ordered a motherboard and will be on the lookout for a ROM or perhaps RAM/ROM board.

More importantly I guess is the flavour of Forth and since I have never done this will be the big issue for me. It's like chosing a Linux Distro :shock:
Looking at the FIG Forth for 6502 on the source page here for starters unless someone points me elsewhere.

Reg
User avatar
GARTHWILSON
Forum Moderator
Posts: 8773
Joined: 30 Aug 2002
Location: Southern California
Contact:

Re: Implementing Forth on an RC6502 SBC

Post by GARTHWILSON »

Do you mean Kb (kilobit), or KB (kilobyte)? 265Kb is 32KB, enough to fit both the BASIC and the Forth on it at the same time. Fig-Forth seems to have been where Forth started for the 6502, although it wasn't a particularly good Forth. It's available at http://6502.org/source/forth65.zip, for the Apple II I believe, and should be pretty easy to adapt for other systems. Note that it has the UM/MOD division bug, the UM* multiplication bug, and the D< double-precision signed less-than comparison bug.



I have more Forth links on my links page at http://wilsonminesco.com/links.html#Forth .
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
User avatar
commodorejohn
Posts: 299
Joined: 21 Jan 2016
Location: Placerville, CA
Contact:

Re: Implementing Forth on an RC6502 SBC

Post by commodorejohn »

Tali Forth v.2 is very simple to get up and running on a new platform - I did it for floobydust's SBC in about an hour and a half, most of which was in setting up the build environment and reading through the relevant documentation.
RegH
Posts: 19
Joined: 19 May 2022
Location: Felixstowe, UK

Re: Implementing Forth on an RC6502 SBC

Post by RegH »

GARTHWILSON wrote:
Do you mean Kb (kilobit), or KB (kilobyte)? 265Kb is 32KB, enough to fit both the BASIC and the Forth on it at the same time. Fig-Forth seems to have been where Forth started for the 6502, although it wasn't a particularly good Forth. It's available at http://6502.org/source/forth65.zip, for the Apple II I believe, and should be pretty easy to adapt for other systems.
I think I got the units correct but it is confusing (me?) - use Kb, KB or chip ID?? Board currently has a 28C64 which is full with Basic etc. Swapping for a 28C256 would give room to add Forth but my understanding is that the SBC can only address a single 8KB block at any one time. I could swap the A13/A14 jumpers and boot into Forth but would have to sort out the boot vectors etc... I think I will go the motherboard/ROM card route.
Thanks for heads-up on bugs.
commodorejohn wrote:
Tali Forth v.2 is very simple to get up and running on a new platform - I did it for floobydust's SBC in about an hour and a half, most of which was in setting up the build environment and reading through the relevant documentation.
Thanks for that; I will look into it.
handyandy
Posts: 113
Joined: 14 Sep 2015
Location: Virginia USA

Re: Implementing Forth on an RC6502 SBC

Post by handyandy »

Historically speaking, there was Rockwell’s RSC FORTH:
viewtopic.php?f=3&t=5226&hilit=Rsc+forth

Cheers,
Andy
RegH
Posts: 19
Joined: 19 May 2022
Location: Felixstowe, UK

Re: Implementing Forth on an RC6502 SBC

Post by RegH »

commodorejohn wrote:
Tali Forth v.2 is very simple to get up and running on a new platform - I did it for floobydust's SBC in about an hour and a half, most of which was in setting up the build environment and reading through the relevant documentation.
Loks like Tali Forth only runs on the 65C02 and my SBC will only accept the 6502. To my shame, I didn't look on here first as I believe there are other good SBC designs which probably support 65C02 :oops:
handyandy wrote:
Historically speaking, there was Rockwell’s RSC FORTH:
Great thread and the RSC manual is a goldmine. Sadly it runs on a Rockwell Forth specific 65*** but it looks a handy beast for a dedicated Forth system.
Paganini
Posts: 516
Joined: 18 Mar 2022

Re: Implementing Forth on an RC6502 SBC

Post by Paganini »

Hi Reg,

A 65C02 will work fine on the Rev H board.

This is the RAM/ROM board you want:

https://www.pcbway.com/project/sharepro ... c9da1.html

Sorry I don't have the options configured as nicely as TEBL does, but I'm still a relative newb at PCBWay.

If you put a 28C256 in it, you can configure it with a jumper to appear in the top 32k (for ROM generally) or bottom 32k (for RAM). Within that space you can enable / disable individual 4k blocks. (On mine, I have $9000 - $9FFF disabled for I/O space.)
"The key is not to let the hardware sense any fear." - Radical Brad
RegH
Posts: 19
Joined: 19 May 2022
Location: Felixstowe, UK

Re: Implementing Forth on an RC6502 SBC

Post by RegH »

Paganini wrote:
A 65C02 will work fine on the Rev H board.
Took the words straight out of my mouth 8) Thanks. I was just going to double check that. There are some (older?) comments on TEBL that the SBC only supports the 6502 whilst I just noticed that the latest CPU board does have 65C02 on it. Will get one in the next order.
Have a ROM and RAM board on the way :D
Martin_H
Posts: 837
Joined: 08 Jan 2014

Re: Implementing Forth on an RC6502 SBC

Post by Martin_H »

Fig Forth is pretty easy to get running. I ported it to the Ophis assembler and got it running on Py65mon without much of an issue. Well I had some issues but the forum helped me resolve them. Here's a link to my source if it helps you:

https://github.com/Martin-H1/6502/tree/master/FigForth

I also brought up volks forth on an SBC and it was pretty easy. See:

https://fossil.forth-ev.de/volksforth/wiki?name=gen6502

I've been meaning to try Tali Forth 2 as it's more modern than some of the others. I would think that removing the 65c02 instructions shows not be that hard.
Paganini
Posts: 516
Joined: 18 Mar 2022

Re: Implementing Forth on an RC6502 SBC

Post by Paganini »

RegH wrote:
Paganini wrote:
A 65C02 will work fine on the Rev H board.
Took the words straight out of my mouth 8) Thanks. I was just going to double check that. There are some (older?) comments on TEBL that the SBC only supports the 6502 whilst I just noticed that the latest CPU board does have 65C02 on it. Will get one in the next order.
Have a ROM and RAM board on the way :D
:D

Just FYI, in case you want to build a CPU board to plug into your backplane once you get one, the CPU board does *not* support the WDC65C02 by default, but can be easily modified to do so by putting a 3k3 resister between the Bus Enable pin and VCC. Other 65C02s don't have the BE feature, and so should work fine (my CMD one does, anyway). I discovered this the hard way. :)
"The key is not to let the hardware sense any fear." - Radical Brad
RegH
Posts: 19
Joined: 19 May 2022
Location: Felixstowe, UK

Re: Implementing Forth on an RC6502 SBC

Post by RegH »

Has anyone managed to get Tali Forth 2 running on the RC6502 Apple 1 Replica (or as mine now is, an RC65C02)??
commodorejohn wrote:
Tali Forth v.2 is very simple to get up and running on a new platform - I did it for floobydust's SBC in about an hour and a half, most of which was in setting up the build environment and reading through the relevant documentation.
I have finally got an R65C02 up and running in the RC6502 and have a ROM board (capable of taking a 28C256) so have begun to look at implementing Tali Forth 2.

However, it seems that the Tali Forth ROM inplementation nominally occupies 24KB ($8000-$DFFF) with the Kernel, I/O, vectors etc. expected to reside in the remaining 8KB ($E000-$FFFF).
The RC6502 is a reasonable Apple 1 replica (uses a 6821 PIA) and the registers are still mapped to $D010-$D013 (WozMon compatibility). It looks like address decoding enables [CS_PIA] for the entire block $D000-$DFFF (i.e. there is no ROM mapped in this range).

I am just wondering if it is going to be possible to use Tali without moving the PIA addresses? I am not keen to do this.
tmr4
Posts: 147
Joined: 19 Feb 2022

Re: Implementing Forth on an RC6502 SBC

Post by tmr4 »

RegH wrote:
I am just wondering if it is going to be possible to use Tali without moving the PIA addresses? I am not keen to do this.
Tali Forth 2 is fairly modular. I got it running on a build with only 16k ROM, I believe by leaving out the assembler, disassembler and editor. You can customize it for your build. See examples in the platform folder.
RegH
Posts: 19
Joined: 19 May 2022
Location: Felixstowe, UK

Re: Implementing Forth on an RC6502 SBC

Post by RegH »

Good point, thanks.
Yes, one of the reasons that I am trying Tali is that it is very well structured and understandable but I did particularly want an assembler and the line editor would be useful too.
I have found the "includes" for them in taliforth.asm rather than the platform file and will try some builds now and check sizes.

The current firmware (in 8KB 28C64) has Basic starting at $E000, the Krusader assembler at $F000 with WozMon at $FF00. I certainly will not require Basic so have a free 4KB at $E000-$EFFF. It should be possible to split Tali and locate some/all of the extras in $E000??? I need to get to grips with the Ophis assemble.
RegH
Posts: 19
Joined: 19 May 2022
Location: Felixstowe, UK

Re: Implementing Forth on an RC6502 SBC

Post by RegH »

tmr4 wrote:
Tali Forth 2 is fairly modular. I got it running on a build with only 16k ROM, I believe by leaving out the assembler, disassembler and editor. You can customize it for your build. See examples in the platform folder.
It took quite a lot of jiggling but I finally managed to get Tali Forth 2 running :D Mind you, I had 32KB ROM (minus the 4k gap where the PIA sits - right in the middle).

I am not sure how you managed to leave out the assembler, disassembler and editor; simply commenting out the .require stopped it assembling. I reasoned that with more ROM, it would be worth leaving them in.
I also managed to crowbar in the Krusader assembler and used WozMon as per usual.

Thanks again all.
Just got to go and learn Forth now 8)
tmr4
Posts: 147
Joined: 19 Feb 2022

Re: Implementing Forth on an RC6502 SBC

Post by tmr4 »

RegH wrote:
I am not sure how you managed to leave out the assembler, disassembler and editor; simply commenting out the .require stopped it assembling.
Unfortunately, I don't have the initial version of Tali Forth 2 that I got running on my build with 16k ROM. Looking back at the last version I played with I see that in addition to removing the assembler, disassembler and editor, I restructured the native_word file into separate source files according to their Standard groupings. It looks like at this point I left out some of these groupings that weren't needed to support other words. This got the build down to a little over 11k, including my own I/O routines. I think I was trying to free up ROM to store Forth programs as I didn't have file storage at the time. I recall getting Conway's Game of Life running.

It was about this time that I realized that Forth provided all of the features I'd been adding to my monitor program so I ditched that effort to focus solely on Forth as an operating system. I started with a token threaded version to keep the size as small as possible. I found that a bit restrictive after a while and switched it to a direct threaded version. I'm working on a 65816 build now and found that a subroutine threaded version, similar to the threading used in Tali Forth 2, works better for my needs.
Post Reply