CS 353: Architecture and Compilers—Midterm Exam Review
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!
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)
… 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
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
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!
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
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.
Data Representation
natural numbers: based on the numeral systems above
integers (including negative): standard signed/magnitude representation (with sign bit)
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
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
)
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
Boolean Logic
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
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
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)
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”)
some simple combinatorial circuits (as in lab):
add, shift, count, increment, selection, etc.
sequential circuits can represent memory storage over time
there may be multiple consistent states, which depend on previous inputs
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”
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)
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)
Machine code and Assembly Language Programming Techniques
basic problems have to do with limited availability of space (e.g. registers) and movement of data
sometimes need to simulate operations which are not directly available
examples: maximum of two numbers, comparison of numbers, multiplication
Not on the exam! (recorded here just for posterity)
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)
approaches to subroutines (“functions” or “methods”)
use macros and simply expand the code in-line (faster)
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?
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)
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)
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)