| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | Newsletters | VB Forums | Developer.com |
|
|||||||
| Assembly Questions and Answers for Assembly here! |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Weird results...
I have assembly routine in my code where main loop for function is:
Code:
label: mov ecx,[esi+ebx] adc [edi+ebx],ecx lea ebx,[ebx+4] dec eax jnz label This is running slower than reference code in C++ (optimized speed) running at 6.6 cycles per loop. This C++ code is 15 instructions per loop (3 times as much as asm loop) ??? My calculations say this asm loop should run at 4.4 cycles per loop. but it is not. it is 10.5. If I change ADC to ADD, loop indeed takes 4.4cycles. Why is ADC so slow ? It should be same speed as ADD no ? |
|
#2
|
|||
|
|||
|
Re: Weird results...
Well... On P4 and up, ADC is actually one of the instructions you would want to avoid because it is slow (significantly slower than ADD, although it does depend on the code sequence)
Note that with carefull selection the P4 can have 4 instructions executing (practically) concurrently. So with the right kind of instructions in the right order a code sequence that is 4 times as large as the code here (5 instrcutions) could still be just as fast. The loop seems to indicate you are doing large integer math ? If this is the case, and you need the extra speed (and you obviously have a P4), you might want to go with using MMX/SSE instructions to higher overall throughput. |
![]() |
| Bookmarks |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|