tabemann / zeptoforth

A not-so-small Forth for Cortex-M

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No word being built

twillis-prog opened this issue · comments

Creating a constant string array. Works in Mecrisp and Gforth.
On Zepoforth zeptoforth-1.5.4.3 - zeptoforth_kernel-1.5.4.3.uf2
Not clear what the issue. is.

compat import ok
\ S" ( "ccc" -- ) ok
: place ( c-addr1 u c-addr2 -- ) ok
over >r rot over 1+ r> move c! ; ok
ok
ok
: S, ok
here over 1+ allot place align ; ok
ok
\ parse ( xchar "ccc" – c-addr u ) ok
: ," here 34 parse S, ; ok
ok
ok
: csarray ( here nstrings -- ) ok
create ok
0 do ok
dup , dup c@ 1+ + aligned ok
loop ok
drop ok
does> ( idx -- addr size ) ok
swap cells + @ count ok
; ok
\ usage ok
here ok
," Monday" ok
," Tuesday" ok
," Wednesday" ok
," Thursday" ok
," Friday" ok
," Saturday" ok
," Sunday" ok
7 csarray day-na2mes no word is being built
Error

The issue is that you are using CREATE rather than <BUILDS with DOES> ─ zeptoforth requires <BUILDS with DOES> for reasons (mostly dealing with compilation to flash) whereas gforth uses CREATE ... DOES> and Mecrisp-Stellaris simply has CREATE as a wrapper around <BUILDS which just uses a empty DOES> internally.

Another little note that does not affect this code because you are using the COMPAT module is that one difference between zeptoforth and both gforth and Mecrisp-Stellaris is that ALIGN ( addr|offset power-of-two -- addr'|offset' ) is meant to align an address or offset to a specified power of two, and to get the same behavior in zeptoforth you use CELL ALIGN, ─ however the traditional ANS ALIGN is provided by the COMPAT module which you are using.

Travis

Note, GitHub ate my references to <BUILDS with DOES> thinking they were tags, so I am posting this to make sure you notice my comment correctly, which should go like this:

The issue is that you are using CREATE rather than <BUILDS with DOES> ─ zeptoforth requires <BUILDS with DOES> for reasons (mostly dealing with compilation to flash) whereas gforth uses CREATE ... DOES> and Mecrisp-Stellaris simply has CREATE as a wrapper around <BUILDS which just uses a empty DOES> internally.

Another little note that does not affect this code because you are using the COMPAT module is that one difference between zeptoforth and both gforth and Mecrisp-Stellaris is that ALIGN ( addr|offset power-of-two -- addr'|offset' ) is meant to align an address or offset to a specified power of two, and to get the same behavior in zeptoforth you use CELL ALIGN, ─ however the traditional ANS ALIGN is provided by the COMPAT module which you are using.

Travis

The matter is that there is no way to programmatically print the name of a constant value because any number of constants may share a value. So if you want to print 1 as F1 you might get some completely unrelated constant foobar which just happens to share the value of 1 printed instead.

Travis