FIF. Another FORTH.

Discussion about ZX80 / ZX81 Software
Moggy
Posts: 3231
Joined: Wed Jun 18, 2008 2:00 pm

Re: FIF. Another FORTH.

Post by Moggy »

A quick example with your new . anywhere version.

(3pap Places after the point)

: 3pap <# # # # 46 hold #S #> TYPE SPACE ;

12345.123 11111.111 D+ 3PAP

23456.234 OK

The new D- operator works likewise so most excellent!
roganjosh
Posts: 100
Joined: Thu Jun 14, 2018 12:59 pm

Re: FIF. Another FORTH.

Post by roganjosh »

Moggy wrote: Sat Mar 27, 2021 11:06 pm The new D- operator works likewise so most excellent!
Great stuff!
I've put yet another version up (but haven't bumped the version as it's just one for testing). As I can't seem to work out (yet) how to use ZXPAND+ from within EightyOne I'd be grateful if, at some stage, you'd try PSAVE under ZXPAND+ again. Theoretically it should now save out a filename called FIF but, as I'm making calls into the ROM, there again it might not. 'Appen I'll try connecting up my real hardware tomorrow and work things out. This project was, after all, supposed to be one way of investigating hardware add-ons.

Ta

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

Re: FIF. Another FORTH.

Post by Moggy »

Personally I avoid Eighty One as I can't put up with its eccentricities,its splendid QL capabilities or it's borked AY, preferring to use SZ81, which just works.

As far as I can tell with Eighty One the ZXpand box should be checked in the hardware menu and all files to be saved/loaded should be in the in the Eighty One folder called sdcard or zxpand sd card or something like that. and anything saved ends up in that folder.

The real Zxpand goes through all the proper motions of saving,LED flashing etc so PSAVE must be invoking the Spand ROM not the 81's ROM. It's just that SZ81 saves the file with using "_" for the name whereas the spand only allows letters and numbers in the file name hence no saved file.

Will try real thing tonight though.
Moggy
Posts: 3231
Joined: Wed Jun 18, 2008 2:00 pm

Re: FIF. Another FORTH.

Post by Moggy »

Couldn't wait.

Tried saving with ZXpand + and an older issue 3

Result is that they both go through the motions of saving but no file saved and both then reset.

SZ81 does save a file called FIF which loads and runs with what ever new words have been added.

I should have mentioned earlier that the SZ81 version I'm using is the non xpand version so will boot up my other pc which has SZ81 with spand compatibility and try that.


EDIT

Tried the SZ81 ZXpand version and like the real thing no file saved,although unlike real kit it doesn't crash.
roganjosh
Posts: 100
Joined: Thu Jun 14, 2018 12:59 pm

Re: FIF. Another FORTH.

Post by roganjosh »

Thanks for your efforts with Spandex. It struck me an hour ago (my brain is now suffering from the lost hour's sleep) that it was never going to work. Great tip about SZ81 though, ta.

It was never the intention for the current version to be run on a ZXpand so I've not until now looked at it. For a start the current code uses a ROM call to do the PSAVE. I haven't seen an annotated disassembly of the ZXPAND ROM but I doubt, even if an equivalent routine exists, that it'll be in precisely the same place. Also, I lifted and modified code from the ZX81 ROM to do the block loading and saving from cassette. Those may well not work on ZXPAND either (and, to maximise free RAM, I was intending not to have cassette support in the ZXPAND version anyway - though I may relent on that).

My next job, therefore, is to produce a ZXPAND version which uses API calls to load/save blocks from/to an SD card.

Incidentally, my confusion over EightyOne last night was that I hadn't realised it was crashing as it dumped me straight into ZXPAND Commander and I was, in vain, looking for a save option. At least I've now read the ZXPAND docs and know what's going on.

Sorry to have caused you a little unnecessary hassle.

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

Re: FIF. Another FORTH.

Post by Moggy »

No hassle at all,Alan.

Not possessing any creative computer skills,I find that the thrill of the chase is in helping those that do have such knowledge so no matter how many dead ends there might be I derive a great deal of satisfaction just in taking part as it were. Voyages of discovery and all that.

What I cannot fathom though is that if the call to save is pointing to the ZX81s ROM routine, then why does the spand go through the flashy-light-looks-like-saving routine instead of the wavy line tape saving jobby?
This would imply that the spand isn't being switched out when the call is made.

Do you invoke FIF81 after doing CONFIG "X" to switch out the spand before hand? If not then I can't see how PSAVE can vector to the 81s ROM save,the flashy flashy LED thing thing seems to point to the spand trying to save not the 81.


For reference I'm not the sharpest knife in the box so indulge me please. :lol:
roganjosh
Posts: 100
Joined: Thu Jun 14, 2018 12:59 pm

Re: FIF. Another FORTH.

Post by roganjosh »

Moggy wrote: Sun Mar 28, 2021 5:32 pm No hassle at all,Alan.

Not possessing any creative computer skills,I find that the thrill of the chase is in helping those that do have such knowledge so no matter how many dead ends there might be I derive a great deal of satisfaction just in taking part as it were. Voyages of discovery and all that.

What I cannot fathom though is that if the call to save is pointing to the ZX81s ROM routine, then why does the spand go through the flashy-light-looks-like-saving routine instead of the wavy line tape saving jobby?
This would imply that the spand isn't being switched out when the call is made.

Do you invoke FIF81 after doing CONFIG "X" to switch out the spand before hand? If not then I can't see how PSAVE can vector to the 81s ROM save,the flashy flashy LED thing thing seems to point to the spand trying to save not the 81.


For reference I'm not the sharpest knife in the box so indulge me please. :lol:

I'm sure you do yourself an injustice. If I do a CONFIG "X" then invoking the PSAVE word behaves as you'd expect i.e. it works. The ZXPAND is behaving much like a normal system with just a RAM pack. If, in that state, you disassemble the code from around $2f6 you see the start of the ZX81 SAVE routine just as you see it on annotated disassemblies on the internet (I used my own disassembler DISACS for that, available for download on this forum). If you do a disassembly without having done a CONFIG "X" then the ZXPAND ROM overlays (replaces) the standard ZX81 ROM and you see that the code from address 0 to $2f6 looks like the ZX81 ROM then, from address $2f6 onwards, the code looks nothing at all like the tape save routine.

However, you don't need the ZX81 ROM switched back in to get a flashing screen. All you need are for some common Z80 CPU IN or OUT instructions to occur. The new code around $2f6 contains a few and pretty soon the new code bangs into what looks like the ZX81 LOAD routine so the INs and OUTs there may be being executed (or the CPU is just jumping somewhere else where there are I/O instructions). In effect the CPU at that point is running non-productive code that just happens to do some I/O as a byproduct and eventually hits some code that causes a more obvious crash. Another more remote possibility might be that, by chance, the spurious code being executed somehow manages to switch the ZX81 ROM back in and also somehow manages to hit part of the original SAVE routine. I haven't looked at how the ROM switching is achieved though.

I don't know whether you get a flashing screen as a matter of course when the ZXPAND SD system is being used (I haven't managed to find the time to try it yet - maybe tomorrow) but if you're saying that a PSAVE causes a display that looks like an SD card load/save then that's likely to be because the new code around $2f6 is where Sir Morris put (part of) his SD card save routine.

Apologies if I've pitched that wrongly. I used to have to give courses on the software I wrote. So did a colleague. My colleague's talks used to make me wince as it sounded to me like he was patronising them. It was dispiriting to often find that the audiences were listening attentively to him but had blank faces when I was talking. I don't miss that part.

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

Re: FIF. Another FORTH.

Post by Moggy »

Thanks for that Alan, what you are saying does indeed make sense and I look forward to future incarnations of this nice little Forth.

Although not strictly Forth79 I have taken a liberty if that is ok and compiled the double operators D- D* and D/

To accompany them I have compiled some number formats for up to 6 places after the point although with the obvious scaling required some care has to be taken with the magnitude of the numbers involved.

I have named them somewhat unimaginatively as 1PAP 2PAP 3PAP 4PAP 5PAP 6PAP
As in 1 Place After Point 2 Place after......

So for example 1.234 1.234 D+ 3pap 2.468

I will remove if not happy.
Attachments
fif.p
(11.07 KiB) Downloaded 103 times
roganjosh
Posts: 100
Joined: Thu Jun 14, 2018 12:59 pm

Re: FIF. Another FORTH.

Post by roganjosh »

I don't mind at all. I'm glad to see it being used.

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

Re: FIF. Another FORTH.

Post by Moggy »

Something generally missing from older forths is a square root function. The FIF81 version attached has a simple SQRT operator which finds integer sqrts for numbers up to 9 digits (within that ranges magnitude) or 3 place decimals for smaller integers <= 4294. This smaller figure is due to the scaling involved and integers > 4924 cause overflow and produce nonsensical answers,which unlike BASIC,Forth has no protection against unless you use an overflow routine created by yourself.

The routine is one written by Klaxon Suralis for Forth Dimension magazine vol 4 issue 1 and adapted slightly by myself as the decimal out put wouldn't work as written and unlike the print version which tops out at roots for integers <= 4095 this version works out roots <= 4294.

EXAMPLES.

For integer roots only enter.

123456789.

SQRT

.

1111 OK







For 3 place decimal roots <= 4294 enter zero,space then the number thus.

0 3.

ROOT


1.732 OK


This version also includes the double number operators posted previously. No doubt there are more elegant solutions but I'm on a very slow learning curve re Forth.
Attachments
sqrt.zip
(6.1 KiB) Downloaded 112 times
Post Reply