CS140 Final Exam Review

The final exam WILL be on Thursday, May 17, from 5:15 - 7:30 in MH 234. If you have a scheduling conflict, then probably your other teacher has misread the final exam schedule.

Format

The exam will consist of 3 - 5 problems. Most of the problems will be similar to the written parts of the homework assignments:

Translate 420 into binary, hex, and octal
Translate 0x420 into binary, octal, and decimal

What's in reg5 after executing:
   reg5 = reg0 + reg1;
   reg5 = reg0 << reg1;
   reg5 = ~reg0;

What's the value of the expression:
   *p + 1
   *(p + 1)
   p[1]

cc[if (a < b) a = b + 2; else a = a * a; ]

etc.

There will be at least one C-- program to write: Write a C-- program that reads three numbers, a, b, and c, then prints them in sorted order. Your program should implement and call a C-- function named max that expects two arguments passed on the stack, then returns the larger of the two to the caller. You may also be asked to write a program that uses an inline assembly block: Write a program that reads a number, n, then computes and prints the sum of squares of all odd numbers less than or equal to n. Only the I/O part of your program should be written in C--. The rest should be implemented by an inline assembly block. Topics Converting between bin, hex, octal, and decimal.

Integer representation systems (for n = 4, 5, 8, 16, or 32)
   n-bit sign-magnitude system
   n-bit ones complement
   n-bit twos complement

C-- Operations
   arithmetic
      overflow
      carry out
   bitwise
   boolean
   shifts (right & left)
      arithmetic
      logical
      rotate

Alignment and byte order

Addressing modes
   Immediate
   Absolute
   Direct
   Indirect
   Base-Index

Pointers and Arrays in C
   Array-pointer duality
   & operator
   * operator
   declaring pointers and arrays
   Note: heap allocation & deallocation will not be on the final

Instruction Sets
   Classifying C instructions
   Translating C instructions into C-- instructions

Call and Return
   How does the CPU execute call?
   How does the CPU execute return?
   How does a caller pass parameters to a procedure?
   How does a procedure save and restore the caller's state?
      Why is this necessary? Give an example.
   Recursion
   Note: interrupts will not be covered on the final.

I80x86 Assembly Programming
   _asm { ... }
   The I80x86-- instruction set:
      mov ARG1, ARG2
      add ARG1, ARG2
      sub ARG1, ARG2
      cmp ARG1, ARG2
      ja LABEL
      jb LABEL
      jae LABEL
      jbe LABEL
      jmp LABEL
   The I80x86-- addressing modes (examples)
      mov eax, 42
      mov eax, reg0
      mov eax, mem[42]