Talk About Network



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 > Why is GForth-I...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 30 Topic 4030 of 4067
Post > Topic >>

Why is GForth-ITC fast?

by brian.fox@[EMAIL PROTECTED] Apr 30, 2008 at 07:30 PM

I have been dis-assembling pieces of GForth and I don't understand why
it is generally faster than other ITC Forths that are written in
Assembler like CI-Forth or my old 16 bit HS/Forth.  The Assembler
primitives seem to be so much smaller from what I can see.  Is the C
compiler smarter than we are?

Here are some examples
CIFORTH (Albert van der Horst)
-------------

@[EMAIL PROTECTED]
        POP     EBX
        MOV     EAX,[EBX]
        PUSH    EAX
        LODSD                 ; NEXT
        JMP      LONG[EAX]

C@[EMAIL PROTECTED]
        POP     EBX
        XOR     EAX,EAX
        MOV     AL,[EBX]
        PUSH    EAX
        LODSD                 ; NEXT
        JMP      LONG[EAX]

!
        POP     EBX      ;ADDR
        POP     EAX      ;DATA
        MOV     [EBX],EAX
        LODSD                 ; NEXT
        JMP      LONG[EAX]

C!
        POP     EBX      ;ADDR
        POP     EAX      ;DATA
        MOV     [EBX],AL
        LODSD                 ; NEXT
        JMP      LONG[EAX]

+
        POP     EAX      ;(S1) <- (S1) + (S2)
        POP     EBX
        ADD     EAX,EBX
        PUSH    EAX
        LODSD                 ; NEXT
        JMP      LONG[EAX]


GFORTH-ITC
---------------------------------------------
see !
Code !
( $402B2C )  mov     dword ptr 40F2E0 , ebx  \ $89 $1D $E0 $F2 $40 $0
( $402B32 )  mov     edx , dword ptr 4 [esi]  \ $8B $56 $4
( $402B35 )  mov     eax , dword ptr [esi]  \ $8B $6
( $402B37 )  add     esi , # 8  \ $83 $C6 $8
( $402B3A )  mov     dword ptr [eax] , edx  \ $89 $10
( $402B3C )  mov     edx , dword ptr [ebx]  \ $8B $13
( $402B3E )  add     ebx , # 4  \ $83 $C3 $4
( $402B41 )  jmp     dword ptr [edx]  \ $FF $22
( $402B43 )  xchg     eax, eax  \ $90
end-code


see c!
Code c!
( $402B74 )  mov     dword ptr 40F2E0 , ebx  \ $89 $1D $E0 $F2 $40 $0
( $402B7A )  mov     dl , byte ptr 4 [esi]  \ $8A $56 $4
( $402B7D )  mov     eax , dword ptr [esi]  \ $8B $6
( $402B7F )  add     esi , # 8  \ $83 $C6 $8
( $402B82 )  mov     byte ptr [eax] , dl  \ $88 $10
( $402B84 )  mov     edx , dword ptr [ebx]  \ $8B $13
( $402B86 )  add     ebx , # 4  \ $83 $C3 $4
( $402B89 )  jmp     dword ptr [edx]  \ $FF $22
( $402B8B )  xchg     eax, eax  \ $90
end-code


see @[EMAIL PROTECTED]
 @[EMAIL PROTECTED]
( $402AFC )  mov     dword ptr 40F2E0 , ebx  \ $89 $1D $E0 $F2 $40 $0
( $402B02 )  mov     eax , dword ptr [esi]  \ $8B $6
( $402B04 )  mov     eax , dword ptr [eax]  \ $8B $0
( $402B06 )  mov     dword ptr [esi] , eax  \ $89 $6
( $402B08 )  mov     edx , dword ptr [ebx]  \ $8B $13
( $402B0A )  add     ebx , # 4  \ $83 $C3 $4
( $402B0D )  jmp     dword ptr [edx]  \ $FF $22
( $402B0F )  xchg     eax, eax  \ $90
end-code

SEE C@[EMAIL PROTECTED]
 c@[EMAIL PROTECTED]
( $402B5C )  mov     dword ptr 40F2E0 , ebx  \ $89 $1D $E0 $F2 $40 $0
( $402B62 )  mov     eax , dword ptr [esi]  \ $8B $6
( $402B64 )  mov     al , byte ptr [eax]  \ $8A $0
( $402B66 )  and     eax , # FF  \ $25 $FF $0 $0 $0
( $402B6B )  mov     dword ptr [esi] , eax  \ $89 $6
( $402B6D )  mov     edx , dword ptr [ebx]  \ $8B $13
( $402B6F )  add     ebx , # 4  \ $83 $C3 $4
( $402B72 )  jmp     dword ptr [edx]  \ $FF $22
end-code

Code +
( $4019E8 )  mov     dword ptr 40F2E0 , ebx  \ $89 $1D $E0 $F2 $40 $0
( $4019EE )  mov     eax , dword ptr [esi]  \ $8B $6
( $4019F0 )  mov     edx , dword ptr 4 [esi]  \ $8B $56 $4
( $4019F3 )  add     esi , # 4  \ $83 $C6 $4
( $4019F6 )  add     edx , eax  \ $1 $C2
( $4019F8 )  mov     dword ptr [esi] , edx  \ $89 $16
( $4019FA )  mov     edx , dword ptr [ebx]  \ $8B $13
( $4019FC )  add     ebx , # 4  \ $83 $C3 $4
( $4019FF )  jmp     dword ptr [edx]  \ $FF $22
( $401A01 )  lea     esi , dword ptr 0 [esi]  \ $8D $76 $0
end-code


Brian Fox




 30 Posts in Topic:
Why is GForth-ITC fast?
brian.fox@[EMAIL PROTECTE  2008-04-30 19:30:05 
Re: Why is GForth-ITC fast?
"winston19842005@[EM  2008-04-30 21:29:44 
Re: Why is GForth-ITC fast?
Robert Spykerman <robe  2008-05-01 01:42:28 
Re: Why is GForth-ITC fast?
anton@[EMAIL PROTECTED]   2008-05-01 10:54:45 
Re: Why is GForth-ITC fast?
Albert van der Horst <  2008-05-01 17:26:57 
Re: Why is GForth-ITC fast?
stephenXXX@[EMAIL PROTECT  2008-05-01 22:22:50 
Re: Why is GForth-ITC fast?
stephenXXX@[EMAIL PROTECT  2008-05-01 09:00:18 
Re: Why is GForth-ITC fast?
Robert Spykerman <robe  2008-05-01 04:43:05 
Re: Why is GForth-ITC fast?
Thomas Pornin <pornin@  2008-05-01 12:45:38 
Re: Why is GForth-ITC fast?
stephenXXX@[EMAIL PROTECT  2008-05-01 12:56:26 
Re: Why is GForth-ITC fast?
Andrew Haley <andrew29  2008-05-01 11:41:05 
Re: Why is GForth-ITC fast?
anton@[EMAIL PROTECTED]   2008-05-01 18:22:56 
Re: Why is GForth-ITC fast?
Bernd Paysan <bernd.pa  2008-05-01 22:01:54 
Re: Why is GForth-ITC fast?
stephenXXX@[EMAIL PROTECT  2008-05-01 22:45:04 
Re: Why is GForth-ITC fast?
Thomas Pornin <pornin@  2008-05-01 23:44:26 
Re: Why is GForth-ITC fast?
Andrew Haley <andrew29  2008-05-02 04:27:59 
Re: Why is GForth-ITC fast?
Thomas Pornin <pornin@  2008-05-01 12:31:12 
Re: Why is GForth-ITC fast?
Albert van der Horst <  2008-05-01 16:33:12 
Re: Why is GForth-ITC fast?
brian.fox@[EMAIL PROTECTE  2008-05-01 17:12:16 
Re: Why is GForth-ITC fast?
mhx@[EMAIL PROTECTED] (M  2008-05-02 02:53:47 
Re: Why is GForth-ITC fast?
brian.fox@[EMAIL PROTECTE  2008-05-01 19:44:40 
Re: Why is GForth-ITC fast?
brian.fox@[EMAIL PROTECTE  2008-05-01 17:16:42 
Re: Why is GForth-ITC fast?
Robert Spykerman <robe  2008-05-01 20:17:47 
Re: Why is GForth-ITC fast?
Robert Spykerman <robe  2008-05-01 21:06:05 
Re: Why is GForth-ITC fast?
Thomas Pornin <pornin@  2008-05-02 13:00:46 
Re: Why is GForth-ITC fast?
Albert van der Horst <  2008-05-02 16:46:32 
Re: Why is GForth-ITC fast?
Thomas Pornin <pornin@  2008-05-02 18:11:41 
Re: Why is GForth-ITC fast?
Robert Spykerman <robe  2008-05-02 06:12:42 
Re: Why is GForth-ITC fast?
Robert Spykerman <robe  2008-05-02 17:40:35 
Re: Why is GForth-ITC fast?
Albert van der Horst <  2008-05-03 10:12:44 

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan12V112 Sat May 17 12:51:21 CDT 2008.