forth

Logical AND in Forth?

蓝咒 提交于 2019-11-29 09:23:27
I know the AND word defines binary and ... but what defines logical and ? The same word, AND , is also used for logical and . But the two input values to AND are recommended to be well-formed flags ; true and false are represented by two values, bits all set (-1) and bits all unset (0). Other values than these may work as true (as in C), but may lead to subtle errors. All comparison operators return well-formed flags, but for instance - does not. The following evaluates to false (0). 7 5 - 7 3 - AND AND gets bit patterns 100 and 010. The result is 0 (as it does the bitwise and ). References:

How do I implement an array of strings?

穿精又带淫゛_ 提交于 2019-11-29 07:12:43
I tried to implement a word that produces a string from an array when given a number on the stack in Forth. My first naive attempt was: create myarray s" Alpha" , s" Beta" , s" Charlie" , This was accepted, but it did not work as expected — myarray @ type produces inconsistent output (instead of my naive expectation that it might print "Alpha"). When searching the web, I found in Gforth documentation that a string created with s" has a limited lifetime which means that my ansatz is bound to fail from the beginning. On the other hand, even arrays of regular objects seem to be not standardized

What are the primitive Forth operators? [closed]

試著忘記壹切 提交于 2019-11-28 16:43:01
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 months ago . I'm interested in implementing a Forth system, just so I can get some experience building a simple VM and runtime. When starting in Forth, one typically learns about the stack and its operators (DROP, DUP, SWAP, etc.) first, so it's natural to think of these as being among the

Logical AND in Forth?

好久不见. 提交于 2019-11-28 02:46:51
问题 I know the AND word defines binary and ... but what defines logical and ? 回答1: The same word, AND , is also used for logical and . But the two input values to AND are recommended to be well-formed flags ; true and false are represented by two values, bits all set (-1) and bits all unset (0). Other values than these may work as true (as in C), but may lead to subtle errors. All comparison operators return well-formed flags, but for instance - does not. The following evaluates to false (0). 7 5

How do I implement an array of strings?

天涯浪子 提交于 2019-11-28 00:50:09
问题 I tried to implement a word that produces a string from an array when given a number on the stack in Forth. My first naive attempt was: create myarray s" Alpha" , s" Beta" , s" Charlie" , This was accepted, but it did not work as expected — myarray @ type produces inconsistent output (instead of my naive expectation that it might print "Alpha"). When searching the web, I found in Gforth documentation that a string created with s" has a limited lifetime which means that my ansatz is bound to