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

Re: [colorforth] Strage ColorForth results


(Best viewed in monospace font)

You're right, I'm wrong.

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. 

Now, my preferred one:

: 0? [ 0 ] + drop if 0 ; then 1 ;
where [ 0 ] is a yellow zero

0090079E 05 00 00 00 00       add         eax,0
009007A3 AD                   lods        dword ptr [esi]
009007A4 74 0B                je          009007B1
009007A6 8D 76 FC             lea         esi,[esi-4]
009007A9 89 06                mov         dword ptr [esi],eax
009007AB B8 00 00 00 00       mov         eax,0
009007B0 C3                   ret
009007B1 8D 76 FC             lea         esi,[esi-4]
009007B4 89 06                mov         dword ptr [esi],eax
009007B6 B8 01 00 00 00       mov         eax,1
009007BB C3                   ret

You can see, btw, that this is not optimized properly

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

009007CC 05 00 00 00 00       add         eax,0
009007D1 74 06                je          009007D9
009007D3 B8 00 00 00 00       mov         eax,0
009007D8 C3                   ret
009007D9 B8 01 00 00 00       mov         eax,1
009007DE C3                   ret

looks much better

This time tested (a bit)

BR,
Roman


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