PDA

View Full Version : asm output



arthurprs
30-08-2008, 01:32 AM
using a bidimensional array
httpstream.pas.283: Result := @inbuffer[Cursor];
0042B024 8B5054 mov edx,[eax+$54]
0042B027 C1E207 shl edx,$07
0042B02A 8D44D05C lea eax,[eax+edx*8+$5c]
httpstream.pas.193: FHTTP.RecvBufferEx(@inbuffer[Feed, bytesreceived], bytestoreceive, MaxInt);
0042AD62 68FFFFFF7F push $7fffffff
0042AD67 8B4358 mov eax,[ebx+$58]
0042AD6A C1E007 shl eax,$07
0042AD6D 8D04C3 lea eax,[ebx+eax*8]
0042AD70 8B55F8 mov edx,[ebp-$08]
0042AD73 8D54105C lea edx,[eax+edx+$5c]
0042AD77 8BCE mov ecx,esi
0042AD79 8B4344 mov eax,[ebx+$44]
0042AD7C 8B38 mov edi,[eax]
0042AD7E FF5740 call dword ptr [edi+$40]

using a linear array
httpstream.pas.283: Result := @inbuffer[Cursor * BUFFSIZE];
0042B020 8B5054 mov edx,[eax+$54]
0042B023 C1E20A shl edx,$0a
0042B026 8D44105C lea eax,[eax+edx+$5c]
httpstream.pas.193: FHTTP.RecvBufferEx(@inbuffer[Feed * BUFFSIZE + bytesreceived], bytestoreceive, MaxInt);
0042BAEA 68FFFFFF7F push $7fffffff
0042BAEF 8B4358 mov eax,[ebx+$58]
0042BAF2 C1E00A shl eax,$0a
0042BAF5 0345F8 add eax,[ebp-$08]
0042BAF8 8D54035C lea edx,[ebx+eax+$5c]
0042BAFC 8BCE mov ecx,esi
0042BAFE 8B4344 mov eax,[ebx+$44]
0042BB01 8B38 mov edi,[eax]
0042BB03 FF5740 call dword ptr [edi+$40]

i don't know much about asm, but witch version will be faster?

the "eax*8" on first and second codes really means a multiplication of eax register by eight ?

imcold
30-08-2008, 05:17 AM
There won't be any measurable difference - or any difference at all.
Yes.

JSoftware
30-08-2008, 10:35 AM
Yeah, as Imcold says, there's no difference at all. They amount to the same amount of cpu clocks

And yes, the *8 means multiplied by eight, but there's the same thing going on in the second [eax+edx+$5c]
Here edx is multiplied by 1, but the multiplication is handled by shifting edx a little more in the former instruction. This might be slightly faster but still only something you couldn't measure :P

arthurprs
30-08-2008, 05:50 PM
Interesting, thanks for the explanation guys :)