In C and C++, the calling convention is backwards, i.e. the variable declared last will be pushed into the stack first.
Whereas in PASCAL the calling convention is just the opposite of that of C and C++, i.e. the variable declared first is pushed into the stack first.
So in PASCAL, the variables are called in order whereas in C and C++ they are called in opposite order.
Following example shows the call stack of a function void funct(int i, int j) written in C/C++ and PASCAL.
C/C++ call
Address | Stack frame | Value |
0xA0008 | j | 30 |
0xA0004 | i | 20 |
0xA0000 | return address of funct() | code address of next to call |
PASCAL call
Address | Stack frame | Value |
0xA0008 | i | 20 |
0xA0004 | j | 30 |
0xA0000 | return address of funct() | code address of next to call |
About our authors: Team EQA
You have viewed 1 page out of 252. Your C learning is 0.00% complete. Login to check your learning progress.