Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How do you write the activation record for a function? I thought that I was usin

ID: 3762403 • Letter: H

Question

How do you write the activation record for a function? I thought that I was using the right commands to get the value that is at and address but the values don't look right. If anyone could explain how to get the activation record and how to print the values and to find the purpose of those values Thanks!

This is my table that I need to fill in. How do I get these answers?:

Address:

Value:

Purpose:

0xBFFF,EEDC

0xBFFF,EED8

0xBFFF,EED4

0xBFFF,EED0

Ebp

0xBFFF,EECC

0xBFFF,EEC8

0xBFFF,EEC4

0xBFFF,EEC0

0xBFFF,EEBC

Here is the disassembled code:

0x08048389 <foo+0>:   push   %ebp
0x0804838a <foo+1>:   mov    %esp,%ebp
0x0804838c <foo+3>:   sub    $0x18,%esp
0x0804838f <foo+6>:   movl   $0x0,-0x4(%ebp)
0x08048396 <foo+13>:   movl   $0x1,-0x8(%ebp)
0x0804839d <foo+20>:   jmp    0x80483b8 <foo+47>
0x0804839f <foo+22>:   mov    -0x8(%ebp),%eax
0x080483a2 <foo+25>:   mov    %eax,0x4(%esp)
0x080483a6 <foo+29>:   mov    0x8(%ebp),%eax
0x080483a9 <foo+32>:   mov    %eax,(%esp)
0x080483ac <foo+35>:   call   0x8048374 <bar>
0x080483b1 <foo+40>:   add    %eax,-0x4(%ebp)
0x080483b4 <foo+43>:   addl   $0x1,-0x8(%ebp)
0x080483b8 <foo+47>:   cmpl   $0x3,-0x8(%ebp)
0x080483bc <foo+51>:   jle    0x804839f <foo+22>
0x080483be <foo+53>:   mov    -0x4(%ebp),%eax
0x080483c1 <foo+56>:   leave
0x080483c2 <foo+57>:   ret   

And this is the register info:

eax            0xf   15
ecx            0xbfffeb30   -1073747152
edx            0x1   1
ebx            0x264ff4   2510836
esp            0xbfffeac8   0xbfffeac8
ebp            0xbfffead8   0xbfffead8
esi            0x2f1ca0   3087520
edi            0x0   0
eip            0x8048387   0x8048387 <bar+19>
eflags         0x206   [ PF IF ]
cs             0x73   115
ss             0x7b   123
ds             0x7b   123
es             0x7b   123
fs             0x0   0
gs             0x33   51

Address:

Value:

Purpose:

0xBFFF,EEDC

0xBFFF,EED8

0xBFFF,EED4

0xBFFF,EED0

Ebp

0xBFFF,EECC

0xBFFF,EEC8

0xBFFF,EEC4

0xBFFF,EEC0

0xBFFF,EEBC

Explanation / Answer

e identified several data that must be kept for each call of a C function or Java method:

All these data form the activation record, or AR, for the procedure call. Every active procedure call must have its own AR somewhere in memory.

Compilers will emit a prologue at the beginning of the compiled assembly language of each procedure. A typical prologue (x86 assembly):

The purpose of a prologue is to initialize the activation record of the called procedure.

The first instruction pushes the caller's %ebp value onto the stack, decrementing %esp by 4.

The second instruction sets %ebp to the current value of %esp. This effectively makes the called procedure's activation record start at the address where the caller's activation record ends.

The third instruction "stretches" the new activation record to contain enough room for all of the local variables that the procedure will use.

accessing Argument Values

The argument values passed to the called procedure are pushed onto the activation record of the calling procedure: thus, they are in the caller's activation record, and are available at positive offsets from the current procedure's base pointer (%ebp register). Because the saved %ebp and the return address each occupy 8 bytes, the first argument value is available at the address %ebp + 8, the second at the address %ebp + 12, etc. (This assumes that the parameters each occupy 4 bytes.

Note that arguments are pushed onto the caller's activation record in right-to-left order. So, a C procedure call

would be compiled into code something like the following

The last instruction is needed to clear the arguments passed to the procedure off of the caller's activation record.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote