Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

NOTE: This assignment is for 32-bit code. For Ubuntu Versions 19 to 20.04, run sudo apt-get install gcc-multilib which is needed by gcc to generate

NOTE: This assignment is for 32-bit code. For Ubuntu Versions 19 to 20.04, run sudo apt-get install gcc-multilib which is needed by gcc to generate 32-bit code. Given the following t.c and ts.s files Run gcc -m32 t.c ts.s to generate a.out Run a.out one two three > myout # outputs will be in the myout file DO the requirements 1 to 4 as specified below. =============================================================================== # ts.s file: .global getebp getebp: movl %ebp, %eax ret /************* t.c file ********************/ #include  #include  int *FP; int main(int argc, char *argv[ ], char *env[ ]) { int a,b,c; printf("enter main "); printf("&argc=%x argv=%x env=%x ", &argc, argv, env); printf("&a=%8x &b=%8x &c=%8x ", &a, &b, &c); (1). Write C code to print values of argc and argv[] entries a=1; b=2; c=3; A(a,b); printf("exit main "); } int A(int x, int y) { int d,e,f; printf("enter A "); // write C code to PRINT ADDRESS OF d, e, f d=4; e=5; f=6; B(d,e); printf("exit A "); } int B(int x, int y) { int g,h,i; printf("enter B "); // write C code to PRINT ADDRESS OF g,h,i g=7; h=8; i=9; C(g,h); printf("exit B "); } int C(int x, int y) { int u, v, w, i, *p; printf("enter C "); // write C cdoe to PRINT ADDRESS OF u,v,w,i,p; u=10; v=11; w=12; i=13; //====================================================================== FP = (int *)getebp(); // FP = stack frame pointer of the C() function // FP is a 32-bit ADDRESS. Write C code to print its value in HEX (2). Write C code to print the stack frame link list as FP -> previousFP -> previousFP -> .... -> NULL (all in Hex) (3). Let p = &u; Print the stack contents from p to the frame of main(). YOU MAY JUST PRINT 128 entries of the stack contents. (4). On a hard copy of YOUR print out, identify the stack contents as LOCAL VARIABLES, PARAMETERS, stack frame pointer of each function. } Sample solutions: ~samples/LAB1pre/a.out outputs : ~samples/LAB1pre/out file 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

From Herds To Insights Harnessing Data Analytics For Sustainable Livestock Farming

Authors: Prof Suresh Neethirajan

1st Edition

B0CFD6K6KK, 979-8857075487

More Books

Students also viewed these Databases questions