FORTH for the SHARP PC-E500 (S)
11-13-2021, 07:19 PM (This post was last modified: 11-17-2021 09:09 PM by robve.)
Post: #56
 robve Senior Member Posts: 314 Joined: Sep 2020
RE: FORTH for the SHARP PC-E500 (S)
(11-13-2021 12:07 PM)Klaus Overhage Wrote:  I was curious whether the test suite works with Forth500. (https://forth-standard.org/standard/testsuite)
And the answer is yes, absolutely no problem.
[...]
The result is the DATE.FTH file in the attached zip archive. At the end of DATE.FTH there are two examples:
Code:
    2021 12 25 ymd2day 2dup day2dow weekday CR     2021 11 13 ymd2day D- D.
Saturday
42
The first day of Christmas is a Saturday and there are still 42 days until then.

Thanks for testing Forth500 and for providing a very useful example.

I've added DATE.FTH to the Forth500 additions on GitHub. I also added a new SEE.FTH decompiler and a Galton board demo GALTON.FTH. I plan to add more examples. Contributions to Forth500 are more than welcome

With the new CLOAD Forth500 command, I can load any Forth program without a problem with the CE-126P, not needing a serial cable to do so. Using option -dINV with PocketTools bin2wav fixed my wav transfer issues as suggested by Torsten Mücker, the PocketTools maintainer (I had helped him update PocketTools for the PC-E500 with new C code so that E500 BASIC images are fully compiled now with bas2img.) With -dINV I've not had a single transfer error. However, transfer over serial is nicer, because loading and compiling happen simultaneously. And serial is bidirectional. I'm waiting for a serial cable to arrive from Takamatsu Japan. They also offer 256KB FRAM cards for the PC-E500(S).

I made a small change to DATE.FTH. I noticed that you defined RDROP but R>DROP is already included in Forth500. Either one is not standardized, so some Forth's use RDROP and other use R>DROP. Either one makes logically sense: R>DROP means R> DROP and RDROP simply means to drop from the R stack. So use R>DROP instead of RDROP in Forth500. Also please note that I've included extra words <> and > for all numeric versions (<> > D<> D> 0<> 0> D0<> D0> F<> F> F0<> F0>) for consistency. Also note that <= and >= are not part of the standard either, but these can be easily defined using INVERT and the Forth500 < and > words that already exist:

Code:
: <=    > INVERT ; : >=    < INVERT ; : 0<=   0> INVERT ; : 0>=   0< INVERT ; : D<=   D> INVERT ; : D>=   D< INVERT ; : D0<=  D0> INVERT ; : D0>=  D0< INVERT ; : F<=   F> INVERT ; : F>=   F< INVERT ; : F0<=  F0> INVERT ; : F0>=  F0< INVERT ;

If you want to get the best performance by inlining this code, then define them IMMEDIATE with POSTPONEd words:

Code:
: <=    POSTPONE > POSTPONE INVERT ; IMMEDIATE : >=    POSTPONE < POSTPONE INVERT ; IMMEDIATE

However, these words can now only be used in definitions (i.e. when compiling) and not interpreted and executed on the command line unless their definitions include a branch to execute code when in interpreting.

Alas, Forth in general has no INLINE modifier (I think I can do that in Forth500 as its updated design allows something like that actually), but the result with IMMEDIATE and POSTPONE is the same, just a lot more code to write when the definition is long. But inlining long definitions won't keep compiled Forth compact. Inlining only two words like the ones above is useful though if you're keen to use these words instead of just writing > INVERT etc.

- Rob

"I count on old friends" -- HP 71B,Prime|Ti VOY200,Nspire CXII CAS|Casio fx-CG50...|Sharp PC-G850,E500,2500,1500,14xx,13xx,12xx...
 « Next Oldest | Next Newest »

 Messages In This Thread FORTH for the SHARP PC-E500 (S) - Helix - 09-06-2021, 11:41 PM RE: FORTH for the SHARP PC-E500 (S) - robve - 09-12-2021, 02:00 AM RE: FORTH for the SHARP PC-E500 (S) - Helix - 09-12-2021, 11:40 PM RE: FORTH for the SHARP PC-E500 (S) - robve - 09-13-2021, 01:12 AM RE: FORTH for the SHARP PC-E500 (S) - xerxes - 09-15-2021, 11:51 PM RE: FORTH for the SHARP PC-E500 (S) - robve - 11-08-2021, 04:22 AM RE: FORTH for the SHARP PC-E500 (S) - xerxes - 11-09-2021, 10:59 PM RE: FORTH for the SHARP PC-E500 (S) - dmh - 10-02-2022, 02:29 PM RE: FORTH for the SHARP PC-E500 (S) - xerxes - 10-04-2022, 12:02 AM RE: FORTH for the SHARP PC-E500 (S) - dmh - 10-04-2022, 12:46 PM RE: FORTH for the SHARP PC-E500 (S) - xerxes - 10-04-2022, 10:39 PM RE: FORTH for the SHARP PC-E500 (S) - dmh - 10-04-2022, 10:55 PM RE: FORTH for the SHARP PC-E500 (S) - Helix - 09-16-2021, 12:47 PM RE: FORTH for the SHARP PC-E500 (S) - robve - 09-16-2021, 05:06 PM RE: FORTH for the SHARP PC-E500 (S) - Helix - 09-17-2021, 08:45 PM RE: FORTH for the SHARP PC-E500 (S) - toml_12953 - 09-17-2021, 09:25 PM RE: FORTH for the SHARP PC-E500 (S) - Helix - 09-22-2021, 10:55 AM RE: FORTH for the SHARP PC-E500 (S) - robve - 09-21-2021, 06:12 PM RE: FORTH for the SHARP PC-E500 (S) - robve - 09-19-2021, 07:14 PM RE: FORTH for the SHARP PC-E500 (S) - Helix - 09-28-2021, 03:28 PM RE: FORTH for the SHARP PC-E500 (S) - robve - 09-28-2021, 09:03 PM RE: FORTH for the SHARP PC-E500 (S) - Helix - 09-29-2021, 09:23 PM RE: FORTH for the SHARP PC-E500 (S) - robve - 09-29-2021, 10:27 PM RE: FORTH for the SHARP PC-E500 (S) - Helix - 09-30-2021, 09:42 PM RE: FORTH for the SHARP PC-E500 (S) - Klaus Overhage - 10-04-2021, 06:43 AM RE: FORTH for the SHARP PC-E500 (S) - Helix - 10-05-2021, 12:28 AM RE: FORTH for the SHARP PC-E500 (S) - Klaus Overhage - 10-05-2021, 01:02 PM RE: FORTH for the SHARP PC-E500 (S) - robve - 10-06-2021, 02:41 PM RE: FORTH for the SHARP PC-E500 (S) - Helix - 10-06-2021, 11:35 PM RE: FORTH for the SHARP PC-E500 (S) - robve - 10-07-2021, 05:55 PM RE: FORTH for the SHARP PC-E500 (S) - Helix - 10-07-2021, 11:48 PM RE: FORTH for the SHARP PC-E500 (S) - robve - 10-08-2021, 01:04 PM RE: FORTH for the SHARP PC-E500 (S) - robve - 10-10-2021, 01:38 AM RE: FORTH for the SHARP PC-E500 (S) - Klaus Overhage - 10-08-2021, 05:36 PM RE: FORTH for the SHARP PC-E500 (S) - robve - 10-08-2021, 07:16 PM RE: FORTH for the SHARP PC-E500 (S) - Klaus Overhage - 10-10-2021, 09:11 AM RE: FORTH for the SHARP PC-E500 (S) - robve - 10-10-2021, 01:22 PM RE: FORTH for the SHARP PC-E500 (S) - Helix - 10-10-2021, 01:36 PM RE: FORTH for the SHARP PC-E500 (S) - robve - 10-13-2021, 02:38 AM RE: FORTH for the SHARP PC-E500 (S) - Klaus Overhage - 10-26-2021, 05:45 PM RE: FORTH for the SHARP PC-E500 (S) - Helix - 10-29-2021, 11:46 PM RE: FORTH for the SHARP PC-E500 (S) - Klaus Overhage - 10-28-2021, 03:11 PM RE: FORTH for the SHARP PC-E500 (S) - robve - 10-29-2021, 04:03 AM RE: FORTH for the SHARP PC-E500 (S) - Klaus Overhage - 10-30-2021, 07:09 AM RE: FORTH for the SHARP PC-E500 (S) - Helix - 10-30-2021, 09:12 PM RE: FORTH for the SHARP PC-E500 (S) - Klaus Overhage - 10-31-2021, 01:57 PM RE: FORTH for the SHARP PC-E500 (S) - Helix - 11-01-2021, 12:34 AM RE: FORTH for the SHARP PC-E500 (S) - robve - 11-02-2021, 07:58 PM RE: FORTH for the SHARP PC-E500 (S) - Helix - 11-03-2021, 11:58 AM RE: FORTH for the SHARP PC-E500 (S) - Klaus Overhage - 11-04-2021, 05:48 PM RE: FORTH for the SHARP PC-E500 (S) - robve - 11-05-2021, 02:04 PM RE: FORTH for the SHARP PC-E500 (S) - Klaus Overhage - 11-06-2021, 10:40 AM RE: FORTH for the SHARP PC-E500 (S) - robve - 11-06-2021, 07:31 PM RE: FORTH for the SHARP PC-E500 (S) - robve - 11-07-2021, 01:15 AM RE: FORTH for the SHARP PC-E500 (S) - Klaus Overhage - 11-07-2021, 01:00 PM RE: FORTH for the SHARP PC-E500 (S) - robve - 11-07-2021, 03:40 PM RE: FORTH for the SHARP PC-E500 (S) - Klaus Overhage - 11-07-2021, 05:44 PM RE: FORTH for the SHARP PC-E500 (S) - robve - 11-07-2021, 08:19 PM RE: FORTH for the SHARP PC-E500 (S) - Klaus Overhage - 11-09-2021, 08:23 AM RE: FORTH for the SHARP PC-E500 (S) - Klaus Overhage - 11-13-2021, 12:07 PM RE: FORTH for the SHARP PC-E500 (S) - robve - 11-13-2021 07:19 PM RE: FORTH for the SHARP PC-E500 (S) - robve - 11-22-2021, 05:42 PM RE: FORTH for the SHARP PC-E500 (S) - Helix - 11-24-2021, 11:33 PM RE: FORTH for the SHARP PC-E500 (S) - robve - 11-25-2021, 02:54 AM RE: FORTH for the SHARP PC-E500 (S) - Helix - 01-12-2022, 11:06 PM RE: FORTH for the SHARP PC-E500 (S) - robve - 01-13-2022, 03:40 AM RE: FORTH for the SHARP PC-E500 (S) - robve - 01-16-2022, 09:22 PM RE: FORTH for the SHARP PC-E500 (S) - Helix - 01-18-2022, 12:32 AM RE: FORTH for the SHARP PC-E500 (S) - Helix - 02-19-2022, 09:40 PM RE: FORTH for the SHARP PC-E500 (S) - robve - 02-20-2022, 09:13 PM RE: FORTH for the SHARP PC-E500 (S) - Helix - 02-20-2022, 11:12 PM RE: FORTH for the SHARP PC-E500 (S) - robve - 04-03-2022, 12:53 AM RE: FORTH for the SHARP PC-E500 (S) - Helix - 04-03-2022, 11:06 PM RE: FORTH for the SHARP PC-E500 (S) - robve - 04-04-2022, 12:47 AM RE: FORTH for the SHARP PC-E500 (S) - robve - 06-21-2022, 02:16 AM RE: FORTH for the SHARP PC-E500 (S) - F-73P - 06-22-2022, 02:10 AM RE: FORTH for the SHARP PC-E500 (S) - robve - 09-16-2022, 06:54 PM RE: FORTH for the SHARP PC-E500 (S) - Helix - 09-16-2022, 11:09 PM RE: FORTH for the SHARP PC-E500 (S) - robve - 09-17-2022, 12:38 AM RE: FORTH for the SHARP PC-E500 (S) - Helix - 09-17-2022, 10:44 PM RE: FORTH for the SHARP PC-E500 (S) - robve - 09-18-2022, 12:21 AM

User(s) browsing this thread: 1 Guest(s)