SOD64 - a 64bit Stack Oriented Design Processor

I have ported L.C. Benschop's Stack Oriented Design processor (1994)
to iForth, and extended it so that it can generate 64-bit Forths.
SOD is a very elegant design. Its opcodes are 5 bit long, so
12 of them fit in a single 64 bit CELL. Three bits in the CELL
are used to signify RETURN, CALL, LITERAL or packed instructions.
SOD64 needs a virtual machine to run. I have written one in
32bit iForth. This means SOD64 executes on 32bit Linux and Windows.
The image files on both platforms are bit-for-bit the same
(like 4th). You could write an LSE64 in it :-)
As you can see, doubles in SOD64 are 128 bits wide:
-1 -1 1 RSHIFT D. 170141183460469231731687303715884105727 OK
SOD64 can metacompile and extend itself. However, because it
needs a virtual machine, you need a 32bit Forth to host it.
I may feel inspired to port Lennart's C engine over to Linux.
In that case SOD64 would become a standalone 64bit Forth that
can can generate efficient and small (20 K) 64-bit executables.
Windows64 may be a problem though (I don't have that platform).
SOD64 is a quite complete ANS Forth with some good utilities, as
you can see below. There is no floating-point (yet), though.
-marcel
--- ------------------
FORTH> sod64 forth.img
20160 bytes image read
Welcome to Forth
SEE CR
$00000440 $CFE8EF7F 13 1 1 + 32 SPECIAL 10 1 1 + 32 SPECIAL ; OK
SEE WORDS
$000042E8 $A09D3FFF 7192 7256 @ 1 NEGATE + 1 1 + 1 + LSHIFT
$00004300 $000039D1 + @ @
$00004308 $00000031 DUP
$00004310 $0000433A JZ $00004338
$00004318 $00000031 DUP
$00004320 $000042B0 CALL $000042B0
$00004328 $0387413D 8 NEGATE + @ 0
$00004330 $0000430A JZ $00004308
$00004338 $00000029 DROP ; OK
0 100 DUMP
00000000: 00 00 00 00 00 00 3A 88 00 00 00 00 00 00 39 B0 ......:.......9¦
00000010: 00 00 00 00 00 00 00 00 A4 4E 4F 4F 50 00 00 00 ........ñNOOP...
00000020: 80 00 00 00 00 00 00 01 00 00 00 00 00 00 00 18 ................
00000030: A4 53 57 41 50 00 00 00 80 00 00 00 00 00 00 03 ñSWAP...........
00000040: 00 00 00 00 00 00 00 30 A3 52 4F 54 00 00 00 00 .......0úROT....
00000050: 80 00 00 00 00 00 00 05 00 00 00 00 00 00 00 48 ...............H
00000060: A2 30 3D 00 00 00 00 00 80 00 00 00 00 00 00 07 ó0=............. OK
-1 -1 1 RSHIFT D. 170141183460469231731687303715884105727 OK
CR WORDS
SAVE-SYSTEM SEE IDIS DO_SEE seers SDO_SPECIAL SDO_LIT SDO_8 SDO_1 SDO_0 SDO_R>
SDO_R@ SDO_OVER SDO_DUP SDO_!A SDO_C!A SDO_>R SDO_DROP SDO_SCAN1 SDO_+CY
SDO_UM/MOD
SDO_RSHIFT SDO_LSHIFT SDO_< SDO_U< SDO_XOR SDO_OR SDO_AND SDO_+ SDO_@ SDO_C@ SD
O_UM* SDO_NEGATE SDO_0= SDO_ROT SDO_SWAP SDO_NOOP H. ir ip cellmask WORDS ID. .S
DUMP DL VOCABULARY ONLY ROOT-WORDLIST FORTH DEFINITIONS WORDLIST PREVIOUS ALSO
SET-ORDER GET-ORDER PAGE CLS .ELAPSED TIMER-RESET NIP -TRAILING WITHIN BOUNDS
0BODY \ ( IMMEDIATE
POSTPONE ABORT ABORT" S" ." RECURSE +LOOP LOOP RESOLVE-LEAVE LEAVE ?DO DO [CHAR]
CHAR ['] ' POCKET REPEAT WHILE ELSE THEN IF UNTIL BEGIN : (POSTPONE) ; ?CSP !CSP
'LEAVE CSP COMPILE, EXPAND-MACRO LITERAL INSERT-OPCODE CODEFLUSH OPSHIFT OPLOC [
]
STATE CONSTANT VARIABLE CREATE REVEAL HEADER NAME> >NAME ALIGN C, , ALLOT
(ABORT")
NUMBER? CONVERT >NUMBER DIGIT? FIND SEARCH-WORDLIST NAME>BUF CURRENT #ORDER
CONTEXT
LAST FORTH-WORDLIST NAMEBUF WORD PLACE PARSE SKIP SCAN REFILL SOURCE-ID SOURCE
QUERY
EXPECT #SRC SRC SID >IN #TIB SPAN TIB ACCEPT FILE-SIZE SYSTEM FILE-POSITION
REPOSITION-FILE DELETE-FILE READ-FILE WRITE-FILE READ-LINE WRITE-LINE CLOSE-FILE
CREATE-FILE OPEN-FILE OSCALL BIN R/W W/O R/O 2SWAP 2OVER FILL MOVE ROLL CMOVE>
CMOVE
. U. D. #> D */ */MOD * M* FM/MOD SM/REM DABS ABS DNEGATE
MAX
MIN ?DUP 2DROP 2DUP 2! D+ 2@ +! CELL- CELLS CELL+ CHAR- CHARS CHAR+ 2/ 2* INVERT
1- 1+ ON OFF ! C! PICK BL TRUE FALSE (S") (.") ALIGNED TYPE COUNT -1 (+LOOP)
(LOOP)
UNLOOP (LEAVE) J I (?DO) (DO) DEPTH RP! RP@ SP! SP@ R0 S0 CR BYE KEY EMIT U> 0>

0< = - DOVAR LIT 8 1 0 R> R@ OVER DUP !A C!A >R DROP SPECIAL SCAN1 +CY UM/MOD
RSHIFT LSHIFT < U< XOR OR AND + @ C@ UM* NEGATE 0= ROT SWAP NOOP OK
22 33 44 .S 22 33 44 OK
. . . 44 33 22 OK
1 CONSTANT #times OK
#8192 CONSTANT size OK
OK
CREATE flags size ALLOT OK
OK
: DO-PRIME flags size 1 FILL
0 size 0 DO I flags +
C@ IF I 2*
3 +
DUP I +
BEGIN DUP size
U< WHILE 0 OVER flags + C!
OVER +
REPEAT
2DROP 1+
THEN
LOOP ; OK
OK
: PRIMES CR #times . ." iterations." TIMER-RESET
0 #times 0 DO
DROP DO-PRIME
LOOP
CR . ." primes found, " .ELAPSED ; OK
PRIMES
1 iterations.
1899 primes found, 0.035 seconds elapsed. OK
Reply to
Marcel Hendrix
Loading thread data ...
In other words, thanks to Marcel Hendrix et al., expect 64-bit Forth supercomputers for use in AI and robotics.
Meanwhile the AI User Manual is filling up with links catalogued at
formatting link
and embedded in the
formatting link
User Manual (q.v.).
Cheers,
Arthur
Reply to
mentifex

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.