FORTH for every Atari
Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team
FORTH for every Atari
Hello,
I worked again on my FORTH interpreter/editor/Compiler and finally wrote a page about it.
Features:
- binaries for 68030 and 68000
- available in french and english
- compiler to generate a standalone program (GEM, Auto, ACC)
- support for DMA sound (even with the SAGA system of the Vampire)
- support for the Supercharger as a coprocessor
- standard functions GEMDOS, Bios, Xbios, VDI, AES
- lots of data types (integers B, W, L, double precision reals, arrays, enumerated sets or numerical segments, structures, chained structures...)
- create menus within the source (without RSC)
- create dialogs within the source (without RSC)
- windowed dialogs are managed
- conditional compilation (according to the language, the CPU, etc)
- can include an external source sent to an external compiler (as an assembler for example)
- all written in assembly, speed and compacity! (the interpreter, editor, compiler in ram weights only 76KB including its debugging infos)
(english) https://gtello.pagesperso-orange.fr/forth_e.htm
(français) https://gtello.pagesperso-orange.fr/forth_f.htm (with full french PDF manual)
One last thing is to write the english version of the manual...
Guillaume.
I worked again on my FORTH interpreter/editor/Compiler and finally wrote a page about it.
Features:
- binaries for 68030 and 68000
- available in french and english
- compiler to generate a standalone program (GEM, Auto, ACC)
- support for DMA sound (even with the SAGA system of the Vampire)
- support for the Supercharger as a coprocessor
- standard functions GEMDOS, Bios, Xbios, VDI, AES
- lots of data types (integers B, W, L, double precision reals, arrays, enumerated sets or numerical segments, structures, chained structures...)
- create menus within the source (without RSC)
- create dialogs within the source (without RSC)
- windowed dialogs are managed
- conditional compilation (according to the language, the CPU, etc)
- can include an external source sent to an external compiler (as an assembler for example)
- all written in assembly, speed and compacity! (the interpreter, editor, compiler in ram weights only 76KB including its debugging infos)
(english) https://gtello.pagesperso-orange.fr/forth_e.htm
(français) https://gtello.pagesperso-orange.fr/forth_f.htm (with full french PDF manual)
One last thing is to write the english version of the manual...
Guillaume.
You do not have the required permissions to view the files attached to this post.
- mrbombermillzy
- Atari Super Hero
- Posts: 581
- Joined: Tue Sep 13, 2016 9:24 am
Re: FORTH for every Atari
Great work there!
Never looked into FORTH, despite having two books on the subject (the first at the age of 15 years!)
The tutorial on your site makes the language look shockingly easy to manipulate the AES with.
How does it interface with assembly (passing data through registers or on the stack?) and run assembly code?
If any of the above is possible, I will be keeping a very close eye on this!

Never looked into FORTH, despite having two books on the subject (the first at the age of 15 years!)
The tutorial on your site makes the language look shockingly easy to manipulate the AES with.
How does it interface with assembly (passing data through registers or on the stack?) and run assembly code?
If any of the above is possible, I will be keeping a very close eye on this!

Re: FORTH for every Atari
Inside FORTH, a6 points to the stack, so it's very easy to pass parameters to an assembly code.mrbombermillzy wrote: ↑Tue Feb 15, 2022 8:02 pm Great work there!![]()
Never looked into FORTH, despite having two books on the subject (the first at the age of 15 years!)
The tutorial on your site makes the language look shockingly easy to manipulate the AES with.
How does it interface with assembly (passing data through registers or on the stack?) and run assembly code?
If any of the above is possible, I will be keeping a very close eye on this!![]()
I was thinking of adding a paragraph with an example interfacing ASM and FORTH...
There are several possibilities, the most powerful is to create FORTH words entirely in ASM : their names, codes are created in assembly and, when loaded during compilation, they appear as normal words that you can use.
Guillaume.
Re: FORTH for every Atari
As a fast example, suppose you want to write a little word that tells you if a year is a leap year:
prepare in ASM:
Then you can assemble this source as, for example, "C:\LEAP.PRG"
Then in FORTH, just add:
And you have the new word isLeap that returns 0 if it's a common year and 1 for a Leap year:
That's it !
So you see, FORTH uses the DATA section to tell the addresses and names of the new words. (there can be more than one).
You just have to preserve A4-A5, and use A6 as the stack pointer to get your parameters and return the results.
Guillaume.
prepare in ASM:
Code: Select all
text
leap:
dc.w 437 ; code for assembly word
move.l (a6)+,d0 ; take the year
move.l d0,d1
and #$0003,d1 ; multiple of 4 ?
bne.s .common ; no so it's a common year
divs #100,d0 ; else, we know it's multiple of 4
swap d0
tst d0 ; multiple of 100?
bne.s .leap ; no, so it's a leap year
swap d0
and #$0003,d0 ; multiple of 400?
beq.s .leap ; yes, so leap
common:
moveq #0,d0
bra.s .exit
.leap:
moveq #1,d0
.exit:
move.l d0,-(a6)
rts
data
dc.b "ADD_DEFS" ; magic word
dc.l leap,-1
dc.b "isLeap",0
end
Then in FORTH, just add:
Code: Select all
0 >include "C:\LEAP.PRG"
Code: Select all
2022 isLeap . \will return 0
1900 isLeap . \will return 0
2000 isLeap . \ will return 1
So you see, FORTH uses the DATA section to tell the addresses and names of the new words. (there can be more than one).
You just have to preserve A4-A5, and use A6 as the stack pointer to get your parameters and return the results.
Guillaume.
- mrbombermillzy
- Atari Super Hero
- Posts: 581
- Joined: Tue Sep 13, 2016 9:24 am
Re: FORTH for every Atari
Sounds great.
The next thing I will ask (doesnt seem to be in the above example), is whether there is the option for parameter passing with these FORTH 'words', and if so, are they calculated/equated and compiled before, or on the same pass as the code (and therefore valid), or after?
What Im really looking for with the above, is the ability to use variable based arguments for the language 'words' which will be valid and not calculated on a later compile pass. Is this done? (This is the biggest drawback for making much more effective assembler MACROs IMHO; values that are not calculated/known before the actual code argument compile pass and therefore invalid).
Hope the above makes some sense, its getting a bit late in the day here!

The next thing I will ask (doesnt seem to be in the above example), is whether there is the option for parameter passing with these FORTH 'words', and if so, are they calculated/equated and compiled before, or on the same pass as the code (and therefore valid), or after?
What Im really looking for with the above, is the ability to use variable based arguments for the language 'words' which will be valid and not calculated on a later compile pass. Is this done? (This is the biggest drawback for making much more effective assembler MACROs IMHO; values that are not calculated/known before the actual code argument compile pass and therefore invalid).
Hope the above makes some sense, its getting a bit late in the day here!


Re: FORTH for every Atari
cool stuff, thanks for providing not only the binary but also the sources!
Re: FORTH for every Atari
Nice! Forth is a language I have absolutely no idea of how it works but I know it has inspired lots of modern languages.
- viking272
- Atari Super Hero
- Posts: 705
- Joined: Mon Oct 13, 2008 12:50 pm
- Location: west of London, UK
Re: FORTH for every Atari
Wow, there is such a lot here. Thank you Guillaume.
It's all very polished and like a commercial package that a whole team has worked on.
I noticed the French manual doesn't have page numbers on each page but it's very well indexed and obviously searchable in the PDF format.
How did you create the PDF document? Is it from LibreOffice?
Do you need help from the community for an English translation?
It's all very polished and like a commercial package that a whole team has worked on.
I noticed the French manual doesn't have page numbers on each page but it's very well indexed and obviously searchable in the PDF format.
How did you create the PDF document? Is it from LibreOffice?
Do you need help from the community for an English translation?
Re: FORTH for every Atari
Amazing! Thank you, Guillaume!
Re: FORTH for every Atari
Hello!mrbombermillzy wrote: ↑Tue Feb 15, 2022 10:07 pm Sounds great.
The next thing I will ask (doesnt seem to be in the above example), is whether there is the option for parameter passing with these FORTH 'words', and if so, are they calculated/equated and compiled before, or on the same pass as the code (and therefore valid), or after?
What Im really looking for with the above, is the ability to use variable based arguments for the language 'words' which will be valid and not calculated on a later compile pass. Is this done? (This is the biggest drawback for making much more effective assembler MACROs IMHO; values that are not calculated/known before the actual code argument compile pass and therefore invalid).
Hope the above makes some sense, its getting a bit late in the day here!![]()
![]()
I'm afraid I didn't understand the question...
I'm terribly sorry...
Guillaume.
Re: FORTH for every Atari
Thanks! It looks polished... The FORTH window is a draft one, no redraws. Your programs can output text, drawings etc... and this is not memorized.viking272 wrote: ↑Tue Feb 15, 2022 11:07 pm Wow, there is such a lot here. Thank you Guillaume.
It's all very polished and like a commercial package that a whole team has worked on.
I noticed the French manual doesn't have page numbers on each page but it's very well indexed and obviously searchable in the PDF format.
How did you create the PDF document? Is it from LibreOffice?
Do you need help from the community for an English translation?
But, within your program, you can manage the redraws, and the FORTH provides some instructions to help.
I first wrote the manual using Atari Works ! Then, I just had to export it to RTF to be able to load it in Libre Office (as you guessed!).
Some help for translating would be appreciated! I can add the original ODT document to my page.
Guillaume.
Re: FORTH for every Atari
It works like a HP calculator. It uses a stack : every new parameter (a number a string address, ...) is pushed on the stack and every function (or word) pops its parameters from the stack and eventually returns values on the stack.
For example, to do the sum: 8+9 you write:
Code: Select all
8 9 +
Another example, if you want to open a file for output:
Code: Select all
" MYFILE.EXT" 1 fopen
Then the value 1 is on the stack (1=write to file)
and fopen pops those two values and if successful, returns the file handle. You can save it to a variable or just use it from the stack.
Let's complete the example, you open the file, write the whole ST screen to it (32000 bytes starting at physbase) and close it:
Code: Select all
" BLOCK.BIN" 1 fopen
dup 32000 physbase fwrite .
fclose
On the second line the handle is duplicated (because we'll need it for fclose), the screen is saved and fwrite returns the number of bytes actually saved, the period pops this value and displays it for checking.
On the last line the duplicated handle is used by fclose.
That's is, without any variable.
Guillaume.
- viking272
- Atari Super Hero
- Posts: 705
- Joined: Mon Oct 13, 2008 12:50 pm
- Location: west of London, UK
Re: FORTH for every Atari
I would like to help with translation but maybe a page at a time...then commit my edits. Some weeks I have very limited time. Is this possible? 
- mrbombermillzy
- Atari Super Hero
- Posts: 581
- Joined: Tue Sep 13, 2016 9:24 am
Re: FORTH for every Atari
Hey, no worries. I will try to explain better with an example scenario...
Lets say I wanted to make a language word 'Graphics' which took a variable 'Screenheight'; the variable being either of two values, so I could set my ST screen to LOW or MED res accordingly, in the language word 'Graphics' code.
Now, would this variable passing be possible, or would this cause an error on compilation because the variable 'Screenheight' is not defined?
Hope thats clearer to understand.

Last edited by mrbombermillzy on Wed Feb 16, 2022 8:50 am, edited 1 time in total.
Re: FORTH for every Atari
Many thanks ! I'll tell you when the ODT file is available.
I started programming this FORTH back in 1989... So there's no hurry.
Guillaume.
Re: FORTH for every Atari
That's clearer !mrbombermillzy wrote: ↑Wed Feb 16, 2022 8:47 amHey, no worries. I will try to explain better with an example scenario...
Lets say I wanted to make a language word 'Graphics' which took a variable 'Screenheight'; the variable being either of two values, so I could set my ST screen to LOW or MED res accordingly, in the language word 'Graphics' code.
Now, would this variable passing be possible, or would this cause an error on compilation because the variable 'Screenheight' is not defined?
Hope thats clearer to understand.![]()
It is not possible, every word or variable used in a new word must be defined before. But what you can do is to use an argument from the stack:
Graphics takes a parameter on the stack (either 0 or 1 for example) and sets the screen mode.
Then, you can use
Code: Select all
0 Graphics
1 Graphics
So then if a variable is defined after, let's call it Screen, you can use:
Code: Select all
Screen @ Graphics
Hope this is clear...
Guillaume.
- mrbombermillzy
- Atari Super Hero
- Posts: 581
- Joined: Tue Sep 13, 2016 9:24 am
Re: FORTH for every Atari
Yes.
Thank you so much for taking the time to explain.

Im guessing then, in this manner, that you can have as many parameters as you like (stack permitting)?
(Sorry for all the hardcore questions, but I need to know, as this could be something HUGE for me!)
Re: FORTH for every Atari
yes, you can have a huge piling of numbers.mrbombermillzy wrote: ↑Wed Feb 16, 2022 9:10 amYes.
Thank you so much for taking the time to explain.![]()
Im guessing then, in this manner, that you can have as many parameters as you like (stack permitting)?
(Sorry for all the hardcore questions, but I need to know, as this could be something HUGE for me!)
I guess the stack is 1KB long, so this is 256 long values.
My Forth allows you to create other stacks, so if you really need 1 MB as a stack, you can have it and push many values to satisfy your gluttony !!
Example:
Code: Select all
2000 &stack MyStack
MyStack current
Code: Select all
stack0 current
Guillaume.
Re: FORTH for every Atari (adding Assember Code)
Hi,
I have added an example on how to mix Assembler and Forth, and this can be done in one and only source file! (at the bottom of the page)
I have added the ODT manual that you can edit for translation. (at the top of the page)
(english) https://gtello.pagesperso-orange.fr/forth_e.htm
(français) https://gtello.pagesperso-orange.fr/forth_f.htm
Guillaume.
I have added an example on how to mix Assembler and Forth, and this can be done in one and only source file! (at the bottom of the page)
I have added the ODT manual that you can edit for translation. (at the top of the page)
(english) https://gtello.pagesperso-orange.fr/forth_e.htm
(français) https://gtello.pagesperso-orange.fr/forth_f.htm
Guillaume.
You do not have the required permissions to view the files attached to this post.
- viking272
- Atari Super Hero
- Posts: 705
- Joined: Mon Oct 13, 2008 12:50 pm
- Location: west of London, UK
Re: FORTH for every Atari
I ran the French manual through Google Translate and it spat out an English version. (they can handle PDF/DOCX formats)
Clearly it will need proof reading plus re-arranging some literal translations etc but it may be a good place to start?
I emailed you this version too for comments.
Clearly it will need proof reading plus re-arranging some literal translations etc but it may be a good place to start?
I emailed you this version too for comments.
- mrbombermillzy
- Atari Super Hero
- Posts: 581
- Joined: Tue Sep 13, 2016 9:24 am
Re: FORTH for every Atari
lol. Thanks.
Apologies if I want clear.
It wasnt so much the stack that I was wanting to extend, but the no. of arguments to a max of about 4. (Would not need the whole stack of arguments!)
If we continue with the example maybe?

So...
Screen @ Graphics
Depth @ Graphics
Blah1 @ Graphics
Blah2 @ Graphics
etc.
Will place Screen,Depth,Blah1,Blah2 on the stack in this order; all accessible from the Graphics word.
Im guessing this is ok to do?
Re: FORTH for every Atari
Actually, it's simpler:mrbombermillzy wrote: ↑Wed Feb 16, 2022 11:34 am
Screen @ Graphics
Depth @ Graphics
Blah1 @ Graphics
Blah2 @ Graphics
etc.
Will place Screen,Depth,Blah1,Blah2 on the stack in this order; all accessible from the Graphics word.
Im guessing this is ok to do?
Code: Select all
Screen @ Depth @ Blah1 @ Blah2 @ Graphics
Guillaume.