tabemann / zeptoforth

A not-so-small Forth for Cortex-M
MIT License
189 stars 17 forks source link

STATE in not maintained consistently #5

Open frenchie68 opened 2 years ago

frenchie68 commented 2 years ago

Hi Travis,

I have been somehow challenged to prove the value of your output. I believe it is promising but you are not quite there yet. You seem to adhere, in a way, to the ANS-94 standard specification but you're not there yet. I tried to run some OTS benchmarks on your platform on the STM32F411RE. Although it is not officially supported, this test pattern ought to work yet it does not:

reboot Welcome to zeptoforth Built for stm32f411, version 0.39.0, on Sat Jun 4 08:15:17 PM CDT 2022 zeptoforth comes with ABSOLUTELY NO WARRANTY: for details type `license' ok DECIMAL ok : dfib1 ( d1 -- d2 ) ok 2DUP 2 0 D< IF ok 2DROP 1 0 ok ELSE ok 2DUP ok -1 -1 D+ RECURSE ok 2SWAP -2 -1 D+ RECURSE ok D+ ok THEN ; ok systick import ok enable-systick ok ok variable st-start ok variable st-end ok systick-counter st-start ! ok 34 0 dfib1 d. 9227465 ok systick-counter st-end ! ok CR st-end @ st-start @ - 10 * . ." ms" 4038500 not compiling

How come?

tabemann commented 2 years ago

I should note that ." does not work when STATE is 0, which is per standard. I also should warn you that while zeptoforth is pretty close to ANS, it does not make a concerted effort to follow ANS in every way (e.g. it uses NOT rather than INVERT because INVERT is an abomination, and it uses [IMMEDIATE] and [COMPILE-ONLY] within words rather than IMMEDIATE and COMPILE-ONLY after words due to issues imposed by compiling to flash).

tabemann commented 2 years ago

If you want to print a constant string at the REPL, use .(, which of course is closed with ), to print it, because .( is immediate.

tabemann commented 2 years ago

I should note that while zeptoforth does support S" and C" at the REPL, these are highly non-standard, and impose their own restrictions (i.e. because it stores the strings in temporary buffers that eventually get reused for more temporary strings).

tabemann commented 2 years ago

I have made a new release, 0.40.0, which adds ." and .\" at the REPL level, so one is no longer required to be in a compilation state to use them (in full builds at least - in kernel-only and mini builds compilation state is still required).

frenchie68 commented 2 years ago

Thanks Travis. /MOD (on the F411) and .S now look good to me. I haven't run extensive tests but as far as I can tell, they are good to go. Do you implement floored division? That's also a big thing since FORTH-83.