V-FORTH - Forth-83 for the VIC

Basic and Machine Language

Moderator: Moderators

User avatar
srowe
Vic 20 Afficionado
Posts: 468
Joined: Mon Jun 16, 2014 3:19 pm

V-FORTH - Forth-83 for the VIC

Postby srowe » Tue Jul 28, 2015 2:46 pm

Well it's only taken about a year but I've got a mostly complete implementation of Forth-83 for the VIC. It has a set of words to interact with disk drives via the KERNAL.

It requires a VIC (or emulator) with 24 KB expansion and one or more disk drives.

To load and start the interpreter use

Code: Select all

load "*",8,1
sys 8192


There is an example file containing words to list a disk directory and perform DOS commands (scratch etc) similar to the DOS wedge. This can be loaded with

Code: Select all

s" dos.fs" included


Watch the space, this is the conventional way of handling string arguments to Forth words. Listing a directory using

Code: Select all

dos
$


and you can run DOS commands with

Code: Select all

@" c0:new.fs=0:dos.fs"


This isn't finished, I am going to add words to do hi res graphics and make adjustments so that the base code is ROMable.
Attachments
vforth.zip
(7.71 KiB) Downloaded 57 times

User avatar
orion70
Meteo VIC
Posts: 3287
Joined: Thu Feb 02, 2006 4:45 am
Location: Piacenza, Italy
Occupation: Biologist

Re: V-FORTH - Forth-83 for the VIC

Postby orion70 » Wed Jul 29, 2015 2:37 am

Wow, a new programming language for the VIC! Forth is really one that attracted me back in the late Eighties, but never took the time (and heart) to read a book and learn it. BTW, here's the Forth-83 manual. Will this manual apply to V-FORTH? And one more question: how this is different from the traditional Forth cartridge?

User avatar
srowe
Vic 20 Afficionado
Posts: 468
Joined: Mon Jun 16, 2014 3:19 pm

Re: V-FORTH - Forth-83 for the VIC

Postby srowe » Wed Jul 29, 2015 12:28 pm

Yes, that's the doc I used as reference to convert to Forth-83. If you're a newcomer to Forth I can recommend Leo Brodie's 'Starting Forth'. There's an online version

http://www.forth.com/starting-forth/

or the Second Edition of the paper edition can be found very cheaply in online bookstores.

There are several VIC Forth cartridges, I have the HES Forth cartridge which is a fig-FORTH implementation. This is an older version but most of the differences are not important to the casual user.

I meant to mention, the source and build can be downloaded from http://eden.mose.org.uk/vforth.git

User avatar
orion70
Meteo VIC
Posts: 3287
Joined: Thu Feb 02, 2006 4:45 am
Location: Piacenza, Italy
Occupation: Biologist

Re: V-FORTH - Forth-83 for the VIC

Postby orion70 » Thu Jul 30, 2015 3:40 am

srowe wrote:Yes, that's the doc I used as reference to convert to Forth-83. If you're a newcomer to Forth I can recommend Leo Brodie's 'Starting Forth'. There's an online version

http://www.forth.com/starting-forth/

Thank you! Juergen Pintaske at ExMark has produced a PDF with Forth Inc's permission to download. It is a pdf of the online version, retaining all the original humorous graphics.

As an alternative, there's also an Italian book dedicated to FORTH for the VIC and C64, so I won't have to double-jump from FORTH to English, and from English to Italian :mrgreen: . I wonder how "compatible" with V-FORTH it is, though :?:

User avatar
srowe
Vic 20 Afficionado
Posts: 468
Joined: Mon Jun 16, 2014 3:19 pm

Re: V-FORTH - Forth-83 for the VIC

Postby srowe » Thu Jul 30, 2015 1:31 pm

Pretty much any book should be of use with V-FORTH, from the point of view of syntax and programming approach. The big difference is the lack of the traditional Forth screens and editor. These are very specific to Forth and completely at odds with the file-oriented nature of all other modern programming languages. I haven't bothered implementing screens, V-FORTH just loads text from SEQ files.

I'd really be interested in hearing how you get on with it.

Bobbi
Vic 20 Afficionado
Posts: 347
Joined: Thu Oct 13, 2016 11:35 am
Location: Toronto
Occupation: Programmer

Re: V-FORTH - Forth-83 for the VIC

Postby Bobbi » Sun Nov 06, 2016 10:55 am

I am a Forth newbie (well I used to have a Jupiter Ace a million years ago, but I am very rusty ...)

How does V-Forth compare to Datatronic VICForth 1.1? It is amazing we have multiple implementations to choose from!

User avatar
srowe
Vic 20 Afficionado
Posts: 468
Joined: Mon Jun 16, 2014 3:19 pm

Re: V-FORTH - Forth-83 for the VIC

Postby srowe » Sun Nov 06, 2016 11:57 am

Bobbi wrote:I am a Forth newbie (well I used to have a Jupiter Ace a million years ago, but I am very rusty ...)


I too had a Jupiter Ace, wish I hadn't sold it!

How does V-Forth compare to Datatronic VICForth 1.1? It is amazing we have multiple implementations to choose from!


That appears to be a FIG-Forth implementation. V-Forth started out as that but I 'upgraded' it to FORTH-83. The core differences are minimal, the biggest change is that there's no editor. Usually FORTH has a dictionary which provides a screen editor, I decided that as we have WYSIWYG editors on more powerful computers these days there was no point. So you need to develop your code on a PC, save it to a SEQ file then INCLUDE the text instead. You can then save the compiled dictionary and load it back.

I've created a number of dictionaries, a graphics one that can plot characters or bitmaps, a sound one that can play tunes. I'm in the process of writing a version of Blue Meanies to show off these.

Give it a try and let me know how you get on.

Bobbi
Vic 20 Afficionado
Posts: 347
Joined: Thu Oct 13, 2016 11:35 am
Location: Toronto
Occupation: Programmer

Re: V-FORTH - Forth-83 for the VIC

Postby Bobbi » Sun Nov 06, 2016 12:27 pm

I'll add it to my list of VIC-things to check out!! Right now I am distracted with another project ...

Incidentally the editor words for VIC-Forth were distributed on a floppy disk that I can't seem to find an image of. The FORTH source for the editor and assembler is included in the manual so I could type it in (without making any mistakes or I need to type that word definition from scratch ...)

Forbidden64
Vic 20 Hobbyist
Posts: 109
Joined: Sun Feb 28, 2016 9:59 pm
Location: CA USA

Re: V-FORTH - Forth-83 for the VIC

Postby Forbidden64 » Tue Apr 04, 2017 6:36 am

I'm still learning FORTH off and on...I still don't know how to do a manual store of bits and bytes to ram from FORTH, and that is what stops me from writing lots of code in it. Being able to define words to do tasks which control memory & I/O is crucial. With it, one can simply write blocks and blocks of graphics/sound/peripheral control routines in FORTH natively just by scaling up from the basic words. I think if that existed, pretty much everything else would follow. I'm pulling out my forth book and I don't really see anything about it in here. Which is crazy! It has to be! I am half done with the book and I can't do something as simple as a POKE lol. Even if I did a system call to a machine language routine to perform an LDA $ADDR STA $SOMEWHERE ELSE or whatever, how would I even get the machine to place the words in a spot I want them in to pass the parameter to the machine instruction routine? I'm am such a newb. Anyone know what the FORTH command is for a 'poke'?

I can say for one that the editor in the original cartridge for HES FORTH is awful compared to BASIC or... anything else. One time it glitched filled the whole screen with scrolling garbage and then deleted my program! I did something I shouldn't have from the main screen and I don't remember what it was. I always wanted a full screen editor for FORTH with no weird stuff like the side scrolling etc., and EDLIN style control schemes reminiscent of the early CP/M... I'm sure if I used it more, I would become quick and efficient with it. I went out of my way to get a FORTH cart for the vic anyway though because it is so fascinating. What I do like about the HES FORTH cart is that all it requires is a datasette and a vic 20; it has multiple ram configurations (by ignoring the 3k gap in all cases); it can run with any size ram expander such as the 8, 16, and 24k expanders from the era. Because it is cassette based, this does mean you can't do some things like swapping out blocks from the floppy like you can with the C64's Datatronic version(which is awesome imho and is essentially a built in MMU, so I hope it is in yours!), but the HES version on vic is still incredible given that no other FORTH I have seen for a commodore allows for tape and runs on the native machine hardware, with just a rom cartridge and nothing else. Technically, not even a datasette. I always think of the VIC as a tape centric computer...though I think that puts me squarely in the minority of modern hobbyists. I see most distributions are in .D64 format for instance. It could be a consequence of all the cross development going on though, and that VICE doesn't support writing .TAP files.[edit! the vice manual in section 5.5 is wrong about this...it does support .tap just fine]

Unfortunately, I don't have a 24k expansion for my vic... :< just a 16K. Otherwise I would already be playing with this! I guess I could use it in an emulator :/ but that just isn't as fun...I'm going to put it in my emulator anyway. I'm just worried that I'll like it too much, and then not have it on my real VIC.[another edit, version 3+ has prg, and rom images which can run just fine with +16k]
Last edited by Forbidden64 on Wed Apr 05, 2017 7:54 am, edited 2 times in total.

Forbidden64
Vic 20 Hobbyist
Posts: 109
Joined: Sun Feb 28, 2016 9:59 pm
Location: CA USA

Re: V-FORTH - Forth-83 for the VIC

Postby Forbidden64 » Tue Apr 04, 2017 7:05 am

Darn it...I booted it up, and typed 'words', and now I have to buy a 24k cart. I saw all the sys-xxxxx commands you added. I'm trying out
sys-writeb

I tried

240 36869 sys-writeb

and the cursor vanished along with any subsequent text. Would that be the incorrect syntax?

User avatar
Mike
Herr VC
Posts: 2993
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: V-FORTH - Forth-83 for the VIC

Postby Mike » Tue Apr 04, 2017 8:51 am

Forbidden64 wrote:[...] VICE doesn't support writing .TAP files.

Eh, what? :?:

I tried

240 36869 sys-writeb

and the cursor vanished along with any subsequent text. Would that be the incorrect syntax?

The default value of VIC-Register 36869 for +8K RAM or more is 192, not 240. Of course that depends on that V-Forth also uses a screen base of $1000. Would be more sensible to try out a change of background/border though, by writing to 36879. IMO.

That being said, Forth has a memory model that organizes the RAM in words, not bytes. You'd normally use the ! operator to store a word at a given address, and @ to fetch it. c! and c@ are there to access characters, i.e. single bytes.

...

As the saying goes: if you've seen one Forth then, well, you've seen one Forth. :lol:

Forbidden64
Vic 20 Hobbyist
Posts: 109
Joined: Sun Feb 28, 2016 9:59 pm
Location: CA USA

Re: V-FORTH - Forth-83 for the VIC

Postby Forbidden64 » Tue Apr 04, 2017 11:41 am

I'm aware of all that. What the desired result was(perhaps counter intuitively), was garbage on the screen. Which I didn't get, which means it did not have the desired effect, and could therefore not create consistent results with that syntax, or is, perhaps, not what I think it is.

My question was more about the nature of the syntax of that statement, and how it produced that particular result. Subsequent text was invisible, as was the cursor, and the previous text remained on the screen completely unaffected.

Forbidden64
Vic 20 Hobbyist
Posts: 109
Joined: Sun Feb 28, 2016 9:59 pm
Location: CA USA

Re: V-FORTH - Forth-83 for the VIC

Postby Forbidden64 » Tue Apr 04, 2017 12:04 pm

Yes, Vice doesn't support writing .TAP files. At least according to their instruction manual, and what I have found in practice:
section 5.5 of VICE manual paragraph 4:

Supported formats are D64 and X64 for disk images (devices 8, 9 and 10) and T64 for tape images. Notice that T64 support is read-only, and that the cassette is automatically rewound when you reach its end.


I noted that the rewind part is not actually the case, it just stops at the end of the image, but the counter stays, and sometimes the rewind button doesn't even work, so you have to reattach the tape image. I also noted that there are many more formats available on VICE than this manual specifies. It may indeed be that their own manual is blatantly false and undersells the capability of an entire drive mechanism, but that would be nuts.

As the saying goes: if you've seen one Forth then, well, you've seen one Forth. :lol:


LOL ain't that the truth! FORTH and COMAL...

Comal actually has sections in it where it tells you that you'll have to change syntax to use comal software with comal...ON THE SAME SYSTEM!! LOL. They actually changed regular syntactical conventions in a subsequent version, and then just sent a paper addendum to tell users why all the software(what little there was) would have to be combed over painstakingly to find all the = that needed to be := or whatever for some bizarre reason they didn't explain. I guess that, and the fact it cost 130$ in 1980's money kind of put people off(as well as a scathing article from a magazine accusing them of fraud). I still like COMAL 80...and actually did pay 130$ in 2010s money to get the cartridge 3 years ago...originals aren't easy to come by, and with the above shortcomings long over, it is very easy to build presentable modular applications quickly in comal.

User avatar
srowe
Vic 20 Afficionado
Posts: 468
Joined: Mon Jun 16, 2014 3:19 pm

Re: V-FORTH - Forth-83 for the VIC

Postby srowe » Tue Apr 04, 2017 12:33 pm

Forbidden64 wrote:I'm still learning FORTH off and on...I still don't know how to do a manual store of bits and bytes to ram from FORTH, and that is what stops me from writing lots of code in it.


The FORTH words you need are ! (store) and fetch (@), for byte accesses C! and C@

Code: Select all

HEX
98 1000 C!


Would display a reverse video X in the top left of the screen.

Unfortunately, I don't have a 24k expansion for my vic... :< just a 16K. Otherwise I would already be playing with this!


16K expansion is enough to run the PRG version of V-FORTH, it leaves you with 8K for the dictionary.

User avatar
srowe
Vic 20 Afficionado
Posts: 468
Joined: Mon Jun 16, 2014 3:19 pm

Re: V-FORTH - Forth-83 for the VIC

Postby srowe » Tue Apr 04, 2017 12:41 pm

Forbidden64 wrote:Darn it...I booted it up, and typed 'words', and now I have to buy a 24k cart. I saw all the sys-xxxxx commands you added. I'm trying out
sys-writeb

I tried

240 36869 sys-writeb

and the cursor vanished along with any subsequent text. Would that be the incorrect syntax?


The $- words are interfaces to KERNAL routines, $WRITEB outputs a single character to file handle (somewhat like PRINT#). The source has comments about usage, here's a link to the code (you want system.fs)

http://eden.mose.org.uk/gitweb/?p=vforth.git;a=tree


Return to “Programming”

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest