An example of Delphi embedded assembly

zhaozj2021-02-11  179

With Delphi written, 4 bytes directed to the X pointer down to reverse: function Toulong (x: pchar): longword; begin result: = (longword (x ^) SHL 24) or (longword ((xiWord ) ^) SHL 16) OR (longword ((x 2) ^) SHL 8) or (longword ((x 3) ^)); end; The following is an embedded assembly method using Delphi: 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; Description: By default, Delphi uses "Register" mode If the parameters are in 3, Eax, EDX, and ECX will be used, and more than 3 parameter portions will use the stack. Returning the length of the parameter, for example, 8 bits are returned by Al, 16 bits use AX, 32-bit Eax, 64 bits use two 32-bit registers EDX: EAX, where EAX is low. Efficiency: This example is approximately 50% from Delphi or C.

转载请注明原文地址:https://www.9cbs.com/read-5646.html

New Post(0)