Exam 2 Study Guide

Picture ID is REQUIRED for all exams

Exam 2 covers the assembly language portion of the course which is presented in chapter 3 of the text (excluding sections 3.12 and 3.14).

Students are permitted to bring one 8 1/2 x 11 piece of paper to the exam which may contain any information the student chooses. In addition, this instruction set "cheat sheet" will be provided with your exam.

This guide presents topics and suggests questions which are likely to be found on the exam. This guide should not be considered comprehensive, but just a guide.

Students are encouraged to complete the practice problems provided in the text (for which solutions are also provided) as well as the homework problems from the text listed on the class schedule page.

One important skill that runs through all exam questions is beingable to read and interpret a sequence of assembly language instructions as you've done with the bomb project. This skill will be required in many forms which are outlined below.

One important skill that runs through all exam questions is beingable to read and interpret a sequence of assembly language instructions as you've done with the bomb project. This skill will be required in many forms which are discussed in more detail below.

    Registers, Memory and Arithmetic Operations

  1. Practice problems 3.1, 3.3, 3.4, 3.5
  2. Discuss the process by which an application consisting of C source file(s) and the C library becomes and executable program.
  3. Given (a) the current contents of some registers, (b) the contents of some addresses in memory, and / or (c) the state of the program stack show the new contents of the registers, memory and stack
    1. after a sequence of one or more arithmetic operations
    2. after a sequence of one or more movl instructions
  4. Compute an effective memory address using any form of simple or indexed address mode.
  5. Given assembly language instructions that represent simple arithemtic operations, be able to reconstuct the equivalent C code and vice-versa.
  6. Control Flow, Loops, Switches

  7. Practice problems 3.7, 3.9, 3.10, 3.11, 3.12, 3.13
  8. What are CF, ZF, OF, SF and how are they used to control program flow?
  9. Given assembly language instructions that represent a conditional branch, be able to reconstruct the equivalent C code and vice-versa.
  10. Given C code for a for-loop, while-loop or do-while-loop be able to write the C "go-to" version of the code.
  11. Given the assembly language code for a for-loop, while-loop or do-while-loop, reconstruct the C code for the loop.
  12. Discuss the implementation of a switch statement using a jump table.
  13. Discuss the implementation of a sparse switch statement.
  14. Discuss the use of the cmpl and setX instructions.
  15. Procedures

  16. Practice problems 3.15, 3.16
  17. Define the following terms
    1. stack frame
    2. stack pointer
    3. frame pointer
    4. program counter
  18. Show the effect of the pushl and popl on the stack.
  19. Discuss the mechanism by which a function call is performed. Discuss the responsibilities of the caller and the callee with respect to registers, return addresses, and stack frames. Be sure to consider recursive functions.
  20. Arrays

  21. Practice Problems 3.17, 3.18, 3.19
  22. Given an array declaration, 2-d array declaration, or dynamically allocated array and associated C and/or assembly language code, be able to compute the memory address of an array element, size of the array, or the type of the array.
  23. Discuss the problems resulting from C's lack of bounds checking on array indices.
  24. Discuss the differences and similarities between a 2-d array defined as int A[12][12] and as int *A[12] both from the C programmer's view point and from the assembly language viewpoint
  25. Structs and Unions

  26. Practice Problem 3.21, 3.22, 3.23
  27. Describe the differences and similarities between structs and unions.
  28. Discuss the concept of alignment and how it affects struct and union definitions.
  29. Discuss the concept of alignment and how it affects an array of structs.
  30. Compute the size in bytes for a given struct or union definition.
  31. Advanced Topics

  32. Practice Problem 3.24
  33. Give a detailed description of the "buffer overflow" problem and how to avoid it.
  34. Given C and / or assembly code used to read strings, show the effect of a buffer overflow attack on the stack, registers, etc.
  35. Give an English description of a relatively complex C variable or function declaration.