Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Forth > Re: Maybe a new...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 16 of 17 Topic 3795 of 4285
Post > Topic >>

Re: Maybe a newbie question..

by m_l_g3@[EMAIL PROTECTED] Mar 5, 2008 at 11:25 AM

On Mar 3, 12:07 pm, sb...@[EMAIL PROTECTED]
 wrote:
> Hi all, maybe it's a very newbie question.
> What is the difference (if there is any) in performance between these
> solutions?
>
> I've to choose 2 words and I'm comparing the IF ELSE cases or a table;
> here an example:
>
> CREATE MYTABLE
> ' WORD1 , ' WORD2 ,
>
> SEL_WORD VAR1 @[EMAIL PROTECTED]
 2* MYTABLE + @[EMAIL PROTECTED]
 EXECUTE ;
>
> or
>
> SEL_WORD VAR1 @[EMAIL PROTECTED]
 0= IF WORD1 ELSE WORD2 THEN ;
>
> I'm working on swiftX forth for an HC12B32 microcontroller; I've seen
> that the first solution (the one using a table) uses 3 bytes more than
> the second solution.
> But the question is: what is the fastest solution? Is there any
> difference? Because the table is very useful and I like a lot using a
> table.
>
> Thanks
>
> --
> Ciao da Stefano

Do you need VAR1 at all?

let us assume that the words writing to VAR1 are only
: set-var1 1 var1 ! ;
: reset-var1 0 var1 ! ;
and all write access to VAR1 is done via only these two.

Then you can use

DEFER the-right-word
: set-var1 ['] wordd2 is the-right-word ;
: reset-var1 ['] word1 is the-right-word ;

and instead of
>  VAR1 @[EMAIL PROTECTED]
 2* MYTABLE + @[EMAIL PROTECTED]
 EXECUTE ;
you can use just
THE-RIGHT-WORD

PS
multiple selecting words are also no problem:

DEFER the-right-word
DEFER the-left-word
: set-var1 ['] word2 is the-right-word ['] word4 is the-left-word  ;
: reset-var1 ['] word1 is the-right-word ['] word3 is the-left-word  ;
 




 17 Posts in Topic:
Maybe a newbie question..
sbi82@[EMAIL PROTECTED]   2008-03-03 01:07:27 
Re: Maybe a newbie question..
Jonah Thomas <jethomas  2008-03-03 06:08:41 
Re: Maybe a newbie question..
sbi82 <stefanobiz@[EMA  2008-03-03 13:09:18 
Re: Maybe a newbie question..
Jonah Thomas <jethomas  2008-03-03 06:20:49 
Re: Maybe a newbie question..
Jonah Thomas <jethomas  2008-03-03 07:53:00 
Re: Maybe a newbie question..
sbi82 <stefanobiz@[EMA  2008-03-03 19:29:49 
Re: Maybe a newbie question..
Brad Eckert <nospaambr  2008-03-03 08:34:37 
Re: Maybe a newbie question..
sbi82 <stefanobiz@[EMA  2008-03-03 19:27:07 
Re: Maybe a newbie question..
Elizabeth D Rather <er  2008-03-03 09:07:37 
Re: Maybe a newbie question..
sbi82 <stefanobiz@[EMA  2008-03-03 20:39:28 
Re: Maybe a newbie question..
Elizabeth D Rather <er  2008-03-03 10:20:50 
Re: Maybe a newbie question..
Jonah Thomas <jethomas  2008-03-03 14:38:38 
Re: Maybe a newbie question..
sbi82 <stefanobiz@[EMA  2008-03-03 20:43:49 
Re: Maybe a newbie question..
stephenXXX@[EMAIL PROTECT  2008-03-03 15:48:41 
Re: Maybe a newbie question..
Bruce McFarling <agila  2008-03-03 15:54:59 
Re: Maybe a newbie question..
m_l_g3@[EMAIL PROTECTED]   2008-03-05 11:25:00 
Re: Maybe a newbie question..
Elizabeth D Rather <er  2008-03-24 10:57:19 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Oct 12 14:05:53 CDT 2008.