When you declare a process or function, you can specify a call rule that uses these keywords: Register, Pascal, CDECL, Stdcall, SaFECALL, such as: Function myfunction (x, y: real): real; cdecl;. .. Call rules determine the order of parameters to pass to routine, and also affect parameters release, errors, and unexpected processing from the registers used by the stack and parameters. The default call rules in Delphi are register.1, register and pascal: Parameters from left to right; that is, the leftmost parameters are first calculated and passed, the rightmost parameters are checked and passed. CDECL, STDCALL, SAFECALL: Parameters are passed from right to left. 2. All call rules In addition to the CDECL, the process, or function releases the parameters from the stack before returning. The CDECL rule is released by the caller after the process or function returns. 3. The Register rule uses three CPU registers to pass parameters, while the parameters transmitted in other call rules are in the stack. (Test 1, 3, the fact that the floating point number, method pointer, variant, int64, and structural types are not incoming registers, that is, the order is not in the current three parameters in turn) 4, The SAFECALL rule achieves an unexpected firewall. In Windows, this error notification between COM processes is implemented. (Error notification) See table:? Directive Parameter order Clean-up Passes parameters in registers register Left-to-right Routine Yes // spotted, priority use of registers pascal Left-to-right Routine Nocdecl Right-to-left Caller NO // Sight, by caller cleaning stdcall Right-to-Left Routine NosafeCall Right-to-Left Routine No, the default Register rule is the most efficient because it usually avoids creating a stack structure ( Stack frame, huh, I don't know if the explanation is reasonable?). The Pascal rule is to backward compatibility. With regard to the stack or register used by the parameters, I did the relevant practice, Function A (B: Integer): Integer; // default to registerbegin // code // returned, and restore the stack pointer END; this Compilation code Similar to Move Eax, BCALL AFUNCTION A (B: Integer): Integer; cdecl; begin // / e; 汇 代 类似 代 类似 p 类似 p 类似 p 类似 p 类似 代 类似 代 类似 代;;;;;; 类似;;