6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 16, 2024 5:23 pm

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Fri Sep 07, 2018 3:34 pm 
Offline
User avatar

Joined: Wed Feb 23, 2005 9:20 am
Posts: 23
Location: Zurich, Switzerland
Hi All,

Last time I logged on here was 2005 :!: :o

In the same way that Brad R published the excellent 6809 CamelForth with a PC cross-compiler, that runs with F83 (and subsequently with Gforth), does such a thing exist for the 6502 target?

I see that FigForth is out there as an assembly listing and there were several commercial Forths for Vic20/C64 etc. and I believe that MPE have a commercial one for PC, but I"ve never come across anything non-commercial.

I'm quite surprised at this really, not many people nowadays are going to write code interactively on a 6502 target and store it on a local SD card or upload/download it everytime by serial port to a PC. A cross-compiler and EPROM emulator is (well, was in the 90's) surely the way forward?

_________________
P*h*i*l*l*i*p EEaattoon in real life


Top
 Profile  
Reply with quote  
PostPosted: Fri Sep 07, 2018 3:55 pm 
Offline
User avatar

Joined: Wed Feb 23, 2005 9:20 am
Posts: 23
Location: Zurich, Switzerland
I just spotted this thread about meta-compiling from not too long ago, I think that's referring to the same thing:
http://forum.6502.org/viewtopic.php?f=9&t=4599

It seems that no-one's quite done it yet?

_________________
P*h*i*l*l*i*p EEaattoon in real life


Top
 Profile  
Reply with quote  
PostPosted: Fri Sep 07, 2018 6:24 pm 
Offline

Joined: Sat Dec 13, 2003 3:37 pm
Posts: 1004
Do you have an application in mind?

Garth has his Forth on his bench top computer (I think). I don't know how he loads the runtime (or if it's in ROM on the board), but he basically does what you said -- simply send the Forth source over the serial line to run it.

Apparently the combination of the serial speed and his Forth program sizes don't make the process slow enough for him to bother with anything else.

F83 does, indeed, have a meta-compiler. It can be ported (as demonstrated by the fact that they have both 8080/Z80 versions and 8086 versions), but as good as the system is (in terms of source availability and other documentation), porting it is not a trivial affair to be sure.

From a hobbyist POV, most folks are happy just writing them from scratch in assembly around here.


Top
 Profile  
Reply with quote  
PostPosted: Fri Sep 07, 2018 6:49 pm 
Offline
User avatar

Joined: Wed Feb 23, 2005 9:20 am
Posts: 23
Location: Zurich, Switzerland
Currently I'm using 6809 CamelForth and cross compiling to a Vectrex games console, the general idea is to make some new games for it eventually. I'm using an EPROM emulator to run on the target and a serial interface for interactive testing. When finished, I can burn the game onto a real EPROM and make a standard cartridge out of it. Additionally, I can run it on a Vectrex emulator with a single step machine code debugger.

If I had an interesting project to do on a 6502 or '816, I'd hope to do it the same way. I guess you could compile on the 6502 machine, send the RAM/ROM content back up the serial port and blow it to a ROM, but that's a bit fiddly.

My Vectrex project happened partly because I knew I could use the 6809 CamelForth cross-compiler!

In the mid 80's, I cut my teeth with assembly on Vic-20 and C64, but it the 90's it was Forth for a living and that's a prerequisite for me now, really.

_________________
P*h*i*l*l*i*p EEaattoon in real life


Top
 Profile  
Reply with quote  
PostPosted: Fri Sep 07, 2018 7:15 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8541
Location: Southern California
whartung wrote:
Do you have an application in mind?

Garth has his Forth on his bench top computer (I think). I don't know how he loads the runtime (or if it's in ROM on the board), but he basically does what you said -- simply send the Forth source over the serial line to run it.

Yes; you can read about it on my workbench computer page, http://wilsonminesco.com/BenchCPU/ . Go down to the heading, "How it is controlled."

Quote:
Apparently the combination of the serial speed and his Forth program sizes don't make the process slow enough for him to bother with anything else.

Right. Instant compilation like Samuel Falvo (forum name kc5tja) talks about would b nice, but it's not that big a deal. Run speed is more important than load speed. If I'm just sending a few lines over, it's basically instant. If it's lots of pages, I'll have a little thumb-twiddling to do. I started the topic here "dictionary hashing before I realized that what's taking most of the compiling time on my system is not the searching itself but rather a lot of other stuff I should re-write as primitives, and should also do the RS-232 interrupt service in assembly. I give a little more detail in this post.

pjeaton, it's nice to see you back. What you're talking about regarding developing in RAM and then transferring to ROM is what I did for the automated test equipment at work around 1990 on the 65c02-powered Cubit 7540 STD-bus SBC. I guess I ought to post an article about the method on my website. I used a metacompiler to get the initial kernel going so there would be a Forth system in EPROM, then developed new code in RAM, on the target itself. After accumulating some amount of new working code, I'd run it through the metacompiler and put it in the EPROM with the earlier code, and get back to developing more in RAM. One change I had to make of course is the way variables' data is kept. There is a THERE that's separate from HERE, and THERE keeps the next available address for variables' data space which is separate from the variables' headers which go into ROM.

_________________
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: Sat Sep 08, 2018 11:19 am 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
I've been playing with a Java based cross-compiler for multiple targets for a while but its not finished. It optimises both at the Forth level and at the generated assembly level. The output is subroutine threaded code. The intermediate representation is designed to be interpretable.

The PIC24 back end turns this:
Code:
hex
0220 constant U1MODE inline
0222 constant U1STA inline
0224 constant U1TXREG inline
0226 constant U1RXREG inline
0228 constant U1BRG inline

0100 constant UTXBF inline
0001 constant URXDA inline

: emit ( ch -- )
  begin U1STA @ UTXBF and until
  U1TXREG !
;

: key? ( -- flag )
  U1STA @ URXDA and
;

: key ( -- ch )
  begin key? until
  U1RXREG @
;

\ ==============================================================================

: boot
   1 2 + key 5 lshift
; external

Into this
Code:
; Generated code do not change

                .global boot
boot:                                   ; : boot
                mov.w   #3,w0           ; 3
                mov.w   w0,[++w14]
                call    key             ; key
                mov.w   [w14--],w0
                sl.w    w0,#5,[++w14]   ; 5 lshift
                return                  ; ;

lshift:                                 ; code lshift
                mov.w   [w14--],w0
                mov.w   [w14--],w1
                sl.w    w1,w0,w0
                mov.w   w0,[++w14]
                return                  ; end-code

keyquery_:                              ; : key?
                mov.w   546,w0          ; 546 @
                and.w   w0,#1,[++w14]   ; 1 and
                return                  ; ;

key:                                    ; : key
.L1:
                call    keyquery_       ; key?
                cp0     [w14--]
                bra     z,.L1           ; (?branch)
                mov.w   550,w0          ; 550 @
                mov.w   w0,[++w14]
                return                  ; ;

All of the runtime routines are defined in an include file and only the required ones are actually generated. The comments show where multiple words have been optimised into a single operation (e.g. '550 @' or '1 and'). In keyquery_ the intermediate stack pushes and pulls are removed and w0 is used as the top of stack.

_________________
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs


Top
 Profile  
Reply with quote  
PostPosted: Mon Sep 10, 2018 8:10 pm 
Offline

Joined: Fri May 05, 2017 9:27 pm
Posts: 895
pjeaton wrote:
I just spotted this thread about meta-compiling from not too long ago, I think that's referring to the same thing:
http://forum.6502.org/viewtopic.php?f=9&t=4599

It seems that no-one's quite done it yet?

I used a metacompiler to build my Forth but you'll be disappointed. I didn't metacompile it from a PC, I metacompiled it from the Commodore 64. Starting with an existing Forth, I wrote the metacompiler and the source for the new Forth then rewrote the metacompiler to work with the new Forth.


Top
 Profile  
Reply with quote  
PostPosted: Mon Sep 24, 2018 9:48 pm 
Offline
User avatar

Joined: Wed Feb 23, 2005 9:20 am
Posts: 23
Location: Zurich, Switzerland
Thanks for your thoughts, guys.

So it still looks like there is no freeware Forth cross compilers for 6502 on the PC, but various people are doing their own thing.

_________________
P*h*i*l*l*i*p EEaattoon in real life


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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: