Forth Language anyone?

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

Forth Language anyone?

Logan_5
I have made it through the course to the Jack Compiler stage.  The Virtual machine that was defined just sparked a few ideas that seemed more interesting to me, and I set the lessons aside to pursue another project.  I have found an excellent and instructive source code in x86 assembler for Forth language.  (http://rwmj.wordpress.com/2010/08/07/jonesforth-git-repository/) I am porting it over to the Hack platform and am having good results.  The source code is meant to run under the Linux OS,  and I am adapting my version to use Jack OS instead.  However Forth language is so extensible that I am seeing ways to implement the Jack OS functions in Forth and come up with a stand alone language/OS for the Hack platform.  Great fun!  One interesting aspect is that the Forth language has let me find a way to side-step the Harvard Architecture of the Hack platform and move more towards a Von-Neumann model.  That is, the user program written in Forth resides completely in RAM along with the data.   The ROM only contains the interpreter for the Forth language and the end user can effectively disregard it.  I have seen a few posts about changing the hardware architecture of the Hack Platform to get something like this.  It is interesting that you can achieve the same kind of effect with software alone.  
Don't think me unkind, words are hard to find, they're only cheques I've left unsigned, from the banks of chaos in my mind.
Reply | Threaded
Open this post in threaded view
|

Re: Forth Language anyone?

ybakos
Awesome!
Reply | Threaded
Open this post in threaded view
|

Re: Forth Language anyone?

eterps
In reply to this post by Logan_5
That's very impressive!
Any chance you will share your work with us in the future? In my opinion it would provide a valuable learning experience about different implementation strategies for TECS.

You also might be interested in a thread I once started on the 'fonc' mailing list:

http://www.mail-archive.com/fonc@vpri.org/msg01614.html

'fonc' stands for fundamentals of new computing, a project lead by Alan Kay (the inventor of Object Orientation).

If you want more information about this project read the following report:
http://www.vpri.org/pdf/tr2011004_steps11.pdf

Kind regards,

Erik.
Reply | Threaded
Open this post in threaded view
|

Re: Forth Language anyone?

Logan_5
Yes, I plan on making it available once it is presentable.  Lots of grinding work.  When you are writing a language, the monotonous part is making sure that each one of the commands work correctly. :-)  Forth Language isn't so bad because it kind of "pulls itself up by its own bootstraps" so to speak.  Once I have the core set of primitive Forth commands written, then the rest of the Language is written in terms of these primitive Forth commands.  The rest of Forth is written in Forth.  Kind of a mind bending computer language.
Don't think me unkind, words are hard to find, they're only cheques I've left unsigned, from the banks of chaos in my mind.
Reply | Threaded
Open this post in threaded view
|

Re: Forth Language anyone?

ybakos
In reply to this post by eterps
@eterps Interesting! I've downloaded the doc; can you tell me more about fonc/STEPS in your own words?
Reply | Threaded
Open this post in threaded view
|

Re: Forth Language anyone?

eterps
FONC/STEPS in my own words?

In my opinion it tries to answer the following question:

Regarding the current state of computing: Operating Systems, Shells, Programming languages, Applications etc.; if we would start all over again, what would be the simplest, shortest way to get to this functionality from scratch.
dlk
Reply | Threaded
Open this post in threaded view
|

Re: Forth Language anyone?

dlk
In reply to this post by Logan_5
Just curious, how do you get the Forth program and data into RAM in the first place?
Reply | Threaded
Open this post in threaded view
|

Re: Forth Language anyone?

Logan_5
Well, luckily I found that the CPU emulator holds its RAM contents even if you load a different program into ROM.  So my process goes like this:  I have written a translator program, much like the VM translator program in the course.  The translator translates my Forth Language code into a Hack assembly language program that I load into ROM.  When run, this program's only purpose is to store the Forth Language code and data into RAM.  Once this little loader program has done the storage of my Forth code into RAM, then I load my Forth Interpreter into ROM.  I then run the forth interpreter and it does what the Forth code loaded into RAM (in a roundabout way) :-) tells it to do.  I wish the CPU emulator had some way to directly load data into RAM.  
Don't think me unkind, words are hard to find, they're only cheques I've left unsigned, from the banks of chaos in my mind.
dlk
Reply | Threaded
Open this post in threaded view
|

Re: Forth Language anyone?

dlk
Clever! Thanks,
- Dan
Reply | Threaded
Open this post in threaded view
|

Re: Forth Language anyone?

Logan_5
In reply to this post by Logan_5
Just an update:
Some really good progress.  My Forth interpreter is now self hosting.  It has a core set of primitive Forth commands and can now compile more.  It's kind of neat.  More the kind of behavior I have come to expect from a real computer.  That is you boot it up and it gives you a command prompt.  From there on the only limit is your creativity.  Things should be less complicated now.  So far, I have had to translate the Forth interpreter from x86 assembly language to Hack assembly language.  Now the rest of the Forth language is written in Forth.  So no more translation.  With all due respect, I dropped Jack OS from my project.  I wrote the screen output routines myself as pure Forth commands.  I did use the font data from Jack OS though, so credit where it is due.  Now that the program has become interactive, I can easily try lots of things that should make more bugs rear their ugly head.  I'm not out of the woods yet.
Don't think me unkind, words are hard to find, they're only cheques I've left unsigned, from the banks of chaos in my mind.
Reply | Threaded
Open this post in threaded view
|

Re: Forth Language anyone?

eterps
Thanks for the update.
I would love to see a screenshot of your command prompt with some Forth commands.
Reply | Threaded
Open this post in threaded view
|

Re: Forth Language anyone?

Logan_5
Here is an image of me trying some of the forth language definitions.  The cursor is flashing by the way, but it just looks solid in the picture. :-)

Don't think me unkind, words are hard to find, they're only cheques I've left unsigned, from the banks of chaos in my mind.
Reply | Threaded
Open this post in threaded view
|

Re: Forth Language anyone?

eterps
Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: Forth Language anyone?

Logan_5
In reply to this post by Logan_5
Another update with still more progress.  The program is getting to be amazing.  I have a pretty full set of Forth commands in place, but I am aiming to make it ANS Forth compliant (once I understand fully what that means).  I can type programs in from the command prompt, OR I have a way to write the programs externally in a text file with lots of comments and whitespace.  I have a translator written in python that will make the text file into a Hack assembly language file that stuffs all of the text (comments and all) in to RAM.  Then the assembly language file points Forth's input buffer at the text.  So when you start up, the Forth interpreter sees all of that text as input and compiles it.  Pretty slick.
Here is a sample screen of it compiling a few commands and executing them.

Don't think me unkind, words are hard to find, they're only cheques I've left unsigned, from the banks of chaos in my mind.
Reply | Threaded
Open this post in threaded view
|

Re: Forth Language anyone?

shubhrapandit
In reply to this post by Logan_5
I am glad to see this brilliant post. all the details are very helpful and good for us, keep up to good work.I found some useful information in your post, it was awesome to read, thanks for sharing this great content to my vision, keep sharing.

Regards - OET Classes in Pune
Reply | Threaded
Open this post in threaded view
|

Re: Forth Language anyone?

DiamondCoder1000
In reply to this post by Logan_5
Can you send the .jack source code? Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: Forth Language anyone?

Lozminda
And I thought doing Big Number functions was a grind (I got the VMEmulator to reproduce the Mandelbrot set, you could zoom in if you had a few weeks to spare). Fair play. I'd love to see the source code too if poss.

Fantastic work !

Loz