FIF. Another FORTH.

Discussion about ZX80 / ZX81 Software
roganjosh
Posts: 88
Joined: Thu Jun 14, 2018 12:59 pm

Re: FIF. Another FORTH.

Post by roganjosh »

OK. thanks Kelly. As neither me nor the hound have strong opinions either way I'll leave the "n\nd ... nd" definition as it always was. I've uploaded a new version (0.09) which contains DPL. Note that DPL will always return -1 if invoked after the line input buffer has been emptied as there is always an attempted (and failed) numeric conversion at that point. So,

Code: Select all

123.4567 DPL @ . D.
will return "4 1234567"

Code: Select all

123.4567
DPL @ .
will return "-1" (and leave 1234567 on the stack of course).

Alan

Edit: Corrected examples above.
Last edited by roganjosh on Fri May 07, 2021 10:09 am, edited 3 times in total.
Moggy
Posts: 2445
Joined: Wed Jun 18, 2008 2:00 pm

Re: FIF. Another FORTH.

Post by Moggy »

SIGN seems to be missing completely from latest version or am I missing something after too much Tramadol?

Defined SIGN as per the book and tried the books formatting example using DPL but got nonsense
and when I try your example of 123.4567 DPL . I get 17416?!


123.4567 DPL @ D.
will return "4 1234567 In my case returns 262162

This is too much for my small brain to master so I think I will bow out at this point as I may only add confusion to the proceedings.
roganjosh
Posts: 88
Joined: Thu Jun 14, 2018 12:59 pm

Re: FIF. Another FORTH.

Post by roganjosh »

Oops, sorry about that. I've corrected the examples. DPL is a variable so its value is printed just like any other i.e. "@ ."
SIGN didn't survive a preliminary name change that was added in the middle of the discussions yesterday - it's now called SIGN again. A new download is available.

Alan
Moggy
Posts: 2445
Joined: Wed Jun 18, 2008 2:00 pm

Re: FIF. Another FORTH.

Post by Moggy »

Must have been all the medication I've been on as I have now got DPL to work as required and most excellent it is too. :D

Basically It's needed in a definition that correctly scales individually numbers entered on the stack rather than the fixed scaling used in formatted numbers and also allows mixed precision that formatting forbids.

EXAMPLE.

1.23

3.0

10

1.1234

If these numbers were to be summed then printed say using a two place format then each one would need to be entered with two places after the point and the single precision number ,10, wouldn't be allowed at all. A clever routine in Winfields book uses the variable DPL as mentioned earlier to correctly scale and allow mixed precision numbers with mixed places after the point. I would add it also tells you if a given number takes the scaling out of range.

This time it works and I can only blame my own kluztiness or drugs for yesterdays apathy! :oops:

Now if only I could learn to write it to a screen and save it that would be progress however I'm finding all this screen and block saving editor gubbins a bit of a dark art. :oops: :oops:

Still small steps as they say.
roganjosh
Posts: 88
Joined: Thu Jun 14, 2018 12:59 pm

Re: FIF. Another FORTH.

Post by roganjosh »

Sorry to hear about the the pill chomping. Does it lead to a more mellow
approach to coding, leaving the rest of us to resort to shouting at the screen as
usual? If not then the following simple editing example may help. If
you find any errors in it I'll update this post).

The thing to remember when writing a screen is that the editor will always
use the most recently LISTed screen. To use your ROOT word as an example,
here's how it might have been entered.

1) First load the editor

Code: Select all

3 LOAD
2) Make sure you're using the editor vocabulary (you will be if you've
just loaded it)

Code: Select all

EDITOR
3) Select your screen (I'm assuming you want decimal 18)

Code: Select all

18 LIST
I'm also assuming that it's empty (you can make it so using CLRSCR if you want)

4) Now type in your FORTH (assuming UDG), leaving two spaces after each P.

Code: Select all

0 P  ( SAMPLE EDIT SESSION)
2 P  : ROOT 1000000. D* SQRT
4 P  SWAP 3PAP CR CR ;
5) If you've no more screens to edit then save the above using

Code: Select all

SAVE-BUFFERS
That's all there is to it. You can then distribute your screen 18 by posting the
SCR12.F file (the file numbering is in hex).

The line numbering above leaves a space between each line as it's easier to
correct errors during development. Also remember you can type 18 LIST at any
time to review your progress and then continue editing.

There are only three gotchas that I can think of:

a) To stop the text at the end of one line merging with the start of another
it is traditional to use two spaces after the P.
b) Remember you're in editor mode and that there is an editor command called I. So
if your word contains the DO LOOP counter I then switch to the FORTH
vocabulary before testing it.
c) If you enter a line that is too long then it'll be discarded rather than
corrupting the next line.

Alan
Moggy
Posts: 2445
Joined: Wed Jun 18, 2008 2:00 pm

Re: FIF. Another FORTH.

Post by Moggy »

The pill gobbling is down to severe pancreatitis and whilst at first things are mellow it quickly turns into confusion followed by the famous Tramadol headache.

To be honest the pursuit and getting to grips with Forth is about the only thing getting me through the day, albeit through a miasma of head funk. :? :?

Many thanks for the editor tips Alan will pluck up courage to give it a whirl tonight. :D







Moggy.
roganjosh
Posts: 88
Joined: Thu Jun 14, 2018 12:59 pm

Re: FIF. Another FORTH.

Post by roganjosh »

Very nasty. At least Forth is a spoonful of sugar. Speedy recovery.

Alan
Moggy
Posts: 2445
Joined: Wed Jun 18, 2008 2:00 pm

Re: FIF. Another FORTH.

Post by Moggy »

Many thanks for your kind words Alan much appreciated. :D

Now the Forth bit!

Took me a while and many crashes later ( I blame the meds) I finally got the feel of it and compiled, saved and loaded a few screens.

Having come from Toddy Forth with its remarkably easy save and load functions it seemed odd to have do it like way back when, that is to say create screen save screen then when needed load and compile screen.

As well as stretching the old grey matter having to work it all out ,it seems to my mind at least to have that old fashioned feel to it which I find quite satisfying when I get it to run just so.

More germane to FIF81 though is that every example I have tried up press from Winfield's book works as is and the DPL feature I have now compiled a screen for, as this is very useful to myself arithmetically speaking as that is where my interest lies rather than games and in this respect the 81 is quite a capable little device as far as 8 bitters go and combined with Forth it is a reasonably capable 32 and, with a small stretch, 64 bit device too.

Some 80's benchmarks on Z80 4Mhz and 6502 computers running various 80's Forths, that I came across, were equalled and in some cases beaten speed wise when I ran them using Toddy Forth on the ZX81. These machines where the standard for maths and scientific use at the time I believe so life in the old black dog still! :lol:

Thanks from a very grateful Moggy.

(Now where did I put my tablets?)
roganjosh
Posts: 88
Joined: Thu Jun 14, 2018 12:59 pm

Re: FIF. Another FORTH.

Post by roganjosh »

Chortle.

Thanks very much Moggy. Your testing has been appreciated no end. Like I've said, I haven't looked at Toddy Forth yet. I certainly veer more towards the traditional when writing for retro machines - I get the greatest satisfaction doing so (I particularly enjoyed getting it working with cassettes). It's excellent though that there are different design philosophies out there to cater for different kinds of uses.

Yep, the Z80 & 6502 can still hold their own for many tasks and achieve some surprising results. I only discovered recently that the Z80 has a 4-bit ALU (I'd always assumed 8), which makes its design even more impressive.

I'll do some more tidying of FIF and then release it as V1.00 . Concomitantly I'll be thinking more about the Chroma 81 support in FIF.

Alan
Moggy
Posts: 2445
Joined: Wed Jun 18, 2008 2:00 pm

Re: FIF. Another FORTH.

Post by Moggy »

Rest assured when the final version is released it will be firmly ensconced in my Zeddy Forth toolbox.

As for the 4 bit ALU I find Ken Shirriff's blogs on the Z80 informative, the ALU bit can be found here if you haven't seen it already.

http://www.righto.com/2013/09/the-z-80- ... ow-it.html


This one concerning register implementation is also very interesting.

http://www.righto.com/2014/10/how-z80s- ... -down.html
Post Reply