Debug register

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

!push eax
!push ecx
!push edx
!pop edx
!pop ecx
!pop eax

is faster than

!pushad
!popad

, believe me.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post 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))
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post 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 ;).
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

Trond mislead me! Or!! Maybe you edited your post after seeing you were wrong :shock:
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post 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:
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post 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.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post 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..
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post 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.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post 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 :)
Post Reply