Hi David,

> After a good couple of days of learning forth and getting my xbee
> communicating using interrupts on uart1 in API mode, this has just started
> happening and I'm stumped.
> 
> When I generate a string with
>> s" Some text",
> 
> it gets corrupted, and I keep seeing bits of the command lines I've been
> typing in the text. For example:
> 
> 
>> ." A longer bit of text"
>  ok
>> 2dup 2dup 2dup
>  ok
>> type
> e 2dup 2dupt of text ok
> 
> Also it seems that the location it's putting my string and the location of
> the TIB are very close. Is this why I'm seeing my input in the string?

Let me explain, what happens in parts. First: The interpreter uses
the memory region TIB that gets all the keystrokes from the usart line.
the interactive s" (there is a compiling s" as well) selects a subregion
from TIB. This has the side effect that a new line will destroy whatever
s" may have had in the previous line. Thus the command

s" hi there" type

will work (prints "hi there"). but

s" hi there"
type

(with a newline between the commands) will produce garbage (at least to
some degree).

The compiling s" variant does something completely different: It copies
the string into the dictionary (flash) and at runtime it gives the
flash address and length. This information uses ITYPE to do basically
the same that TYPE does for RAM based strings. The compiling s" makes
a copy to a different memory region, the interpreted s" does not; it
only gives a subregion of the TIB (or to be more precious: of the
memory buffer, SOURCE points to).

The command ." should only be used within colon definitions. It compiles
(copies) the string that follows into the dictionary (flash) and at
runtime it prints the string character by character. The ." should not
be used in interpreter mode (it does not produce an error message however)

For a simple example how strings can be dealt with, I'd recommend
http://amforth.sourceforge.net/recipes/simple-strings.html
It does not exactly cover your problems, but may give you an
idea how thing could be done.

Matthias


------------------------------------------------------------------------------
Keep yourself connected to Go Parallel: 
TUNE You got it built. Now make it sing. Tune shows you how.
http://goparallel.sourceforge.net
_______________________________________________
Amforth-devel mailing list for http://amforth.sf.net/
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel

Reply via email to