For the comparision, there is the original BASIC code::smt023
410 CODE FINDMEM=HEX$("7d,6,3,f7,b,21,0,80,eb,b7,ed,52,c9")
2040 LET SCREEN_MEM=REM(USR(FINDMEM,102),16384)
2045 LET INK_COLOUR=GREEN
2050 FOR CHAR=65 TO 90
2060 FOR POSITION=0 TO 959
2070 SPOKE 255,SCREEN_MEM+POSITION,CHAR
2080 NEXT
2082 LET INK_COLOUR=(INK_COLOUR+25) BAND 255
2084 SET #102:PALETTE 0,INK_COLOUR
2090 NEXT
It is running for about 6 minutes. The FORTH version is only about 10 seconds! Good demonstrate the speed difference between the two language! Impressive!
(And the FORTH have support for the EXOS Special Function call, no machine code needed for ask the video address.)
http://www.forth.com/starting-forth/index.html (http://www.forth.com/starting-forth/index.html)It looks great for beginners! (I also like the cartoons :-) )
I found something what I not understood :oops:If you put BINARY before : ABC ... it will work as expected.
(Attachment)
10 PROGRAM "cdef.bas"
20 NUMERIC C(9)
30 RESTORE 1000
40 FOR I=1 TO 9
50 READ A
60 LET C(I)=BIN(A)
70 NEXT
80 SET CHARACTER 32,C(1),C(2),C(3),C(4),C(5),C(6),C(7),C(8),C(9)
1000 DATA 10000001
1010 DATA 01000010
1020 DATA 00100100
1030 DATA 00011000
1040 DATA 00011000
1050 DATA 00100100
1060 DATA 01000010
1070 DATA 10000001
1080 DATA 11111111
And the FORTH:The [ DECIMAL ] part is only so we don't end up in binary at the command line.But funny if it is happened :-D
But funny if it is happened :-DAll DECIMAL, BINARY etc do is store 10, 2 etc in a variable called BASE. So even more confusing:
(Attachment)
The manual talking separately about the IS-FORTH and then the Enterprise specific FORTH things.I don't think it was ever planned for release on other systems, but it was written first on another system and then the Enterprise bits added. There was a new standard at the time, FORTH-83, which IS-FORTH was written to, and then the Enterprise extensions added - I think that might be why the manual is written the way it is. I never heard about Videoton being interested in FORTH but, as a mere meek and mild programmer, I was not involved in any discussions with them myself!
The IS-FORTH is released for other systems? Or it is planned for later but not happened because the collapse? The Videoton not interested about the FORTH?
How can Load/Save programs?I was reading the IS-FORTH manual on this and it is very confused!
The description of the "NAME" not fully clear for me :oops:
Can you write some examples? (for Tape and Disk)
" filename" NAMEThis is more simple than the manual say on the page 47 :-)
I played at Tape config then can see in the status line what currently saving.:smt023 I don't know how you found that! I was wondering how it would know which system to use. :smt017
Without NAME specification then saving null filename. With NAME then the specified filename.
After the BUFFERS OFF then numbered .4TH files saved.
For example 1,2,10 buffers used then 10.4TH, 2.4TH, 1.4TH, NAME not used.
The FORTH detect the EXDOS at the start and switch the BUFFERS OFF (and left ON if no EXDOS).But not with ep128emu! :ds_icon_frown:
Now I played in EXDOS mode:It is worth adding to this that if you EDIT in disk mode, the changes may not be written to the disk file until you FLUSH, which writes all modified blocks to disk.
Without NAME null filename used. For loading this is translated by the EXDOS to filename "START", if a FORTH program saved with this name then the LOAD-BUFFERS (pressing F1 key) can load it.
Important default: BUFFERS OFF
At this mode, the SAVE-BUFFERS not use the the NAME! Saving separate numbered .4TH files.
At the LOAD or EDIT command if not in the memory the speccified block the try load from the disk, if not exist then create new empty block.
For example 10 LOAD automaticaly load and compile the 10.4TH file.
If switched BUFFERS ON then SAVE-BUFFERS use NAME and save all blocks to one file.
The "all blocks" and the "numbered" files are different format.
The "numbered" are simple 1024 bytes text files, the "all blocks" is a EXOS module, started 16 bytes header with 01h type byte, after all blocks saved: first 16 bit block number, then the 1024 ASCII characters.
One trick how to easy transfer examples from the net to IS-FORTH: Copy+Paste to text file, then save as 1.4TH
Then 1 LOAD. *** End of file error displayed (because it is shorter than 1024 bytes), but don't care with them, the text is in the buffer, can be edited, or with the next 1 LOAD compile it.
But not with ep128emu! :ds_icon_frown:Only with FileIO config. (Becuse it is not a random access file handler, just Load/Save as the tape. Then not set the "Default device is file handler" flag to the EXOS.)
I think right the BUFFERS OFF mode are the native FORTH mode, the other is developed only for the Enterprise without disks?Yes, exactly right!
The original FORTH systems have less memory but disks as fast storage. The Enterprise has a lot of memory, then possible simulate the fast storage without disk, this is the BUFFERS ON mode?
In BUFFERS OFF mode with disks also can be used the lot of memory for caching the blocks avoid the disk access?
And for example if written a 80K program then it can be run fully in memory in EP128? But also run on EP64 with EXDOS, just sometimes disk access needed for changing the block in the memory?
How is possible character <-> character code conversion in FORTH?For converting from a character to a number, ASCII is what you want - it reads the very next character and leaves its ASCII value on the stack. Thus:
Example in BASIC: CHR$(65) or ORD("A")
(For only printing the EMIT do the code->chr conversion.)
How can I "print" (well, dump) the (output of) vlist into a file (eg using FILEIO with ep128emu), so I can examine it later outside of IS-FORTH too?Probably the easiest way is with EXOS channels:
Btw, did you know, that an about Sinclair ZX81 class of machine - the Jupiter ACE, released in 1982 - used forth as the "default language" (unlike most of other 8 bit computers using BASIC)?
" A:\VLIST" 10 OPENOUT | creates the file on channel 10 |
10 #EDITOR | sets the channel used for the editor (ie. VLIST's output) to the file on channel 10 |
VLIST | lists all the words to the editor channel, ie your new file |
100 #EDITOR | sets the editor channel back to the default of 100 |
10 CLOSE | closes the new channel and your file |
I have written a version of the zzzip speed test in FORTH. It does exactly the same thing - gets a screen memory pointer from EXOS and fills the screen with As, then Bs, ... Z.I have just noticed in the IS-FORTH manual there is an even easier way of doing this. VADDR gives you a pointer to the video memory!
...
: GET_SCREEN_MEM ( -- addr )
0 0 3 102 SPFUNC ( Special func Get Video Memory on chan 102 )
0 <> ABORT" SPFUNC ERROR" ( EXOS error )
SWAP DROP ( Do not need value returned in C )
;Quotezozosoft
(And the FORTH have support for the EXOS Special Function call, no machine code needed for ask the video address.)
Is recursion possible in Forth?Yes, being stack based anyway it is quite natural. There is a ‘normal‘ infix (not reverse polish) expression evaluater example in the IS-FORTH manual. [When evaluating eg 3*2+(6-4), when ( is encountered you recurse to evaluate the expression between ( and ).]
Yes I find FORTH a fascinating language & operating system, completely different from anything else. Very simple yet very powerful and without the bloat and fat that comes with modern OSs.I must agree with these, even with the fact that I know _some_ forth only since a day or so :)
As far as I know IS-FORTH is forth-83 (it was supposed to be!) but it is possible I missed something. I am not sure about WORDS - I thought that came later but I might be wrong. Of course you can always enterHehe, cool, WORDS defined as VLIST :)
: WORDS VLIST ; :)
There is no SEE in IS-FORTH. I have often wondered if it would be possible to "disassemble" a forth word but I didn't realise someone had actually done it! I will think about that one and see if I can come up with anything. Yes it has a built-in assembler but that too is reverse polish eg DE PUSH - RTFM! - but I acknowledge TFM is not always as clear or in deapth as it could be :oops:
Another questions are about the on-disk file format (the basics told by Zozo btw): before every 1024 buffer there are two bytes.You ask the type-1 EXOS module? I think the right name for this "on-tape" format.
The first - it seems - is the "buffer sequence number" starting to be counted fromLater I found: the buffer number is on 16 bits! Valid from 1 to 32767.
Later I found: the buffer number is on 16 bits! Valid from 1 to 32767.Nice spot, I had some feeling before it can be the case somehow :) Btw, then in the EXOS header too, the byte after type type byte telling the number of buffers should be interpreted as word, eg the next byte then is the high-byte of the buffer counter? If it's not true, the format would be limited to have max of 255 buffers only ... However as every buffer is 1K, I guess it can be enough, as files with more buffers would be longer than 255K which is not so practical on an averge Enteprise system (unless IS-FORTH can load only a given buffer, and not the whole file, of course).
The sequence is "random", last edited first, see this example:
If it's not true, the format would be limited to have max of 255 buffers only ... However as every buffer is 1K, I guess it can be enough, as files with more buffers would be longer than 255K which is not so practical on an averge Enteprise systemFrom the manual: at the start 8 buffers used. Can be added more with the CREATE-BUFFERS which is allocating full segment for more 16 buffers. It is can be used 16 times, then the total buffers is 8+16*16=264.
From the manual: at the start 8 buffers used. Can be added more with the CREATE-BUFFERS which is allocating full segment for more 16 buffers. It is can be used 16 times, then the total buffers is 8+16*16=264.Ok, but 264 cannot fit within a single byte, so the EXOS header should contain not only a byte for describing the number of forth buffers, if I am correct. That's why I thought the byte in the EXOS header after the type byte is not enough, and maybe the byte after it (which is usually zero) is the high byte of the word sized buffer counter for real. But I should create a file with more than 255 (and less than 264, if you are right?) buffers in it :) Honestly, I feel lost a bit with forth, especially with the storage methods. As far as I can understand the "difficulties" is because forth is old and run on systems without "real" OS (other than forth) having only block I/O without real filesystem etc ...
Was it a performance reason? Eg, was it faster to implement common numbers like 0 or 3 as forth words, and leaving other numbers as-is?Yes, spot on - you have discovered a little secret! (Actually, not so secret - they are in the manual). Not a major performance increase but slightly quicker nonetheless. I think it's worth it for 0 and 1 which occur in programs very commonly; I'm not so convinced by 2 and 3!
Honestly, I feel lost a bit with forth, especially with the storage methods. As far as I can understand the "difficulties" is because forth is old and run on systems without "real" OS (other than forth) having only block I/O without real filesystem etc ...Yes, FORTH can sit rather uncomfortably on other OSs, particularly with file I/O, and especially with tape storage! I was reading the word list of a modern FORTH the other day and it included a set of words very similar to C's fopen(), fread() etc.. Of course of the Enterprise you can use EXOS :)
From the manual: at the start 8 buffers used. Can be added more with the CREATE-BUFFERS which is allocating full segment for more 16 buffers. It is can be used 16 times, then the total buffers is 8+16*16=264.Trust you to try that zozo!! ;-) :oops: I was not able to test that 30 years ago - that much memory was just a distant dream! This system of saving the buffers to a file was really a way of getting around the lack of disks which standard FORTH relies on (it is my invention, not standard). In my defence nobody would want to save 264k to a tape file :smt015 If you were writing a serious program on a real Enterprise with disks you would not use this method at all - you would use the random access .4th files to hold your FORTH blocks.
But now I tried and after 13 CREATEs it is frozen (http://enterpriseforever.com/Smileys/phpbb/ds_icon_redface.gif)
There is a Turbo Pack Tape (http://ep128.hu/Ep_Util/TPT.htm) extension which compresses the saved bytes on the fly :-) (and higher baud rate also can be used)
One point I have just noticed is that trailing spaces are not removed; thus even the smallest program takes up 1k :oops: and if you have 16 small program fragments each in their own block it will take up 16k :oops::oops::oops::oops::oops::oops::oops::oops::oops::oops::oops::oops::oops::oops::oops::oops: which is not good on tape systems that this is aimed at!
Yes, spot on - you have discovered a little secret! (Actually, not so secret - they are in the manual). Not a major performance increase but slightly quicker nonetheless. I think it's worth it for 0 and 1 which occur in programs very commonly; I'm not so convinced by 2 and 3!I've just checked the output of vlist out again. It seems there are four words defined whose names are consist of only numbers: 0, 1, 2 and 3. Interesting to have defined words for 2 and 3 too, if it's not worth as much as for 0, 1 because then some may think that eg 4 and 5 should be handled this way as well :)
...some may think that eg 4 and 5 should be handled this way as well :)It's FORTH so they can if they want to :smt003 (will require use of assembler if it is to be exactly the same)
It's FORTH so they can if they want to :smt003 (will require use of assembler if it is to be exactly the same)So before someone asks:
ExcaliburGER's machine at the Classic Computing exhibition :-)
(Attachment Link)
BUFFERS ON " DORECO.4TH" NAME
LOAD-BUFFERS
1 LOAD 2 LOAD 3 LOAD
DOINT
FIB2-BENCH
GCD1-BENCH
( Drawing Sierpinsky triangle )
: TRIANGLE ( X Y L S -- )
2SWAP 2DUP MOVE ( STARTPOINT )
2SWAP SWAP DUP
0 > IF
SWAP 2SWAP 2DUP
4 PICK + DRAW
2DUP SWAP 4 PICK + SWAP DRAW
2DUP DRAW 2SWAP
2 / SWAP 1 - SWAP
( SHOULD BE X Y L-1 S/2 )
3 PICK 3 PICK 3 PICK 3 PICK
RECURSE
3 PICK 1 PICK + 3 PICK 3 PICK 3 PICK
RECURSE
3 PICK 3 PICK 2 PICK + 3 PICK 3 PICK
RECURSE
2SWAP SWAP
THEN
2DROP 2DROP ;
BUFFERS ON " triangle.4th" NAME
LOAD-BUFFERS 1 LOAD
-- Switch to HIRES graphic mode
4 HIRES
-- to run it after loading
0 0 6 700 TRIANGLE
4 HIRES
-- after that - only 4 lines at the bottom for input
0 0 6 700 TRIANGLE
Hope it helps
How to compile FORTH program? So make it executable?Hi, I try to answer your question from my basic FORTH understanding at all. Most of the FORTH systems can't make an executable out of a given source code, because they need their inner core. Maybe there is a way to do this in IS-FORTH, but I haven't found anything about it in the manual yet.
Hello Hexcaliburger.
I have tried to load the file, but Forth doesn't find it. What is your configuration?