









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










Example C program
Symbol Table
Context Frame (Activation Record) Format
Function stacked stuff …….. …….. Local Variables Caller’s Frame Pointer (R5) Caller’s R7 (contains caller’s caller’s PC) Function Return Value Function Pass Value 1 …….. Function Pass Value n R R …….. “Previous R5” Local Variables
_Frame_ Function Call Implementation
Callee executes function code.
Function stacked stuff …….. …….. Local Variables Caller’s Frame Pointer (R5) Caller’s R7(contains ITS caller’s PC) Function Return Value Function Pass Value 1 …….. Function Pass Value n R R (Stack PTR) (Frame PTR) Calling program Called Program Called Program Called Program Called Program “PUSHED” on Stack By: …….. Local Variables
int *ptr; ptr is a pointer variable that points to an int type variable char *cp; cp is a pointer variable that points to a character type variable double *dp; dp is a pointer variable that points to a double type variable
What are the final values of object and ptr?
#include <stdio.h> int IntDivide(int x, int y, int *quoPtr, int remPtr); int main() { int dividend; / The number to be divided / int divisor; / The number to divide by / int quotient; / Integer result of division / int remainder; / Integer remainder of division / int error; / Did something go wrong? / printf("Input dividend: "); scanf("%d", ÷nd); printf("Input divisor: "); scanf("%d", &divisor); error = IntDivide(dividend,divisor,"ient,&remainder); if (!error) / !error indicates no error */ printf("Answer: %d remainder %d\n", quotient, remainder); else printf("IntDivide failed.\n"); } int IntDivide(int x, int y, int *quoPtr, int *remPtr) { if (y != 0) { quoPtr = x / y; / Modify *quoPtr */ remPtr = x % y; / Modify *remPtr */ return 0; } else return -1;