FORTH for the PC-G850(V)(S)

Ici, on fait dans le petit, le LCD qui déchire sa race, on y cause même calculatrices quand on est en manque !

Modérateur : Politburo

Répondre
engelen
Fonctionne à 75 bauds
Fonctionne à 75 bauds
Messages : 21
Enregistré le : 01 sept. 2021 21:14
Localisation : New York
Contact :

FORTH for the PC-G850(V)(S)

Message par engelen »

A modern Forth 2012 standard compliant system for the Sharp PC-G850(V)(S) pocket computer.

Image

Download here: https://github.com/Robert-van-Engelen/Forth850

You can extend Forth850 as you wish, including assembly code written on the machine itself in the TEXT editor and assembled with the built-in Z80 Assembler. Forth source code can be written with the built-in TEXT editor to read it back into Forth with the TEXT word.

I've implemented Forth850 as efficiently as possible in direct threaded code (DTC) with brand new Z80 code written from scratch. The Forth850 source code is included and heavily documented.

The n-queens benchmark is solved in 0.865 seconds, the fastest Forth implementation of the benchmarks. Forth850 n-queens runs 5 times faster than the C n-queens benchmark on the PC-G850VS.

Forth850 includes stack under/overflow checks, dictionary overflow checks and can be interrupted by pressing BREAK.

I'll be happy to take requests for new features and include additions, demos and examples.

- Robert
Avatar du membre
Dom
Fonctionne à 2400 bauds
Fonctionne à 2400 bauds
Messages : 1347
Enregistré le : 26 oct. 2018 18:45
Localisation : Ile-de-France

Re: FORTH for the PC-G850(V)(S)

Message par Dom »

Hi Robert,
Thank you, your work is very appreciated !
Moi, c'est les poquettes, et la Coll'à'Dom, c'est
Gilles59
Fonctionne à 2400 bauds
Fonctionne à 2400 bauds
Messages : 1602
Enregistré le : 27 oct. 2010 20:46

Re: FORTH for the PC-G850(V)(S)

Message par Gilles59 »

I wonder if your code can be adapted without too much difficulty on another Z80 platform and if you would be ok with that?
Casio FX-502P /602P / 603P / FX180P+ / FX4000P / TI57 / TI66 / TI74 Basicalc / TI95 Procalc / HP12C / HP15C LE / DM41L / HP 30B / HP39GII / HP 48SX USA / 49G / 49g+ / 50G / 50G NewRPL / HP Prime / Oric 1 / Amstrad CPC 6128+ CM14 et MM12 / Alice 32
engelen
Fonctionne à 75 bauds
Fonctionne à 75 bauds
Messages : 21
Enregistré le : 01 sept. 2021 21:14
Localisation : New York
Contact :

Re: FORTH for the PC-G850(V)(S)

Message par engelen »

Gilles59 I have no problem if you or someone else wants to port the code as long as credits are included. It is BSD-3 open source and fully documented. The only system calls that are required are calls similar to PUTCHR to write a character with EMIT and GETCHR to read the keyboard with KEY (and GETKEY) in Forth. These are easy to replace.

I'm also considering porting Forth850 to the PC-1600, perhaps sometime soon. In the meantime, I'm also looking for a floating point library that is small. There are some Z80 floating point projects that might be suitable. But the code base is typically quite large. In other cases the Z80 code looks specific for certain platforms, like the Ti-83. If I can't find a fp library, then I may write my own. I already wrote some fp routines that are single precision IEEE 754 compatible.

- Robert
engelen
Fonctionne à 75 bauds
Fonctionne à 75 bauds
Messages : 21
Enregistré le : 01 sept. 2021 21:14
Localisation : New York
Contact :

Re: FORTH for the PC-G850(V)(S)

Message par engelen »

I made some further Z80 math speed improvements and fixed a bug in the '*' (star) multiplication word.

So far everything tested out OK, but will keep v0.9 version until I'm sure there are no remaining issues. Then I will update to v1.0.

- Robert
engelen
Fonctionne à 75 bauds
Fonctionne à 75 bauds
Messages : 21
Enregistré le : 01 sept. 2021 21:14
Localisation : New York
Contact :

Re: FORTH for the PC-G850(V)(S)

Message par engelen »

engelen a écrit : 19 nov. 2022 02:43 I'm also looking for a floating point library that is small. There are some Z80 floating point projects that might be suitable. But the code base is typically quite large. In other cases the Z80 code looks specific for certain platforms, like the Ti-83. If I can't find a fp library, then I may write my own. I already wrote some fp routines that are single precision IEEE 754 compatible.
New Z80 IEEE 754 floating point library is complete and now added to the Forth850-full version. The full version is a 10K binary. The small version is 8K.

I've tested the floating point routines and wrote some demo code. Here a sine plotter that uses the new Z80 floating point routines:

Image

The IEEE 754 floating point implementation is close to compliance, but lacks INF/NAN support (since Forth has exceptions we get errors any way) and does not use "banker's rounding" (to avoid code bloat). There is no observable difference, except for the rounding of the last (binary) digit. I may revisit this sometime in the future.

- Robert
Gilles59
Fonctionne à 2400 bauds
Fonctionne à 2400 bauds
Messages : 1602
Enregistré le : 27 oct. 2010 20:46

Re: FORTH for the PC-G850(V)(S)

Message par Gilles59 »

Great job. Is there a PC-G850 emulator to test this?
Casio FX-502P /602P / 603P / FX180P+ / FX4000P / TI57 / TI66 / TI74 Basicalc / TI95 Procalc / HP12C / HP15C LE / DM41L / HP 30B / HP39GII / HP 48SX USA / 49G / 49g+ / 50G / 50G NewRPL / HP Prime / Oric 1 / Amstrad CPC 6128+ CM14 et MM12 / Alice 32
engelen
Fonctionne à 75 bauds
Fonctionne à 75 bauds
Messages : 21
Enregistré le : 01 sept. 2021 21:14
Localisation : New York
Contact :

Re: FORTH for the PC-G850(V)(S)

Message par engelen »

The smaller "standard 8K version" Forth850 has proven to be stable for weeks of using it with aggressive testing, but lacks floating point.

The work-in-progress Forth850 "full version" with IEEE 754 floating point had an issue with floating point string parsing that I fixed today. Testing the "full version" of Forth850 with IEEE 754 floating point will continue before I am confident to upgrade from v0.9 to a stable v1.0.

Further work on the IEEE 754 floating point implementation is progressing well. I have a new prototype of the Forth850 "full version" with IEEE 754 floating point that implements three of the five IEEE 754 rounding modes to choose from: round to nearest, ties to even (same as libmath used by C/C++, Lua, Python, Julia etc), round to nearest, ties to away, and round towards zero (truncation). The "full version" of Forth850 will use round to nearest, ties to even. The Z80 math code base is still small and efficient, i.e. "memory less" using Z80 registers. The rounding modes add about 67 bytes of code after rewriting parts of the Z80 core IEEE 754 math routines.

Creating clean, well-documented and formalized Z80 assembly code helps a lot to assure the IEEE 754 math implementation is correct. It's an interesting and fun small project to work on!

- Robert
Avatar du membre
fred260571
Fonctionne à 1200 bauds
Fonctionne à 1200 bauds
Messages : 362
Enregistré le : 19 avr. 2016 13:10
Localisation : Toulouse

Re: FORTH for the PC-G850(V)(S)

Message par fred260571 »

Fantastic job
Now I need to find my 850 :mrgreen: :mrgreen: :mrgreen:
ignorance is bliss
TI 57 II, TI 66, casio fx7500g, HP48GX, HP49G+, HP200LX, palm m125, Sharp PC-G850VS, HP12C
Répondre

Retourner vers « Tous les Pockets »