News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Clock cycles used by push, pop, mov

Started by Don57, June 28, 2011, 05:39:07 PM

Previous topic - Next topic

Don57

I was planning on replacing some register loading

    mov eax, dwNumber1
    mov dwNumber2, eax

with push and pops to save some clock cycles. When I looked it up in the Masm reference material, probably reading it wrong,
I read it as 

   mov reg,mem  1 cycle     
   push or pop 3 cycles

just curious Thanks

bomz

this cycles have no any reference to real velocity of read/write to memory. through register it much quickly

bomz





as you may see through memory needs more than 30 000 cycles. all you may rightly use memory cache

bomz

I made a liitle program for myself which exclude double http addresses from big list - 19 000 addresses long . My first application do this 8 minutes, after apply modern algorithm and all investigations with ticks I do this - 0.3 sec

Making video need computer recourses


any push-pop, any inc-dec, any lodsb-stosb, any loop,...

jj2007

Depends on the CPU and the bus. On a Celeron M, a push mem/pop mem pair needs 6 cycles, against 2 cycles for a mem2reg, reg2mem pair. However, that is for cached memory. The difference is much smaller for non-cached memory. Below, the first two rows are for 1000 bytes each, the kCycles for 8,000,000, i.e. non-cached memory. In practice, the differences are irrelevant.

Intel(R) Celeron(R) M CPU        420  @ 1.60GHz (SSE3)
1521    cycles for push+pop
520     cycles for mov+mov
13768   kCycles for push+pop
13050   kCycles for mov+mov
11977   kCycles for rep movsd

1519    cycles for push+pop
523     cycles for mov+mov
13692   kCycles for push+pop
13056   kCycles for mov+mov
11977   kCycles for rep movsd

dedndave

a little surprising, actually
i thought PUSH/POP was faster on this CPU   :P
(i mean faster than the measurement - not faster than MOV/MOV)

prescott w/htt
Intel(R) Pentium(R) 4 CPU 3.00GHz (SSE3)
3089    cycles for push+pop
602     cycles for mov+mov
25425   kCycles for push+pop
21472   kCycles for mov+mov
22708   kCycles for rep movsd

3122    cycles for push+pop
601     cycles for mov+mov
25104   kCycles for push+pop
21593   kCycles for mov+mov
22652   kCycles for rep movsd

MichaelW

Quote from: Don57 on June 28, 2011, 05:39:07 PM
When I looked it up in the Masm reference material, probably reading it wrong,
I read it as 

   mov reg,mem  1 cycle     
   push or pop 3 cycles

Those cycle counts are probably from somewhere around the 486 era, too far back to be meaningful today.
eschew obfuscation