With delphi written procedures, x indicators pointing to the four-byte order reversed:
Function toulong (x: pchar): longword;
Begin
Result: = (longword (x ^) shl 24) or
(Longword ((x + 1) ^) shl 16) or
(Longword ((x + 2) ^) shl 8) or
(Longword ((x + 3 )^));
End;
Following is embedded with delphi compilation wording:
Function toulong (x: pchar): longword;
Asm
Mov esi, eax
Mov ax, [esi]
Xchg ah, al
Shl eax, 16
Mov ax, [esi +2]
Xchg ah, al
End;
Note: By default, delphi "register", if the parameters have been three,
Will be using eax and edx and ecx, more than three parameters of the stack will be used. Return parameters
Depending on the length of storage, such as al 8 with the return of 16 by ax, with eax 32, with 64 with two
32 register edx: eax, eax is low.
Efficiency: asm about this case or c delphi faster than 50%. |