home .. forth .. colorforth mail list archive ..

Re: [colorforth] Strange ColorForth results


--- "Roman Pavlyuk (personal)" <john@xxxxxxxxxxxxx>
wrote:
> (Best viewed in monospace font)
> 
> You're right, I'm wrong.

Well...I wouldn't say that.  Samuel's post (putting
in an extra literal before the '?') seems to have
fixed the problem.
 
> Anyway, the original wrong one
> 
> : 0? ? drop if 0 ; then 1 ;
> 
> 00900811 A9 EB 07 90 00       test       
> eax,9007EBh
> 00900816 AD                   lods        dword ptr
> [esi]
> 00900817 74 00                je          00900819
> 00900819 8D 76 FC             lea        
> esi,[esi-4]
> 0090081C 89 06                mov         dword ptr
> [esi],eax
> 0090081E B8 01 00 00 00       mov         eax,1
> 00900823 C3                   ret
> 00900824 8D 76 FC             lea        
> esi,[esi-4]
> 00900827 89 06                mov         dword ptr
> [esi],eax
> 00900829 B8 00 00 00 00       mov         eax,0
> 0090082E C3                   ret
> 
> TEST uses some junk off stack. 

Ok, I think I get it.  By the way, how did you 
get the Pentium diassembly?
 
> Now, my preferred one:
> 
> : 0? [ 0 ] + drop if 0 ; then 1 ;
> where [ 0 ] is a yellow zero

Yep.  That works.  I'm still not sure when to
use yellow versus green.  For instance

: 0? 0 + drop if 0 ; then 1 ; 

also works.  I'm guessing using the yellow
0 is more efficient?  Then why not the following?

: 0? [ 0 ] + drop if [ 0 ] then [ 1 ] ;
 
> You can see, btw, that this is not optimized
> properly
> 
> So, 
> : 0? [ 0 ] + if drop 0 ; then 1 ; 

Hmmmm...that doesn't work.  

0 0? leaves an extra number on the stack.

: 0? [ 0 ] + if drop 0 ; then drop 1 ; 

works, but I don't think that is optimal.
(Could be wrong)

Regards,

John M. Drake
 


__________________________________
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
http://antispam.yahoo.com/tools

---------------------------------------------------------------------
To unsubscribe, e-mail: colorforth-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: colorforth-help@xxxxxxxxxxxxxxxxxx
Main web page - http://www.colorforth.com