6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Nov 24, 2024 12:18 am

All times are UTC




Post new topic Reply to topic  [ 14 posts ] 
Author Message
PostPosted: Sun Jul 14, 2013 4:26 pm 
Offline
User avatar

Joined: Sat Sep 29, 2012 10:15 pm
Posts: 904
In my quest to make my FPGA Playground board useful (Arlet's core and 64K SRAM, serial IO) I thought Forth would be a good next step (I have Daryl's 1K monitor running as a loader and can load binaries from my linux box).

So where can I find a simple Forth to start with? I've written many Forth-like systems and don't really feel like doing one right now (too many pots in the fire). I figured there would be something at 6502.org resources or code but could not find anything other than the old FIG listing.

Daryl mentioned in some thread that he fixed FIG to work on his boards. Any chance of a copy?

Anyone have a minimal implementation?

_________________
In theory, there is no difference between theory and practice. In practice, there is. ...Jan van de Snepscheut


Top
 Profile  
Reply with quote  
PostPosted: Sun Jul 14, 2013 5:10 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1748
Location: Sacramento, CA
The latest version I have is with my AVR65C02 Emulator. If you download the source files, in the SBC2OS folder, you will find the FIGForth.asm source file. Just adjust your memory boundaries and IO and it should work.

Will follow up tomorrow.

Daryl

_________________
Please visit my website -> https://sbc.rictor.org/


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 15, 2013 12:02 am 
Offline

Joined: Sat Dec 13, 2003 3:37 pm
Posts: 1004
This is as basic a Fig Forth as you can get as well.

https://dl.dropboxusercontent.com/u/334 ... IG6502.ASM

It works, I think it has the U/ fix in it.

Super simple assembly.


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 15, 2013 4:34 am 
Offline
User avatar

Joined: Sat Sep 29, 2012 10:15 pm
Posts: 904
Thanks!

Sadly, I have tried 3 varieties of FigForth (Daryl's, whartung's link and another one from someone else's SBC site), and they all silently die. I traced it up to the first NEXT (not really traced, just stuck rts's in), after that it gets harder to debug... I will have to make some fixes to Daryl's monitor (the register display command does not work as is) to investigate it more properly. I sure hope it's something easy!

What does Fig Forth display on the screen on a successful start?

_________________
In theory, there is no difference between theory and practice. In practice, there is. ...Jan van de Snepscheut


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 15, 2013 6:20 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1748
Location: Sacramento, CA
Try using a BRK vs the RTS, that will capture the register values.

This is the FigFORTH prompt:
fig-FORTH 1.0

After pressing enter, you get:
OK

To edit my source (From the AVR65C02 files:)

Fix these:

ORIG = $0400 ; origin of FORTH's Dictionary. (good as is)
MEM = $3F00 ; top of assigned memory+1 byte. (adjust for your RAM)


;
; Monitor calls for terminal support
;
OUTCH = output ; output one ASCII char. to term.
INCH = Input_chr ; input one ASCII char. to term.
TCR = Print_CR ; terminal return and line feed.


* = $0400 ; add this if you haven't defined it anywhere else
ENTER NOP ; Vector to COLD entry (good as is - included for reference)



MON .WORD *+2 ; (good as is - just included for reference)
JMP MonitorBoot ; back to SBC Monitor

That should be all you need to do to get it running.

Daryl

_________________
Please visit my website -> https://sbc.rictor.org/


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 15, 2013 4:20 pm 
Offline
User avatar

Joined: Sat Sep 29, 2012 10:15 pm
Posts: 904
Daryl, thanks for the brk tip.

The changes I made are exactly what you suggest. Another place I had to bypass was XQTER:
Code:
;
;         XQTER leaves a boolean representing terminal break
;
;
XQTER          ;jsr   cbrk              ;if Ctrl-c, set C else clear C
                clc                     ;TODO: for now
                lda   #$00              ;0
                rol   a                 ;move carry to bit 0
                jmp   PUSHOA           

This should behave as no Ctrl-c ever takes place for now...

EDIT: I found one problem with my conversion code that messed up the initial load of address of ABORT into IP (did not insert #)... But something else is still wrong... Got the prompt after fixing another (my own) bug, crashing on literal... Getting closer though

_________________
In theory, there is no difference between theory and practice. In practice, there is. ...Jan van de Snepscheut


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 15, 2013 5:58 pm 
Offline

Joined: Sat Dec 13, 2003 3:37 pm
Posts: 1004
In my code, there's a line "JSR TRAC" in NEXT (I think), there's some code commented out above it (an attempt to make TRACING settable with a user variable, that I never managed to get to work).

If you uncomment that JSR, it will show you running through the high level words.

But, you must have something fundamentally wrong going on, the basic interpreter should certainly work.


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 15, 2013 6:15 pm 
Offline
User avatar

Joined: Sat Sep 29, 2012 10:15 pm
Posts: 904
Daryl, the problem was the 3 equates for the IO routines. I changed the code to call the routines directly and got to the prompt anyway.

It almost works... The prompt comes up, I hit CR, "OK" comes up. Typing in literals crashes it, . crashes it, DUP returns "DUP ?" and then crashes...

EDIT: it's just flaky. Hitting CR a few times will crash.

I probably have to debug the outer loop to find the problem

_________________
In theory, there is no difference between theory and practice. In practice, there is. ...Jan van de Snepscheut


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 15, 2013 8:52 pm 
Offline

Joined: Sat Dec 13, 2003 3:37 pm
Posts: 1004
That's really odd.

Since you're not actually doing anything to it, beyond swapping out a couple of I/O routines, it should Just Work(tm). The core of the system is just a couple of machine code words, and the inner interpreter (i.e. NEXT). Assuming all of that is stable, you shouldn't have any problems.

This is on real hardware, yes? I had lots of issues with my Forth, but that's because it was running on my simulator and I was using it as a test mule to help prove it. In the end I didn't have to change any actual code.

So I'm just surprised you're having all of these issues getting the prompt up and simple words and definitions working. (Disk I/O is another matter, but even that isn't too bad.)


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 15, 2013 11:31 pm 
Offline
User avatar

Joined: Sat Sep 29, 2012 10:15 pm
Posts: 904
Real hardware is a relative term - it's an FPGA with Arlet's core and 64K SRAM running at 45MHz. Real enough, anyway.

Daryl's monitor is running solid as a rock, but out of an internal 2K BRAM, so it is possible that there is some SRAM-related instability (45 was the upper limit in previous tests). I will try dropping the clock first.

_________________
In theory, there is no difference between theory and practice. In practice, there is. ...Jan van de Snepscheut


Top
 Profile  
Reply with quote  
PostPosted: Tue Jul 16, 2013 12:26 am 
Offline
User avatar

Joined: Sat Sep 29, 2012 10:15 pm
Posts: 904
Yes, it was unstable due to high speed. It is running solidly so far at 30MHz. I am so happy to have Fig-Forth running after all these years :lol:

Thank you!

_________________
In theory, there is no difference between theory and practice. In practice, there is. ...Jan van de Snepscheut


Top
 Profile  
Reply with quote  
PostPosted: Tue Jul 16, 2013 12:32 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
Where's the "Like" button? I need it once in a while.

Do make sure you incorporate the division and multiplication bug fixes.

_________________
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?


Top
 Profile  
Reply with quote  
PostPosted: Tue Jul 16, 2013 12:44 am 
Offline
User avatar

Joined: Sat Sep 29, 2012 10:15 pm
Posts: 904
Thanks Garth!
I believe that Daryl had incorporated your math bugfixes. I had to make a minor fix to replace an stz. [EDIT: removed silly question]. I do miss the 65C02 instructions.

_________________
In theory, there is no difference between theory and practice. In practice, there is. ...Jan van de Snepscheut


Top
 Profile  
Reply with quote  
PostPosted: Tue Jul 16, 2013 3:39 am 
Offline
User avatar

Joined: Sat Sep 29, 2012 10:15 pm
Posts: 904
It is working at 40MHz now (I moved the circuit around a little to speed it up). I have to do some catching up as I haven't used Forth in a while (I've been using my own forth-like systems over the years). I feel like I found an old friend!

_________________
In theory, there is no difference between theory and practice. In practice, there is. ...Jan van de Snepscheut


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: