Home

Definition of calling sequence

In a program when a subroutine call occurs, an agreement between the calling routine and the called routine on how arguments will be passed and in what order, how values will be returned, and which routine will handle any necessary housekeeping (such as cleaning up the stack). The calling sequence becomes important when the calling and called routines were created with different compilers or if either was written in assembly language. Two common calling sequences are the C calling sequence and the Pascal calling sequence. In the C calling sequence, the calling routine pushes any arguments included in the call on the stack in reverse order (right to left) and performs any stack cleanup; this permits a varying number of arguments to be passed to a given routine. In the Pascal calling sequence, the calling routine pushes any included arguments on the stack in the order in which they appear (left to right), and the called routine is expected to clean up the stack.

Computer Science