Recent Changes - Search:

Instructor

  • who: Michael Swift
  • where: Room 7369
  • when: Monday 11-12, Thursday 1:30-2:30
  • email: swift 'at' cs.wisc.edu
  • TAs

Lecture:

HomePage

Resources

edit SideBar

ASMReview

  • Given this code:
   int foo(int a, int b) 
   {
     Int c;
     char d[8];
   }
   int main(int argc, char * argv[])
   {
     Int e = atoi(argv[1};
     foo(argc, e)
   }
  1. Draw the stack contents while executing in foo(), with the base of the stack being the address pointed to be the frame pointer when executing main()
  • Stacks on x86 grow down.
    1. Suppose stacks grew up instead. Draw the same stack as for question 1, but with stacks that grow up.
    2. The stack pointer currently points to the last used byte in a function; anything below that address is not in use. Reading from the stack address returns the most recently pushed data. How does this change if stacks grow up?
  • Suppose you have the code below:
   int foo(int a, int b)
   {
     printf("A = d\n", a, b);
     return(bar(a,b));
   }

   int bar(int c, int d)
   {
     return(c + d);
   }
Because the last thing foo() does is call bar(), how could you optimize the assembly code for foo() to make the program execute faster?
Edit - History - Print - Recent Changes - Search
Page last modified on February 26, 2019, at 06:54 PM