Please read this page about taking my exams!
Exam format
 Length
 3 sheets of paper, doublesided (so, 56 pages)
 The pages are fairly dense, there are a lot of small questions
 Partial credit is given for almost all questions, even for some multiple choices
 No calculators needed
 Nothing will involve numbers > ~500
 Memorize the powers of 2… or at least, memorize how to get them
 Memorize the bits <> hex digits… or at least, memorize how to count in binary/hex
 Topic point distribution
 More credit for earlier topics (e.g. memory addresses, arrays, MIPS programming)
 Less credit for more recent ones (e.g. multiplication, division)
 More credit for things I expect you to know because of your experience (labs, project)
 Kinds of questions
 A few multiple choice and/or matching and/or “pick n“ (but not many)
 Some fill in the blanks
 mostly for vocabulary
 or things that I want you to be able to recognize, even if you don’t know the details
 Practical questions about numbers and arithmetic (i.e. math problems, basically)
 Base conversion
 Interpreting patterns of bits in different ways (signed, unsigned, bitfields, floats etc)
 2’s complement negation, addition
 Several short answer questions
 again, read that page above about answering short answer questions!!
 No writing code from scratch, but:
 tracing (reading code and saying what it does)
 debugging (spot the mistake)
 interpreting asm as HLL code (identifying common asm patterns)
 fill in the blanks (e.g. picking right registers, right branch instructions)
Things people asked about in the reviews
 Ways of representing signed numbers
 signmagnitude
 floats!!!!!!!
 one bit for sign
 bits after sign are magnitude (distance from 0)
 to negate, flip sign bit
 two’s complement
 ints!!!!!!!!!!!!
 one bit for sign, “negative place value”
 bits after sign are added to that.
 to negate, flip all bits (bitwise NOT), then add 1
 signmagnitude
 UNSIGNED numbers…
 negative numbers do not exist
 if the top bit is 1, nothing special happens
 positive signed numbers look the same as their unsigned equivalents
 e.g.
0110
== 6, in both signed and unsigned numbers
 e.g.
 Addition and subtraction
 exact same addition algorithm is used for both signed and unsigned numbers
 the thing that differs is detecting overflow
 subtraction is just addition  uses the rule
x  y == x + y == x + ~y + 1
 this weirdly still works for unsigned numbers, even though negatives “don’t exist”
 2’s complement is kind of magic, okay?

Detecting overflow. Overflow occurs in these situations:
Addition Subtraction Signed Add two numbers of same sign, get opposite sign. Same as addition, but apply rule after negating second operand. Unsigned MSB has a carry out of 1. (got an n+1bit number) MSB has a carry out of 0.
 Endianness
 it is a rule which is used to decide the order of BYTES
 when going from things bigger than a byte to bytes
 or vice versa.
 it comes up in…
 memory (cause it’s an array of bytes)
 files (also arrays of bytes)
 networking
 big endian does… the big end (most significant byte) first.
 “read it in order”
 little endian does the opposite.
 least significant byte first.
 “swap the order”
 it is a rule which is used to decide the order of BYTES
 Computer architecture stuff
 CISC vs. RISC
 Complex vs. Reduced
 CISC are for HUMANS
 they try to be easy to program for our squishy brains
 typically have few registers
 complex (multiple step) instructions
 “find a character in a string”
 “loop until this counter becomes 0”
 “access an array element at index i with size B”
 LOWER PERFORMANCE
 MORE COMPLEX CIRCUITRY/ENGINEERING
 HARD TO MAKE COMPILERS
 RISC is basically just the opposite in every category
 only CISC architecture still in widespread use is x86/x64
 most other CISC architectures are dead/legacy
 everything else in common use is RISC.
 ARM, MIPS, POWERPC, AVR
 CISC vs. RISC
 Bitwise operators
&
is bitwise AND
is bitwise OR&&
is logical and (used for conditions)
is logical or (used for conditions)<<
is left shift (multiplies by powers of 2)>>
is signed / “arithmetic” right shift (divides by powers of 2) preserves the sign bit by “smearing” it into the new spots on the left
>>>
in java is unsigned / “logical” right shift always shifts 0s into top bits
 Zero/sign extension
 when you put a value < 32 bits into a 32bit register, have to extend it
 want to preserve the same value, just represent it with more bits
lb/lh
does sign extension (copies sign bit (0 OR 1) to left)lbu/lhu
does zero extension (fills extra bits with 0s) Does not happen with
lw
because you’re loading a 32bit value into a 32bit register  same size
 when you put a value < 32 bits into a 32bit register, have to extend it