TG9541/stm8ef

Add VALUE and TO

TG9541 opened this issue · 1 comments

The words VALUE and TO are part of the Forth Standard and supporting this ANS-Forth feature makes testing code written for other platforms easier.

The problem with VALUE and TO is that different memory classes require different behavior (e.g. initialization to the last value).

As the Forth Standard has no requirements or recommendations for dictionaries in ROM, STM8 eForth only provides a definition of VALUE with the variable Cell in-lined in the dictionary and discourages its use outside of the following use cases:

  • testing code not originally intended for STM8 eForth in RAM
  • defining values in ROM that can be changed interactively while the Flash ROM is unlocked (NVM mode)

The code has been checked in Issue #430.

The code passes the Forth Standard tests:

T{  111 VALUE v1 -> }T ok
T{ -999 VALUE v2 -> }T ok
T{ v1 ->  111 }T ok
T{ v2 -> -999 }T ok
T{ 222 TO v1 -> }T ok
T{ v1 -> 222 }T ok

T{ : vd1 v1 ; -> }T ok
T{ vd1 -> 222 }T ok

T{ : vd2 TO v2 ; -> }T ok
T{ v2 -> -999 }T ok
T{ -333 vd2 -> }T ok
T{ v2 -> -333 }T ok
T{ v1 ->  222 }T ok