![]() | ||
| Home | SwiftX Archive | SwiftForth Archive | |

It does help, a lot more than the SwiftX Reference Manual, 3.4 DEFINING WORDS. The word I was really trying to understand was a
little more removed but works the same as ACE:.
INTERPRETER : +DATA ( n1 n2 -- n3 ) SWAP DUP ( n2 n1 n1 ) EQU ( n2 n1 ) + ;
I didn't think about it looking forward beyond the actual call of the word containing it. Although familiarizing myself with
cross-compiler principles is a very good idea, I don't think it would have taught me this. Perhaps a little explanation and
example like you gave me added to the manual would benefit others as well.
-----Original Message-----
From: swiftx-bounce_at_forth.com [mailto:swiftx-bounce_at_forth.com]On Behalf
Of Rick VanNorman
Sent: Wednesday, March 21, 2001 11:50 AM
To: swiftx_at_forth.com
Subject: [swiftx] Re: EQU Inside Colon Definitions
Dennis,
The simplest way to explain EQU is that it gives you a free
way to name a constant. When you refer to a word defined by
EQU inside a colon definition, it is exactly like typing the
number. For instance:
14 EQU FOO
: BAR1 FOO 0 DO I . LOOP ;
: BAR2 14 0 DO I . LOOP ;
BAR1 and BAR2 compile exactly the same code.
The other way in which you have observed EQU being used is
as a word to help define other words -- extending the compiler.
The case you quote
>INTERPRETER
>: ACE: ( r -- ) 'ACE + EQU ;
Is where you want to define a set of constants by their offset
from a base address. For instance, if 'ACE is 128, then the following
definitions are equivalent:
0 ACE: FOO 128 0 + EQU FOO
1 ACE: BAR 128 1 + EQU BAR
etc.
Hope this helps.
Rick
*********** REPLY SEPARATOR ***********
On 3/21/2001 at 11:35 AM Dennis W. Bulgrien wrote:
>EQU help states "If ... referenced inside a target colon definition, its
>value will be compiled as a literal". Does this mean that
>if <name> or "EQU" is referenced? I found code with EQU inside an
>interpreter colon definition. I don't know what it does, other
>than popping a cell off the stack. Could someone explain it please?
>
>Example:
>--------
>\ ACE: defines registers in the TI dual ACE chip.
>\ 'ACE is the base address for the TI chip.
>
>Help:
>-----
>EQU <name>
>( x =97 )
>
>Define a one-cell constant in the host only, whose value is x. If an EQU
>is referenced inside a target colon definition, its value
>will be compiled as a literal. Execution of name returns x.
m
----------------------------------------------------------------------
swiftx_at_forth.com The SwiftX programming discussion email list
To unsubscribe, send subject "unsubscribe swiftx" to listar_at_forth.com
For help with listar commands, send subject "help" to listar_at_forth.com
Archives are located at http://www.forth.com/swiftx -- check them out!
----------------------------------------------------------------------
swiftx_at_forth.com The SwiftX programming discussion email list
To unsubscribe, send subject "unsubscribe swiftx" to listar_at_forth.com
For help with listar commands, send subject "help" to listar_at_forth.com
Archives are located at http://www.forth.com/swiftx -- check them out!
Received on Wed Mar 21 2001 - 11:11:55 PST
This archive was generated by hypermail 2.2.0 : Wed Jan 07 2009 - 03:04:22 PST