V
CS 353: Architecture and Compilers—Midterm Exam Review
V
Important note!
*
click on the triangles to the left to expand or contract sections!
*
use the text size feature in your browser to make this text larger and more readable!
V
About the exam
*
the midterm exam will take place on Friday, October 16th
*
the instructor will be available from Zoom at the usual lecture time and place (Ford 302 at 2:15pm)
V
… but most people will take the exam remotely
*
The exam will be provided as a PDF file via email; you should fill out the exam with a PDF editor or write your answers in a text file
*
in either case, please email the exam to the instructor when you are done
*
the exam will be designed so that you should be able to complete it in about an hour
*
but we will “overflow” into the lab time, if necessary (or just helpful)
*
you will not have access to books, notes, computers, networks or neighbors during the exam (you may use scratch paper)
*
you are encouraged to ask your instructor for clarifications during the exam, if necessary, via Zoom
V
In preparing for the exam, you should consult:
*
your notes from lecture and lab—these are likely to be especially helpful
*
Look at the course homepage for topics, diagrams, etc.
*
See especially items in the News section and the handout archive (which has some sample problems!)
*
… and also especially the lab assignments linked from the home page, as well as your programs
V
Format: the exam will consist of several kinds of questions, typically:
*
10-12 True-or-False questions at 1-2 points each
*
8-10 short answer questions at 4-6 points each
*
2-3 longer answer questions at 8-15 points each
*
These review notes are not exhaustive, but are meant as a guide to coverage—see above sources for details!
V
Numeral systems: binary, decimal, hexadecimal, etc.
*
basic concepts: bases, places, valuation
*
numerals can be viewed as the coefficients of a polynomial—the base is the “unknown”
*
what is the highest digit used in base n? how many digits are used in base n?
*
how many things can we count/represent with n digits in base b? what is the highest number we can represent?
*
ordering of the numerals: odometer style
V
fast conversion between bases (Horner's left-to-right accumulating technique; the role of div and mod)
*
(for each digit, starting with a total of zero: multiply current total by base and add next digit)
*
addition algorithms on strings of bits (or other digits): carries, etc.
V
Data Representation
*
natural numbers: based on the numeral systems above
*
integers (including negative): standard signed/magnitude representation (with sign bit)
V
two's complement: conversion to and from, use in addition, checking for overflow
*
high-order bit always tells sign (no negative zero)
*
asymmetric coverage: highest magnitude negative number is one greater
*
for negative numbers, read zeros as ones and vice versa (but also then off by one)
*
overflow only if sign of result differs from common sign of arguments
V
letters, symbols, etc.: ASCII code (7 bits, plus maybe one parity bit) versus Unicode (complex, multi-byte, “encoded codes”)
*
some properties of ASCII codes for letters: each set in order, upper and lower case separated by 32
*
you should understand the UTF-8 encoding technique (see the Wikipedia description)
V
sound, graphics, etc.: you should understand basic principles of how various data are represented digitally (in binary, especially)
*
see the old lecture on Data Represntation from the course homepage
V
Boolean Logic
V
we consider functions (and expressions) over a two-valued (boolean) domain of truth values, 0/1 or T/F
*
how many combinations are there of a certain number of arguments?
*
how many functions (with a given number of arguments) are there?
*
standard operators: AND, OR, NAND, NOR, XOR, XNOR, NOT
V
use of truth tables to determine the valuation of expressions
*
use binary numeral “odometer” ordering to cover the possible values of variables
*
to write a formula for a truth table, use disjunction of conjunctions technique
V
Gates and Circuits
*
represent 0/false as either no voltage or lower voltage, and 1/true as higher voltage
*
transistor allows electrical control of “switching” a signal: either ON to enable flow or ON to prevent flow
*
can build basic gates (AND, OR, etc.) from a few transistors (e.g., in serial or parallel)
V
we build circuits by connecting gates with wires, according to the hierarchical structure of the expression
*
real physical implementation requires some attention to timing, amplification, etc.
*
combinatorial versus sequential circuits (the latter may include feedback “loops”)
V
some simple combinatorial circuits (as in lab):
*
add, shift, count, increment, selection, etc.
V
sequential circuits can represent memory storage over time
*
there may be multiple consistent states, which depend on previous inputs
V
Computer Organization
*
combinations of circuits are used to build memory, control, ALU
*
components are connected by busses: groups of wires (under some communication protocol) with control lines to ”direct traffic”
V
memory: a hierarchy from registers to cache to RAM to disk (network can be seen as especially slow-but-large external storage)
*
(from closer/fewer/faster/more expensive to farther/more/slower/cheaper)
*
the control unit decodes instructions, selects an operation, and dispatches arguments/results
*
ALU (arithmetic-logic unit) performs actual data transformation (e.g., ADD, SHIFT)
V
Instruction Set Architecture and Assembly Programming
*
program versus data storage: both in RAM, but conceptually separate
*
issues of word size (trade-off with richness of instruction set)
*
typically choose some fixed-width binary “word size” (e.g., 8, 12, 16 or 32 bits)
*
assembler directives: not actual instructions on the machine, just to the assembler program (e.g., CONST on the PC-231)
V
Machine code and Assembly Language Programming Techniques
*
basic problems have to do with limited availability of space (e.g. registers) and movement of data
V
sometimes need to simulate operations which are not directly available
*
examples: maximum of two numbers, comparison of numbers, multiplication
V
Not on the exam! (recorded here just for posterity)
V
realistic modern architectures include many more features:
*
pipelining: execute several instructions in parallel in stages (fetch, execute, write)
*
hardware-based stacks (for expression evaluation, method calls)
V
approaches to subroutines (“functions” or “methods”)
*
use macros and simply expand the code in-line (faster)
V
use a jump to a secondary set of instructions in memory
*
how do we get back to the calling address?
*
how do we communicate parameters? (in registers)
*
do we “save” the values in other registers for the caller, or only use a special subset of registers?
V
macro assemblers: allow abbreviation of instruction sequences as a single “pseudo-instruction”
*
issue: how do you avoid over-use of registers? (those used in the macro and those in the calling context)
*
issue: multi-line macros may change line numbering (labels thus become crucial)
*
issue: how are “arguments”/parameters to macros specified?
*
issue: can one macro “call” another? (i.e. recursive macros)
V
simulating arrays
*
use consecutive RAM locations to store array values
*
get continuing access to array elements by holding a RAM address in a register and incrementing (up or down)
*
array access may depend on the size of array elements (might be more or less than one word of RAM)
V
addressing modes: how are operands specified?
*
implicit: the location of the data is part of the specification of the opcode (e.g. DATA)
*
immediate: data is encoded in the instruction itself (e.g. SET)
*
direct: number of register or address of RAM is encoded in the instruction (e.g. ADD, JUMP)
*
indirect: a register or RAM location holds the address of the actual data (e.g. LOAD, JPIF)
*
indexed: some architectures allow an “array address” and an index to be combined (not in PC-231)