Parameter Coordination

Table 20.1 lists the main conventions on passing parameters to the procedure. Notice that in all Assembly programs presented in this book, the stdcall type for passing parameters was specified. However, this convention isn't used practically because parameters are passed and retrieved explicitly without the translator's help. When dealing with high-level languages, this must be taken into account. Therefore, the programmer must know how calling conventions work.

Table 20.1: Calling conventions

Convention

Parameter

Clearing the stack

Register

Pascal (the convention adopted in Pascal)

From left to right

Procedure

None.

Register (register or fast calling convention)

From left to right

Procedure

Three registers are employed ( EAX, EDX , and ECX ); if these registers are not sufficient for passing all parameters, then the remaining parameters are passed through the stack.

Cdecl (C convention)

From right to left

Calling program

None.

Stdcall (standard call)

From right to left

Procedure

None.

This table clearly explains the conventions on calling functions and on passing parameters, so it doesn't need additional clarification .

I'd like to draw your attention to another important aspectnamely, the types of return values. In Assembly language, everything is simple: The value returned in the EAX register can be either a number or a pointer to some variable or structure. If the return value has the WORD data type, it is passed in the least significant word of the EAX register. However, if you are dealing with the C programming language, you should pay attention to the problem of type casting. Type casting can be considered an art or a science, but unfortunately , in this book I can't pay it the attention that it deserves .



The Assembly Programming Master Book
The Assembly Programming Master Book
ISBN: 8170088178
EAN: 2147483647
Year: 2004
Pages: 140
Authors: Vlad Pirogov

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net