Post Reply 
DM-FORTH: FORTH implementation for the DM41X
11-30-2023, 10:26 AM (This post was last modified: 11-30-2023 08:59 PM by dmh.)
Post: #5
RE: DM-FORTH: FORTH implementation for the DM41X
You're welcome. I'm enjoying getting FORTH running on more devices and testing N-Queens :-)

I just tested the 50G FORTH code you already have listed on the DM41X and, as expected, it works and is what I used. All I added was a few words to time the runtime.
EDIT: I realised that I added disabling program interrupt checking to make it is fast as possible so here is the code including that with timing removed,

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
  BRKOFF
  NQCORE
  NQPRINT
  BRKON
;

I notice you don't have my PrimeFORTH, written in Python, listed either.

The Prime G2 version runs N-Queens in 2.49 seconds and the code is here:

https://github.com/diemheych/PrimeFORTH/...queens.fth

(11-30-2023 02:46 AM)xerxes Wrote:  
(11-28-2023 02:05 PM)dmh Wrote:  N-Queens for an 8x8 board runs in .27 seconds on USB power which appears to be the fastest version in FORTH when reviewing the current Calculator Benchmark list.

Thank you for the test. Interestingly, it's 9 times faster than the Jonesforth implementation on the 50G.
Can you please post the test code for 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 


Messages In This Thread
RE: DM-FORTH: FORTH implementation for the DM41X - dmh - 11-30-2023 10:26 AM



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