Post Reply 
FORTH for the SHARP PC-E500 (S)
11-08-2021, 04:22 AM
Post: #52
RE: FORTH for the SHARP PC-E500 (S)
(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.

Forth500 n-queens benchmark on the PC-E500S: 4.15s

A little over 4 seconds on a standard PC-E500S machine with no enhancements.

By comparison, BASIC takes 1:19 minute and assembly code is of course the best at 0.114s.

I ran NQUEENS four times to get 16.6s repeatedly with +/- 0.2s deviation in the 16.6s stopwatch timing. The value S=876 is displayed.

The n-queens code in standard Forth using VALUEs instead of VARIABLEs:

Code:
8 CONSTANT RR
0 VALUE SS
0 VALUE XX
0 VALUE YY
CREATE AA RR 1+ ALLOT

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

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

: NQUEENS
  NQCORE
  ." S=" SS .
;

- 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
Post Reply 


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 - 11-08-2021 04:22 AM
RE: FORTH for the SHARP PC-E500 (S) - dmh - 10-02-2022, 02:29 PM
RE: FORTH for the SHARP PC-E500 (S) - dmh - 10-04-2022, 12:46 PM
RE: FORTH for the SHARP PC-E500 (S) - dmh - 10-04-2022, 10:55 PM



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