Cash-back offer from May 7th to 12th, 2024: Get a flat 10% cash-back credited to your account for a minimum transaction of $50.Post Your Questions Today!

Question DetailsNormal
$ 25.00

CSC 373: Computer System I, 2015 Summer I, Assignment #3 | Complete Solution

Question posted by
Online Tutor Profile
request

CSC 373: Computer System I, 2015 Summer I, Assignment #3

Last revised 2015 July 14

Purpose:

To:

  1. Go over the basics of assembly language
  2. Go over how to use a debugger
  3. Go over the layout of an activation record

Assignment

Please do the following:

  1. Download the program called toAnalyzeCDM.zip from COL
  2. Use an sftp program like filezilla to upload it to a ctilinux machine (like ctilinux2.cstcis.cti.depaul.edu) Do not bother unzipping it on your local machine.
  3. On ctilinux1 or ctilinux2 unzip it with:

$ unzip toAnalyzeCDM.zip

  1. Do chmod u+x toAnalyze to make tell Unix that it is an executable program
  2. Analyze it with gdb: gdb toAnalyze. It has a structure like:

int bar (/* some number of args */) { /* Some number of local vars */ return( /* something */ ); } int foo (/* some number of args */) { /* Some number of local vars */ /* Some code, including call(s) to bar() */ return( /* something */ ); } int main () { /* Some number of local vars, including call(s) to foo() */ return(0); }

Answer the following:(20 Points) Assembly language understanding (1):

The assembly language for bar() is:

(gdb) disass bar Dump of assembler code for function bar: 0x08048374 <bar+0>: push %ebp 0x08048375 <bar+1>: mov %esp,%ebp 0x08048377 <bar+3>: sub $0x10,%esp 0x0804837a <bar+6>: mov 0x8(%ebp),%eax 0x0804837d <bar+9>: add $0x1,%eax 0x08048380 <bar+12>: mov %eax,-0x4(%ebp) 0x08048383 <bar+15>: mov -0x4(%ebp),%eax 0x08048386 <bar+18>: leave 0x08048387 <bar+19>: ret End of assembler dump.

Give a 1-2 sentence description of the purpose of each instruction.
I am more interested in the why than the what.

Instruction:

Purpose:

push %ebp

___________________________________________________________

mov %esp,%ebp

___________________________________________________________

sub $0x10,%esp

___________________________________________________________

mov 0x8(%ebp),%eax

___________________________________________________________

add $0x1,%eax

___________________________________________________________

mov %eax,-0x4(%ebp)

___________________________________________________________

mov -0x4(%ebp),%eax

___________________________________________________________

leave

___________________________________________________________

ret

___________________________________________________________

(10 Points) Assembly language understanding (2):

Write a C function that does what bar() does.
You won't be able to figure out the names of my parameters var(s) and local var(s); just make up your own name(s).

(20 Points) Activation Records (1):

Stop the program at its second call to bar(). When I did so I got the following:

(gdb) break foo Breakpoint 1 at 0x804838e (gdb) break bar Breakpoint 2 at 0x804837a (gdb) run Starting program: /home/CSTCIS/jphillips/classes/csc373/20145-4SumI/Assign3/toAnalyzeCDM Breakpoint 1, 0x0804838e in foo () (gdb) c Continuing. Breakpoint 2, 0x0804837a in bar () (gdb) c Continuing. Breakpoint 2, 0x0804837a in bar () (gdb) stepi 0x0804837d in bar () (gdb) stepi 0x08048380 in bar () (gdb) stepi 0x08048383 in bar () (gdb) stepi 0x08048386 in bar () (gdb) info reg . . . esp 0xbfffe898 0xbfffe898 ebp 0xbfffe8a8 0xbfffe8a8 . . . eip 0x8048386 0x8048386 <bar+18> . . . (gdb)

Write the activation record for bar() when %eip gets to 0x08048386.
Under Value put the numeric value held at that address.
Under Purpose put one of the following:

    1. not part of bar()'s activation record
    2. argument to bar()
    3. the address in foo() to which eip should return
    4. the stored ebp address for foo()
    5. local variable to bar()

Address:

Value:

Purpose:

0XBFFF,E8C8

_ __________

___________

0XBFFF,E8B4

___________

___________

0XBFFF,E8B0

___________

___________

0XBFFF,E8AC

___________

___________

ebp -->

0XBFFF,E8A8

___________

___________

0XBFFF,E8A4

___________

___________

0XBFFF,E8A0

___________

___________

0XBFFF,E89C

___________

___________

(10 Points) Assembly language understanding (3):

What are the values that foo() obtains as arguments from main()?
Where are they on the stack?
Give an offset from ebp from within foo()'s activation record.

(10 Points) Assembly language understanding (4):

How many local variables does foo() have?
Where are they on the stack?
Give an offset from ebp from within foo()'s activation record.

(20 Points) Debugger usage (1):

foo() has a loop. Inside of foo() what are the values that both its parameters and local variables take on when eip is at address 0x080483bb?

Iteration:

1st param?

2nd param?

1st local var?

1

________

________

________

2

________

________

________

3

________

________

________

4

________

________

________

(5 Points) Debugger usage (2):

What value does foo() return to main()?

(5 Points) Assembly language understanding (5):

foo() calls bar(). bar() starts at address 0x0804,8374. If you look at the machine code for foo()'s call to bar(), however, you'll see that the actual number in the function call is 0xFFFF,FFCC.

08048388 <foo>: . . . 80483a0: 89 04 24 mov %eax,(%esp) 80483a3: e8 cc ff ff ff call 8048374 <bar> 80483a8: 89 c2 mov %eax,%edx . . .

    1. What to what number did the CPU add with 0xFFFF,FFCC to get the address of bar(), 0x0804,8374?
    2. Do this addition. Compute 0x0804,8374.

Last revised 2015 July 14

Purpose:

To:

  1. Go over the basics of assembly language
  2. Go over how to use a debugger
  3. Go over the layout of an activation record

Assignment

Please do the following:

  1. Download the program called toAnalyzeCDM.zip from COL
  2. Use an sftp program like filezilla to upload it to a ctilinux machine (like ctilinux2.cstcis.cti.depaul.edu) Do not bother unzipping it on your local machine.
  3. On ctilinux1 or ctilinux2 unzip it with:

$ unzip toAnalyzeCDM.zip

  1. Do chmod u+x toAnalyze to make tell Unix that it is an executable program
  2. Analyze it with gdb: gdb toAnalyze. It has a structure like:

int bar (/* some number of args */) { /* Some number of local vars */ return( /* something */ ); } int foo (/* some number of args */) { /* Some number of local vars */ /* Some code, including call(s) to bar() */ return( /* something */ ); } int main () { /* Some number of local vars, including call(s) to foo() */ return(0); }

Answer the following:(20 Points) Assembly language understanding (1):

The assembly language for bar() is:

(gdb) disass bar Dump of assembler code for function bar: 0x08048374 <bar+0>: push %ebp 0x08048375 <bar+1>: mov %esp,%ebp 0x08048377 <bar+3>: sub $0x10,%esp 0x0804837a <bar+6>: mov 0x8(%ebp),%eax 0x0804837d <bar+9>: add $0x1,%eax 0x08048380 <bar+12>: mov %eax,-0x4(%ebp) 0x08048383 <bar+15>: mov -0x4(%ebp),%eax 0x08048386 <bar+18>: leave 0x08048387 <bar+19>: ret End of assembler dump.

Give a 1-2 sentence description of the purpose of each instruction.
I am more interested in the why than the what.

Instruction:

Purpose:

push %ebp

___________________________________________________________

mov %esp,%ebp

___________________________________________________________

sub $0x10,%esp

___________________________________________________________

mov 0x8(%ebp),%eax

___________________________________________________________

add $0x1,%eax

___________________________________________________________

mov %eax,-0x4(%ebp)

___________________________________________________________

mov -0x4(%ebp),%eax

___________________________________________________________

leave

___________________________________________________________

ret

___________________________________________________________

(10 Points) Assembly language understanding (2):

Write a C function that does what bar() does.
You won't be able to figure out the names of my parameters var(s) and local var(s); just make up your own name(s).

(20 Points) Activation Records (1):

Stop the program at its second call to bar(). When I did so I got the following:

(gdb) break foo Breakpoint 1 at 0x804838e (gdb) break bar Breakpoint 2 at 0x804837a (gdb) run Starting program: /home/CSTCIS/jphillips/classes/csc373/20145-4SumI/Assign3/toAnalyzeCDM Breakpoint 1, 0x0804838e in foo () (gdb) c Continuing. Breakpoint 2, 0x0804837a in bar () (gdb) c Continuing. Breakpoint 2, 0x0804837a in bar () (gdb) stepi 0x0804837d in bar () (gdb) stepi 0x08048380 in bar () (gdb) stepi 0x08048383 in bar () (gdb) stepi 0x08048386 in bar () (gdb) info reg . . . esp 0xbfffe898 0xbfffe898 ebp 0xbfffe8a8 0xbfffe8a8 . . . eip 0x8048386 0x8048386 <bar+18> . . . (gdb)

Write the activation record for bar() when %eip gets to 0x08048386.
Under Value put the numeric value held at that address.
Under Purpose put one of the following:

    1. not part of bar()'s activation record
    2. argument to bar()
    3. the address in foo() to which eip should return
    4. the stored ebp address for foo()
    5. local variable to bar()

Address:

Value:

Purpose:

0XBFFF,E8C8

_ __________

___________

0XBFFF,E8B4

___________

___________

0XBFFF,E8B0

___________

___________

0XBFFF,E8AC

___________

___________

ebp -->

0XBFFF,E8A8

___________

___________

0XBFFF,E8A4

___________

___________

0XBFFF,E8A0

___________

___________

0XBFFF,E89C

___________

___________

(10 Points) Assembly language understanding (3):

What are the values that foo() obtains as arguments from main()?
Where are they on the stack?
Give an offset from ebp from within foo()'s activation record.

(10 Points) Assembly language understanding (4):

How many local variables does foo() have?
Where are they on the stack?
Give an offset from ebp from within foo()'s activation record.

(20 Points) Debugger usage (1):

foo() has a loop. Inside of foo() what are the values that both its parameters and local variables take on when eip is at address 0x080483bb?

Iteration:

1st param?

2nd param?

1st local var?

1

________

________

________

2

________

________

________

3

________

________

________

4

________

________

________

(5 Points) Debugger usage (2):

What value does foo() return to main()?

(5 Points) Assembly language understanding (5):

foo() calls bar(). bar() starts at address 0x0804,8374. If you look at the machine code for foo()'s call to bar(), however, you'll see that the actual number in the function call is 0xFFFF,FFCC.

08048388 <foo>: . . . 80483a0: 89 04 24 mov %eax,(%esp) 80483a3: e8 cc ff ff ff call 8048374 <bar> 80483a8: 89 c2 mov %eax,%edx . . .

    1. What to what number did the CPU add with 0xFFFF,FFCC to get the address of bar(), 0x0804,8374?
    2. Do this addition. Compute 0x0804,8374.
Available Answer
$ 25.00

[Solved] CSC 373: Computer System I, 2015 Summer I, Assignment #3 | Complete Solution

  • This solution is not purchased yet.
  • Submitted On 23 Jul, 2015 07:26:45
Answer posted by
Online Tutor Profile
solution
push %ebp ______ It stores the previous base pointer (ebp) and set the base pointer as it was the top of the stack _______________________ mov %esp,%ebp _______ all the stack contents is saved down the stack, so the function can push/pop in the stack. ____________________________ su...
Buy now to view the complete solution
Other Similar Questions
User Profile
Homew...

CSC 373: Computer System I, 2015 Summer I, Assignment #3 | Complete Solution

Push %ebp ______ It stores the previous base pointer (ebp) and set the base pointer as it was the top of the stack _______________________ mov %esp,%ebp _______ all the stack contents is saved down the stack, so the function ...
User Profile
Exper...

CSC 373: Computer System I Assignment #2 | Complete Solution

This Tutorial is rated A+ previously,if you have any questions regarding this tutorial then you can contact me....

The benefits of buying study notes from CourseMerits

homeworkhelptime
Assurance Of Timely Delivery
We value your patience, and to ensure you always receive your homework help within the promised time, our dedicated team of tutors begins their work as soon as the request arrives.
tutoring
Best Price In The Market
All the services that are available on our page cost only a nominal amount of money. In fact, the prices are lower than the industry standards. You can always expect value for money from us.
tutorsupport
Uninterrupted 24/7 Support
Our customer support wing remains online 24x7 to provide you seamless assistance. Also, when you post a query or a request here, you can expect an immediate response from our side.
closebutton

$ 629.35