Page 2 of 2

Posted: Mon Feb 20, 2006 7:53 pm
by Trond
!push eax
!push ecx
!push edx
!pop edx
!pop ecx
!pop eax

is faster than

!pushad
!popad

, believe me.

Posted: Mon Feb 20, 2006 7:58 pm
by thefool
Trond=true.

Proof(No debugger!):

Code: Select all

Delay(1000)

avg=0
For a=1 To 10
start=GetTickCount_()
For i=1 To 99999999
!push eax
!push ecx
!push edx
!pop edx
!pop ecx
!pop eax 
Next i
stop=GetTickCount_()

avg+stop-start
Next a

MessageRequester("Average for multiple pop-pushs",Str(avg/10))


;NExt!

Delay(1000)

avg=0
For a=1 To 10
start=GetTickCount_()
For i=1 To 99999999
 !pushad
!popad 
Next i
stop=GetTickCount_()

avg+stop-start
Next a

MessageRequester("Average for pushad-popad",Str(avg/10))

Posted: Mon Feb 20, 2006 8:05 pm
by Fred
I know that, better read my post again: "faster to write". You used it in a debug code, right ? BTW, you push only 3 registers while PUSHAD push 8 registers.. not very fair speed test ;).

Posted: Mon Feb 20, 2006 8:09 pm
by thefool
Trond mislead me! Or!! Maybe you edited your post after seeing you were wrong :shock:

Posted: Mon Feb 20, 2006 8:10 pm
by Fred
thefool wrote:Maybe you edited your post after seeing you were wrong :shock:
I don't think so or i would have to hack the database directly :lol:

Posted: Mon Feb 20, 2006 8:11 pm
by Trond
Yes I misled you on purpose! :twisted:


:oops:
I don't think so or i would have to hack the database directly :lol:
Or used the edit button.

Edit: Or hack it indirectely.

Posted: Mon Feb 20, 2006 8:22 pm
by thefool
Fred wrote:BTW, you push only 3 registers while PUSHAD push 8 registers.. not very fair speed test ;).
shh.. what the users dont notice they dont mind..!

After the small correction (mind you, its again trond :P ) the pushad is faster..

Time to dig up my head, and an assembler manual..;

Theory:

Pushad takes 18 clock cykles, popad takes 24.
One single push takes 2, and a pop takes 4. 2*8+4*8 = 48 clock cykles in total, wich is more than 42 (18+24). But if you only need those registers the 3 push and pops is faster of course..

Posted: Mon Feb 20, 2006 9:08 pm
by Fred
seems like you have to update your asm manual, these numbers are valid for 386 :P. For 486 and up it's more like: pop/push: 1 cycles, pushad: 9 cycles, popad: 9 cycles.

Posted: Mon Feb 20, 2006 9:57 pm
by thefool
Darn :P
I got many laying around, just picked one. But ok it was too old :)

okay these should be correct:

Pushad:11
Popad : 9

Pop : 4
Push:1


So:

Pushad+popad = 20
Pop*8+push*8 = 40

These are correct. The pb test also shows that pushad+popad is about twice as fast :)