# Quiz 1 Study Guide

Quiz 1 is closed-book, closed-note, and no electronic devices are allowed. It will cover everything through the 02/8 lecture, covering the textbook through section 3.4.3, along with section 3.5.1 (lea instruction). This study guide highlights some of the major topics we have covered so far, but it is not an exhaustive list. Material from the sides and the textbook but not included here may also appear on the quiz.

### Data Representation

• Bits—our first data abstraction
• Bytes—our first grouping of bits
• important because memory is byte addressable
• i.e., the smallest addressable grouping of data
• Memory model of a computer:
• Memory can be considered as an large array of bytes
• A byte of data is located in memory by its address which is the index into this byte array
• Word Size
• Natural grouping of bytes for a given computer architecture
• Data can be read and written from memory in word-sized chunks
• Modern desktop computers have a word size of 64-bits
• Decimal number system
• Base 10
• How humans represent numbers
• Binary number system
• Base 2
• How computers represent numbers
• Base-n number systems
• The weight of each column is nk where k is the position of the number (starting from 0) and n is the base of the system
• Converting numbers to and from decimal, binary, and hexadecimal
• Converting to and from a decimal number to any base-n system
• Unsigned numbers
• Represented as binary numbers in a fixed bit-width for a given type
• Signed numbers
• Understand the differences between sign and magnitude, ones’ complement, and two’s complement systems
• Two’s complement numbers
• How signed numbers are represented inside a computer
• Only one representation of 0
• Binary arithmetic is the same for signed and unsigned numbers
• How to perform two’s complement negation
• Flip all the bits and add 1
• Weight of the MSB is -2k where k is the bit-width of the two’s complement number
• How to perform binary arithmetic for signed an unsigned numbers
• Understanding whether an operation will result in overflow
• Difference between positive overflow and negative overflow
• Positive overflow – result should have been positive but result is negative
• Negative overflow – result should have been negative but result is positive
• Sizes of C basic data types on X86_64 Linux (char, short, int, long, float, double)
• Conversions between these types
• Understanding the difference between little-endian and big-endian representation of numbers
• How are integers represented in memory
• Floating point representation of numbers
• Floating point addition and multiplication
• Calculation is performed and rounded to fit the floating point type
• Rounding modes
• How all four rounding modes work
• Round to even is the default

### Boolean and Bitwise Operations in C

• Bit-level operations: and (&), or (|), xor (^), not (~)
• How to set, clear, and flip a given bit in a bit vector
• Boolean identities
• De Morgan’s Theorem
• Logical operations: and (&&), or (||), not (!)
• Differences between logical and bit-level operations
• Shift operations: left shift («), right shift (»)
• difference between arithmetic and logical shifts
• mathematical equivalent of shifting (multiplying / dividing by 2)
• Casting
• Mapping signed to unsigned and unsigned to signed integers
• Sign extension: going from a smaller-bit integer type to a larger-bit integer type
• Truncating: going from a larger-bit integer type to a smaller-bit integer type

### 3.1 A Historical Perspective

• What is Moore’s Law and why is it important?

### 3.2 Programing Encodings

• Difference between assembly and machine language
• Understand the parts of processor state that are normally hidden from a program:
• Registers
• Program Counter
• Condition Codes
• What is `objump` and how is it used?
• How can you generate the assembly code from a c program and a binary.

### 3.3 Data Formats

• Understand how the sizes of C basic data types relate to the assembly-code suffixes (Figure 3.1 in your textbook).

### 3.4 Accessing Information

• Understand the various forms of the x86-64 operands (Figure 3.3 in your textbook).
• Given an operand be able to compute its value.
• The `mov` instruction in all its forms.

• `lea` Computes an address like the `mov` instruction but does not reference memory at all.