Welcome, Guest. Please login or register.


Author Topic: FORTH (Read 44939 times)

Offline BruceTanner

  • EP lover
  • *
  • Posts: 607
  • Country: gb
Re: FORTH
« Reply #15 on: 2013.February.26. 15:54:21 »
Quote from: Zozosoft
How can Load/Save programs?
The description of the "NAME" not fully clear for me :oops:
Can you write some examples? (for Tape and Disk)
I was reading the IS-FORTH manual on this and it is very confused!

For historical reasons FORTH does not handle "files" as we know them very well! When it was created on the simple systems of the 1970s, you entered your code in 1k blocks (or screens) of 16 lines x 64 characters (= 1k). So you could go "100 EDIT" or "203 EDIT" etc and the entire block would be displayed on the screen. After editing, you would then go "100 LOAD" and your code would be read in as though you had typed it at the command line. If your code spanned more than one block you put "-->" at the bottom and it would load the next screen, etc. Or you could have a master index block which loaded lots of others. There would be a number of 1k buffers in memory just to prevent excessive (slow) disk access. In typical FORTH style this was very simple and efficient as the 1k FORTH blocks could correspond directly to a group of sectors on the disk!

When it came to using the EXOS editor it was a bit tricky to display the entire block in this way, so you can type any number of lines of any length but each block must still be less than 1k (I think the editor status line displays the number of characters left when you get close).

So when I came to do something with cassette tapes it was a bit tricky! So I decided to have enough buffers to keep all the user's source code in memory at once in the "disk" buffers. Then you type

" filename" NAME    to name your program (the space after the first " is important but not included in the name), and
SAVE-BUFFERS      to save all the buffers as a file, and
LOAD-BUFFERS      to load them again. (I'm not sure off the top of my head if loading them on a freshly-booted system sets the NAME...will have to try it).

Once you have loaded a new set you will still have to LOAD them with 203 LOAD or whatever.

This is what I was using the other day with EPFILEIO and it seemed to work ok. If you don't do the " filename" NAME it prompts you with a Windows window. :)

IS-FORTH is supposed to handle disks too, making up filenames out of the block numbers (and possibly the NAME, & can't remember!) I had a very quick go the other day and nothing seemed to happen, but there was some confusion about where EPFILEIO was putting files (as it turned out, a hidden directory called C:\Users\Bruce\Appdata\Local\VirtualStore\Program Files (x86)\ep128emu\files) so I need to give that another go!

In summary I'd suggest you use EPFILEIO at the moment and I'll try and work out how to make it use disks properly later.
« Last Edit: 2013.February.26. 15:58:15 by BruceTanner »

Offline BruceTanner

  • EP lover
  • *
  • Posts: 607
  • Country: gb
Re: FORTH
« Reply #16 on: 2013.February.26. 16:10:45 »
Having had a quick play I think it will always use the NAME, and if you go eg " A:\TEST" NAME and then SAVE-BUFFERS (or FLUSH) will write out all the buffers in a file on drive A:, so you don't need to reply on EPFILEIO.

I'm not sure where the bit about making up filenames came from...will have to play a bit more. Or maybe that was a scheme I abandoned but got left in the manual!

Offline Zozosoft

  • Global Moderator
  • EP addict
  • *
  • Posts: 14723
  • Country: hu
    • http://enterprise.iko.hu/
Re: FORTH
« Reply #17 on: 2013.February.26. 16:25:34 »
Quote from: BruceTanner
" filename" NAME
This is more simple than the manual say on the page 47 :-)
« Last Edit: 2013.February.26. 16:28:40 by Zozosoft »

Offline Zozosoft

  • Global Moderator
  • EP addict
  • *
  • Posts: 14723
  • Country: hu
    • http://enterprise.iko.hu/
Re: FORTH
« Reply #18 on: 2013.February.26. 16:43:29 »
I played at Tape config then can see in the status line what currently saving.
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.

Offline BruceTanner

  • EP lover
  • *
  • Posts: 607
  • Country: gb
Re: FORTH
« Reply #19 on: 2013.February.26. 17:01:45 »
Quote from: Zozosoft
I played at Tape config then can see in the status line what currently saving.
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.
:smt023 I don't know how you found that! I was wondering how it would know which system to use. :smt017

Offline BruceTanner

  • EP lover
  • *
  • Posts: 607
  • Country: gb
Re: FORTH
« Reply #20 on: 2013.February.26. 17:10:53 »
As well as the book I mentioned before called Starting Forth, there is another good (but more advanced) book by the same author called Thinking Forth. Downloadable as a .pdf from a link on this page http://www.forth.com/forth/forth-books.html (near the bottom right hand corner). Good discussion from p136 onwards about managing the blocks in a largish application!

Offline Zozosoft

  • Global Moderator
  • EP addict
  • *
  • Posts: 14723
  • Country: hu
    • http://enterprise.iko.hu/
Re: FORTH
« Reply #21 on: 2013.February.27. 09:31:28 »
Now I played in EXDOS mode:
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.

Offline BruceTanner

  • EP lover
  • *
  • Posts: 607
  • Country: gb
Re: FORTH
« Reply #22 on: 2013.February.27. 09:53:29 »
:smt023 Good work zozo, you've got that cracked!

I think the intention was that if you have disks, you use BUFFERS OFF mode. If you only have tape you use BUFFERS ON mode and NAME. Shame it did not say that in the manual :oops:!

Offline Zozosoft

  • Global Moderator
  • EP addict
  • *
  • Posts: 14723
  • Country: hu
    • http://enterprise.iko.hu/
Re: FORTH
« Reply #23 on: 2013.February.27. 09:59:27 »
The FORTH detects the EXDOS at the start and switched the BUFFERS OFF (and left ON if there is no EXDOS).
« Last Edit: 2013.February.27. 11:47:06 by szipucsu »

Offline BruceTanner

  • EP lover
  • *
  • Posts: 607
  • Country: gb
Re: FORTH
« Reply #24 on: 2013.February.27. 10:27:16 »
Quote from: Zozosoft
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:

Offline Zozosoft

  • Global Moderator
  • EP addict
  • *
  • Posts: 14723
  • Country: hu
    • http://enterprise.iko.hu/
Re: FORTH
« Reply #25 on: 2013.February.27. 10:28:33 »
I think right the BUFFERS OFF mode are the native FORTH mode, the other is developed only for the Enterprise without disks?
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?
« Last Edit: 2013.February.27. 11:49:54 by szipucsu »

Offline BruceTanner

  • EP lover
  • *
  • Posts: 607
  • Country: gb
Re: FORTH
« Reply #26 on: 2013.February.27. 10:30:21 »
Quote from: Zozosoft
Now I played in EXDOS mode:
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.
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.

Offline Zozosoft

  • Global Moderator
  • EP addict
  • *
  • Posts: 14723
  • Country: hu
    • http://enterprise.iko.hu/
Re: FORTH
« Reply #27 on: 2013.February.27. 11:27:59 »
Quote from: BruceTanner
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.)

Offline BruceTanner

  • EP lover
  • *
  • Posts: 607
  • Country: gb
Re: FORTH
« Reply #28 on: 2013.February.27. 12:17:54 »
Quote from: Zozosoft
I think right the BUFFERS OFF mode are the native FORTH mode, the other is developed only for the Enterprise without disks?
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?
Yes, exactly right!

Offline Zozosoft

  • Global Moderator
  • EP addict
  • *
  • Posts: 14723
  • Country: hu
    • http://enterprise.iko.hu/
Re: FORTH
« Reply #29 on: 2013.March.02. 12:55:57 »
How is possible character <-> character code conversion in FORTH?
Example in BASIC: CHR$(65) or ORD("A")
(For only printing the EMIT do the code->chr conversion.)
« Last Edit: 2013.March.02. 16:23:07 by szipucsu »