Using create/does>¶
The command combination create .. does>
creates a challange on a microcontroller forth which dictionary
resides in flash memory since create writes the
execution token. A subsequent does> replaces this
execution token with some other value. The AVR can reprogram
it on the fly, the MSP430 places a much higher burden to achieve
it. Due to the size of a single flash page the the sequence
create/does>
works on the AVR8 only.
The combination <builds/does>
works on all platforms
without restrictions as a plug-in replacement.
A subtle error will be made with the following code
: const create , does> @ ;
This code does not work as expected. The value compiled with ,
is compiled into the dictionary, which is read using the @i
word. The
correct code is
: const create , does> @i ;
Similarly the sequence
: world create ( sizeinformation ) allot
does> ( size is on stack) ... ;
does not work. It needs to be changed to
: world variable ( sizeinformation) allot
does> @i ( sizeinformation is now on stack) ... ;
;
See also