Post Reply 
FORTH for the SHARP PC-E500 (S)
01-13-2022, 03:40 AM
Post: #61
RE: FORTH for the SHARP PC-E500 (S)
(01-12-2022 11:06 PM)Helix Wrote:  I'm still learning Forth, following the book Starting Forth 2nd edition. (I know it's outdated, but it's didactic and enjoyable. I have also the Forth Programmer's Handbook for a more modern reference.)

I have a problem with the KEY? word. If no key is pressed, it returns "error -57" instead of 0.
The same problem occurs with EKEY? Furthermore, if a key is pressed, EKEY? returns 255. I think it should be -1.

It is good to hear you are putting Forth500 through its paces Smile

You made a good point. The EKEY? word calls CHAR-READY? but then throws exception -57 if CHAR-READY? returns true. This is a small part of the older pceForth version, which looks wrong to me. The EKEY? Forth standard word requires EKEY? to return true or false.

I will correct this discrepancy soon and release an update.

I may also add a new module LOCALS.FTH that I wrote from scratch to implement the LOCALS word set (I heard that Forth purists turn their nose up to LOCALS, arguing that it is superfluous since everything can be done via the stacks.)

I was tinkering with some code I wrote to add dynamic scoping of arguments and locals to Forth definitions. This turns out to be surprisingly simple to implement in Forth itself, so I wouldn't be surprised if someone hasn't done this already.

- 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...
Visit this user's website Find all posts by this user
Quote this message in a reply
01-16-2022, 09:22 PM
Post: #62
RE: FORTH for the SHARP PC-E500 (S)
Helix,

The EKEY? and KEY? exception problem is fixed. That was annoying. Thanks for reporting. Sorry to have missed that. I try to test Forth500 as much as possible before releasing updates, but there is only so much time one person can put into this.

The Forth500 update includes the following changes:

- updated BREAK key pressing exception to display Break instead of <Error -28

- updated REPRESENT to produce 12 or 13 non-rounded digits for single floating point results instead of 10, which means that single precision arithmetic is practically performed with 12 or even 13 digits without rounding

- updated double floating point computation results to round to 20 digits rather than ignoring the guard digits

- fixed EKEY? issue that affected KEY? as well

- 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...
Visit this user's website Find all posts by this user
Quote this message in a reply
01-18-2022, 12:32 AM
Post: #63
RE: FORTH for the SHARP PC-E500 (S)
Thank you for the update! Now EKEY? works as expected. Smile

Jean-Charles
Find all posts by this user
Quote this message in a reply
02-19-2022, 09:40 PM
Post: #64
RE: FORTH for the SHARP PC-E500 (S)
I think I have found another quirk. Smile
M*/ ignores negative numbers.
For example -1. 1 1 M*/ D. gives 1 instead of -1
Same result with 1. -1 1 M*/

Jean-Charles
Find all posts by this user
Quote this message in a reply
02-20-2022, 09:13 PM
Post: #65
RE: FORTH for the SHARP PC-E500 (S)
(02-19-2022 09:40 PM)Helix Wrote:  I think I have found another quirk. Smile
M*/ ignores negative numbers.
For example -1. 1 1 M*/ D. gives 1 instead of -1
Same result with 1. -1 1 M*/

It's easy to fix and I will update the repo soon. There is an internal RAM register clash that resets the sign bit of the result. This issue should not have happened. I may have overlooked this specific case when testing the latest round of speed optimizations and code size reductions to make the Forth500 system fit in about 20K Big Grin

-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...
Visit this user's website Find all posts by this user
Quote this message in a reply
02-20-2022, 11:12 PM
Post: #66
RE: FORTH for the SHARP PC-E500 (S)
Thanks for the update Wink

Jean-Charles
Find all posts by this user
Quote this message in a reply
04-03-2022, 12:53 AM
Post: #67
RE: FORTH for the SHARP PC-E500 (S)
I haven't had the time to work on a text file editor for Forth500 to edit Forth source code. I usually INCLUDE my programs from COM: or use CLOAD with the CE-126P. Editing text files on the RAM disk can be done with a separate BASIC program called edit500 available at: http://www.andrewwoods3d.com/pce500/

Or you could use my new Forth500 TLOAD command defined below that loads Forth from a TEXT file created in BASIC with the built-in BASIC editor:

Code:
\ TLOAD.FTH load TEXT file with line numbers as Forth source
\ Author: Robert van Engelen
\ TLOAD filename

.( Loading TLOAD...)

ANEW _TLOAD_

DECIMAL

: TLOADED       ( c-addr u -- )
  \ open file and save fileid to the return stack
  R/O OPEN-FILE THROW >R
  \ read header 16 bytes + 0 0 CR bytes
  FIB 19 R@ READ-FILE 0= SWAP 19 = AND
  \ and check if it is a TEXT file header
  FIB 5 S\" \xff\x00\x08\x00\x34" S= AND IF
    BEGIN
      \ while not EOF and line number high byte is not $FF
      R@ READ-CHAR 0= SWAP $FF <> AND WHILE
      \ read and nip line number low byte
      R@ READ-CHAR NIP 0= WHILE
      \ get line len byte
      R@ READ-CHAR 0= WHILE ( -- len1 )
      \ read the len number of bytes into the FIB
      FIB OVER R@ READ-FILE 0= WHILE ( -- len1 len2 )
      \ all bytes read?
      OVER = WHILE ( -- len1 )
      \ evaluate the line read
      FIB SWAP ['] EVALUATE CATCH ?DUP IF
        \ drop string that failed to evaluate, close file and rethrow
        2DROP R> CLOSE-FILE DROP THROW
      THEN
    AGAIN
    ELSE DROP THEN
    ELSE 2DROP THEN
    ELSE DROP THEN
    THEN
    THEN
  ELSE
    ." not TEXT"
  THEN
  \ pop fileid from the return stack and close file
  R> CLOSE-FILE DROP
;

: TLOAD         ( "name" -- ) PARSE-NAME TLOADED ;

This approach is similar to the PC-G850(V)(S) C programming with its built-in line-number-based text editor. It is a bit odd to use line numbers. But hey, this is a throwback to the 80s Smile

How to use TLOAD:

1. in BASIC key in TEXT, the prompt will change to < to indicate the TEXT mode
2. type in your Forth program line-by-line with line numbers
3. use RENUM in case you can't insert a line
4. then SAVE "name" to save your program to RAM disk as name.BAS (don't forget this step!)
5. go back to Forth500 with CALL&B0000 (or CALL&B9000 on a 32K machine)
6. key in TLOAD name.BAS
7. done!

- 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...
Visit this user's website Find all posts by this user
Quote this message in a reply
04-03-2022, 11:06 PM (This post was last modified: 04-03-2022 11:10 PM by Helix.)
Post: #68
RE: FORTH for the SHARP PC-E500 (S)
(04-03-2022 12:53 AM)robve Wrote:  I haven't had the time to work on a text file editor for Forth500 to edit Forth source code. I usually INCLUDE my programs from COM: or use CLOAD with the CE-126P. Editing text files on the RAM disk can be done with a separate BASIC program called edit500 available at: http://www.andrewwoods3d.com/pce500/

Or you could use my new Forth500 TLOAD command defined below that loads Forth from a TEXT file created in BASIC with the built-in BASIC editor:

Thank you for this suggestion and for this clever program. However I'm currently busy with other things, and I will not test them soon.
I've just spent an hour trying the INCLUDE command, that I have never used so far, but for some reason it didn't work. Maybe I'm messing something in the file format, or I've forgotten one important detail, but I give up.
I will certainly return to Forth and to the PC-E500 next winter.

However, if this program works as expected, it should completly satisfy my needs Smile.
So, thank you again!

Jean-Charles
Find all posts by this user
Quote this message in a reply
04-04-2022, 12:47 AM (This post was last modified: 04-12-2022 02:17 AM by robve.)
Post: #69
RE: FORTH for the SHARP PC-E500 (S)
(04-03-2022 11:06 PM)Helix Wrote:  I've just spent an hour trying the INCLUDE command, that I have never used so far, but for some reason it didn't work. Maybe I'm messing something in the file format, or I've forgotten one important detail, but I give up.

Have you tried this? To load from COM:, make sure to set the serial parameters first on the E500 to correspond to the settings of your sending program, which should be done once (and for all) in BASIC with OPEN "baud rate, parity, word length, stop bit, A, C, &H1A, XON" AS #1 then CLOSE #1. The file to send should have an ending &1A (ctrl-Z) end of file.

PS. I should add that commands like INCLUDE open and then close the file, even when an error occurred. However, if files or COM: cannot be opened, then try fileid CLOSE-FILE . for some fileid>0 values to close the file. This closes the file if for some reason it stayed open e.g. after a program aborted due to an error when files are open.

- 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...
Visit this user's website Find all posts by this user
Quote this message in a reply
06-21-2022, 02:16 AM
Post: #70
RE: FORTH for the SHARP PC-E500 (S)
Compute digits of pi.
The following Forth500 program is based on the C code to compute the digits of pi by Dik T. Winter, CWI Amsterdam. It computes up to 9864 digits of pi, but is memory-restricted to about 6000 digits max:
Code:
.( Loading BIG-PI...)

ANEW _BIG_PI_

DECIMAL

0 VALUE b       0 VALUE c
0 VALUE e       0 VALUE g
0. 2VALUE d     

\ array f located at HERE + 40 bytes (hold area)
: f!    CELLS HERE + 40 + ! ;
: f@    CELLS HERE + 40 + @ ;

: big-pi    ( +n -- )
  DUP 4 < ABORT" too small"
  \ c=7*n/2; c-=c%14
  7 UM* D2/ D>S DUP 14 MOD - TO c
  \ check for sufficient space to store array f
  c UNUSED 40 - 1 RSHIFT U> ABORT" out of memory"
  \ f[0...c-1]=2000
  c 0 DO 2000 I f! LOOP
  \ e=0
  0 TO e
  CR
  BEGIN
    \ d=0; g=2*c-1; b=c
    0. TO d
    c 2* 1- TO g
    c TO b
    BEGIN
      \ d+=f[b]*10000; f[b]=d%g; d/=g; g-=2; b--
      b f@ 10000 UM* +TO d
      d g 0 D/MOD
      TO d
      D>S b f!
      -2 +TO g
      -1 +TO b
    b WHILE
      \ d*=b
      d b UMD* TO d
    REPEAT
    \ printf("%.4u",e+d/10000); e=d%10000
    d 10000 SM/REM
    e + 0 <# # # # # #> TYPE
    TO e
    \ c-=14
    -14 +TO c
  c 0= UNTIL
;

A screenful with the first 152 digits of pi (this takes one minute to compute):
Code:
152 big-pi
3141592653589793238462643383279502884197
1693993751058209749445923078164062862089
9862803482534211706798214808651328230664
70938446095505822317253594081284 OK[0]

A C program for the PC-G850(V)(S):
Code:
1 unsigned long a=10000,d;
2 unsigned b,c,e,*f,g;
3 main(){
4  printf("digits?");scanf("%u",&c);
5  c=7*c/2;c-=c%14;f=malloc(4*c+4);
6  for(;b-c;)f[b++]=a/5;
7  for(;d=0,g=c*2;c-=14,printf("%.4lu",e+d/a),e=d%a)
8   for(b=c;d+=f[b]*a,f[b]=d%--g,d/=g--,--b;d*=b);
9 }

The PC-G850VS calculates the first 152 digits of pi in 1 minute and 15 seconds.

This slightly modified version in C with 64 bit integers correctly computes up to 54935 digits of pi:
Code:
uint64_t a=10000,b,c,d,e,*f,g;
main(){printf("digits?");scanf("%llu",&c);c*=3.5;c-=c%14;f=malloc(sizeof(*f)*(c+1));
for(;b-c;)f[b++]=a/5;for(;d=0,g=c*2;c-=14,printf("%.4llu",e+d/a),e=d%a)
for(b=c;d+=f[b]*a,f[b]=d%--g,d/=g--,--b;d*=b);}

The 54936th digit is off by one, followed by 10000 instead of 0000:

362524395716152714669005814610000
___________________________^x____
where a 7 should appear in place of the 6, falling the 1 to carry over to the 6. When pushing for 100000 digits this happens a few more times. I reckon the algorithm can be fixed to perform the carry. But this algorithm is quite slow for long digit sequences. There are also better algorithms, e.g. BBP, Chudnovsky.

- 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...
Visit this user's website Find all posts by this user
Quote this message in a reply
09-16-2022, 06:54 PM
Post: #71
RE: FORTH for the SHARP PC-E500 (S)
Forth500 2.0 released

Forth500 2.0 is a standard Forth system for the Sharp PC-E500(S) with 564 built-in Forth words.

Forth500 2.0 runs up to 20% faster by exploiting faster 16-to-20 bit address conversion via the internal RAM registers of the ESR-L CPU.

The NQUEENS calculator benchmark finishes in 3.47 seconds in Forth500 2.0. It took 4.15 seconds in Forth500 1.0. Tested with a loop of 20 NQUEENS runs.

The speed boost should be noticible to colon definition calls (20% less overhead) and also to all Forth primitives involving single and double integer literals, variables, values, constants, single and double integer store and fetch, single integer arithmetic involving addition and subtraction, and single and double integer stack operations.

Improvements are also made to the Forth500 manual and to the Forth500 implementation overall, including new support for Forth vocabularies (yes, finally...)

Also included in Forth500 2.0 is a new text editor "TED". TED.FTH is located in the Forth500 additions folder. With TED you can interactively write, edit and run Forth code in Forth500:

Code:
TEDI MYWORK.FTH ↲
↲                           \ start editing (press enter)
.( TED is great!) ↲        \ a line of Forth (press enter to save)
[CCE]                       \ end editing and read MYWORK.FTH
TED is great!

Synopsis:
TED             edit the last file edited
TED FILE.FTH    edit FILE.FTH
TEDI            edit the last file edited, then read it into Forth500
TEDI FILE.FTH   edit FILE.FTH, then read it into Forth500

Files are saved to the E: or F: RAM disk. See also the TED editor instructions.

By the way, any suggestions for additions, improvements and issues are of course always welcome.

Enjoy!

- 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...
Visit this user's website Find all posts by this user
Quote this message in a reply
09-16-2022, 11:09 PM
Post: #72
RE: FORTH for the SHARP PC-E500 (S)
I like some of the new additions. Smile
Now that you have vocabulary words, and if you have time to waste, you can write an assembler. Big Grin

Jean-Charles
Find all posts by this user
Quote this message in a reply
09-17-2022, 12:38 AM
Post: #73
RE: FORTH for the SHARP PC-E500 (S)
(09-16-2022 11:09 PM)Helix Wrote:  I like some of the new additions. Smile

Note that there are also a number of new separate Forth500 additions and examples: CALENDAR.FTH (borrowed from Jupiter ACE), HANOI.FTH (a classic, shows deep recursion), HITOMEZA.FTH (patterns), LINES.FTH (a bounding lines screen saver), MORE.FTH (like Unix more command), REDEF.FTH (redefine any Forth word, like the Jupiter ACE REDEFINE word), SAVE.FTH (save Forth500 image with all user code to a file), and TED.FTH. I kept TED small, so loading does not take too much time and the application itself does not require much memory to run. But it pushes memory limits on an unexpanded E500.

(09-16-2022 11:09 PM)Helix Wrote:  Now that you have vocabulary words, and if you have time to waste, you can write an assembler. Big Grin

Give me a day or two Smile

Eager to try ESR-L CPU programming? Try the XASM126 assembler written in Pascal. It's included with Forth500 to build Forth500. Also included are ESR-L and E500 technical manuals. I've translated the Japanese XASM documentation to English for convenience and CPU resources Big Grin

OK, so honestly most of the Forth500 improvements were done during an extended weekend fairly recently to execute my plan I'd talked about before, i.e. to use a different method for the Forth execution token fetch/execute cycle and other internals that require 16-to-20 bit address conversions. But testing and iterating to ensure perfection always takes some days with projects like this, especially since testing is done on the actual machines, before I'm confident to commit the update. This is necessary, because over 900 lines of assembly were changed/removed/added to the 2.0 release. All of this taking only 16 more bytes of the binary, by shuffling things and by reusing code in cases where this wasn't done before.

IMHO the low-power ESR-L CPU ISA is interesting and powerful for an 8 bit CPU with 20 bit address space. OK, it's not a famous Z80 or HP Saturn, but I actually like it better than a Z80 (don't know if anyone can agree or not). Most of the Sharp IQ and OZ Wizards have this CPU on board, no surprise. It runs a 2.3MHz clock. But you have to divide this by 3 since a single CPU instruction cycle takes three clock ticks. So effectively it runs at 768KHz. This makes sense, because a typical instruction fetch-decode-execute takes three ticks and just one cycle on the ESR-L when other CPUs take 3 cycles. Also, most CPU instructions on the ESR-L take only a few CPU cycles, such as 2, 3 or 4 CPU cycles for 8, 16, 24 bit register moves respectively.

- 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...
Visit this user's website Find all posts by this user
Quote this message in a reply
09-17-2022, 10:44 PM
Post: #74
RE: FORTH for the SHARP PC-E500 (S)
(09-17-2022 12:38 AM)robve Wrote:  Note that there are also a number of new separate Forth500 additions and examples: CALENDAR.FTH (borrowed from Jupiter ACE), HANOI.FTH (a classic, shows deep recursion), HITOMEZA.FTH (patterns), LINES.FTH (a bounding lines screen saver), MORE.FTH (like Unix more command), REDEF.FTH (redefine any Forth word, like the Jupiter ACE REDEFINE word), SAVE.FTH (save Forth500 image with all user code to a file), and TED.FTH. I kept TED small, so loading does not take too much time and the application itself does not require much memory to run. But it pushes memory limits on an unexpanded E500.

I've noticed them Wink

(09-17-2022 12:38 AM)robve Wrote:  Eager to try ESR-L CPU programming? Try the XASM126 assembler written in Pascal. It's included with Forth500 to build Forth500. Also included are ESR-L and E500 technical manuals. I've translated the Japanese XASM documentation to English for convenience and CPU resources Big Grin

This is something I will investigate later. I still have to finish learning Forth, especially all the features of Forth500, and I have a lot to explore with all your examples.

The only CPU I know is the SC61860, because I learned the machine language of my Sharp PC-1401. But I've forgotten everything since that time!
Do you know if there is a common CPU that is comparable to the ESR-L, if my question makes sense?

Jean-Charles
Find all posts by this user
Quote this message in a reply
09-18-2022, 12:21 AM (This post was last modified: 10-06-2022 03:40 PM by robve.)
Post: #75
RE: FORTH for the SHARP PC-E500 (S)
(09-17-2022 10:44 PM)Helix Wrote:  The only CPU I know is the SC61860, because I learned the machine language of my Sharp PC-1401. But I've forgotten everything since that time!
Do you know if there is a common CPU that is comparable to the ESR-L, if my question makes sense?

I tend to think of the ESR-L as a mix of Z80, 6809 and SC61860 (ESR-H or "old-SC") flavors. The German Systemhandbuch section 12 on the CPU gives a good technical overview, albeit in German. There are also suggestions on how to reserve space for machine code and there is info on the PC-E500 internals. For the FCS and IOCS system calls, see the PC-E500 technical manual. Both texts are included as PDFs in the Forth500 resources. There is also a ESR L CPU technical manual.

The ESR-L machine code prefix bytes are the odd ones for this CPU. A prefix byte applies to internal RAM registers. The internal RAM acts like a large register window with base pointer BP. It allows for a clever way to run routines that have their private internal RAM by shifting the window. For example, BASIC uses an internal RAM window. Forth500 too, but using a different location of the window. This is done with "prefix bytes" added to CPU instructions to address internal RAM. Without a prefix byte, an internal RAM register (a location) is always relative to the BP. So internal register (ex) for example is really (BP+ex) when prefix bytes are turned off with pre_off. A prefix byte must be used for absolute RAM register addressing like (ex) but with prefix bytes on with pre_on, which is required with the operating system FCS and IOCS calls. A prefix byte can also be used to address internal RAM registers relative to the PX index register, either (PX+n) or (BP+PX). I've only used (BP+PX) for the floating point routines, to index BCD digits stored in internal RAM. Note that internal RAM memory is written (n) with location n (could be BP+n), whereas external RAM is written [nm] for 16 bits nm or written [lmn] for 20 bits lmn. Registers are one byte (A, B, IL), two bytes (BA, I) or three bytes (memory/index registers X, Y and stack pointers U, S like the 6809). Internal RAM can contain integers of one, two or three bytes. Register BA combines A (lo) and B (hi). I combines IH and IL. Assigning to IL makes IH zero (IH is not directly addressable). That's often very handy, as it results in shorter and slightly faster code. There are RAM memory block moves MVL with IL number of bytes moved. Internal RAM block binary addition ADCL and subtraction SBCL instructions and BCD DADL and DSBL. Except for those specialized cases, most ESR-L instructions should be easy to get familiar with. Perhaps take a look at the Forth500.s assembly? It's all explained and annotated.

- Rob

EDIT: mention PC-E500 technical manual.

"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...
Visit this user's website Find all posts by this user
Quote this message in a reply
10-02-2022, 02:29 PM
Post: #76
RE: FORTH for the SHARP PC-E500 (S)
Can this article still be updated as it looks to be in an older format?

If so, can you please also add my 50G version (posted in the general forum here).

TIA, dmh

(09-15-2021 11:51 PM)xerxes Wrote:  
(09-12-2021 02:00 AM)robve Wrote:  - improved execution speed and reduced code size

I'm really impressed. I no longer expected the project to be completed.
Would be nice to have Forth500 in the n-queens benchmark list too.

The already tested Forth implementations on pocket computers:
Code:

 55.0    HP-71B         Forth / Forth/Assembler ROM Module HP-82441A / Ver.1A
 45.1    HP-71B         Forth / HP-41 Translator ROM Module HP-82490A / Ver.2A
 31.7    PB-1000        PB-Forth
 23.5    RL-H1800       Snap Forth ROM Module
 20.0    HP-75C         Forth

Calculator Clique on YouTube
Visit this user's website Find all posts by this user
Quote this message in a reply
10-04-2022, 12:02 AM
Post: #77
RE: FORTH for the SHARP PC-E500 (S)
(10-02-2022 02:29 PM)dmh Wrote:  Can this article still be updated as it looks to be in an older format?

If so, can you please also add my 50G version (posted in the general forum

Yes, it's still possible to update the old format list. Can you please let me know, which version of Forth do you have ported?

Calculator Benchmark
Find all posts by this user
Quote this message in a reply
10-04-2022, 12:46 PM
Post: #78
RE: FORTH for the SHARP PC-E500 (S)
It's a C version based on Richard W.M. Jones' Jonesforth and then ported to the 50G using HP GCC 2.0.

(10-04-2022 12:02 AM)xerxes Wrote:  
(10-02-2022 02:29 PM)dmh Wrote:  Can this article still be updated as it looks to be in an older format?

If so, can you please also add my 50G version (posted in the general forum

Yes, it's still possible to update the old format list. Can you please let me know, which version of Forth do you have ported?

Calculator Clique on YouTube
Visit this user's website Find all posts by this user
Quote this message in a reply
10-04-2022, 10:39 PM
Post: #79
RE: FORTH for the SHARP PC-E500 (S)
(10-04-2022 12:46 PM)dmh Wrote:  It's a C version based on Richard W.M. Jones' Jonesforth and then ported to the 50G using HP GCC 2.0.

Thank you. I've updated the list.

Calculator Benchmark
Find all posts by this user
Quote this message in a reply
10-04-2022, 10:55 PM
Post: #80
RE: FORTH for the SHARP PC-E500 (S)
Great, thanks :-)

Note, the FORTH code for the 50G is different. I have included below in case you want to list it.

Code:
8 CONSTANT RR
 VARIABLE II VARIABLE SS VARIABLE XX VARIABLE YY
 HERE @ RR 2+ ALLOT CONSTANT AA

 : RCLAA @ AA + C@ ;
 : STOAA @ AA + C! ;

 : NQPRINT
  1 II !
  BEGIN II @ XX @ 1+ < WHILE
    II RCLAA .
    1 II +!
  REPEAT ;

 : NQCORE
   0 SS !
   0 XX !
   BEGIN
     1 XX +!
     RR XX STOAA
     BEGIN
       1 SS +!
       XX @ YY !
       BEGIN YY @ 1 > WHILE
         -1 YY +!
         XX RCLAA YY RCLAA - DUP
         0 = SWAP ABS XX @ YY @ - = OR IF
           0 YY !
           BEGIN XX RCLAA 1 - DUP XX STOAA 0 = WHILE
             -1 XX +!
           REPEAT
         THEN
       REPEAT
     YY @ 1 = UNTIL
   RR XX @ = UNTIL
 ;

: NQUEENS
  NQCORE
  NQPRINT
;

(10-04-2022 10:39 PM)xerxes Wrote:  
(10-04-2022 12:46 PM)dmh Wrote:  It's a C version based on Richard W.M. Jones' Jonesforth and then ported to the 50G using HP GCC 2.0.

Thank you. I've updated the list.

Calculator Clique on YouTube
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




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