Computer Organization - Exam 1 Topic List
Exam date:
Thursday, March 28, 2013
Last updated
2013/03/22 16:14:57
Important Notes
I will provide you with a copy of the MIPS reference card found at
the front of your textbook to use during this exam.
You do not need to bring your own copy of the card.
You are NOT allowed to use a calculator on any questions that
specifically ask you to convert numbers from one base to another,
unless the calculator is a simple four-function one.
TEXT CHAPTERS
- Chapter 1: Computer Abstractions and Technology
- Chapter 2: Instructions: Language of the Computer
- Chapter 3: Arithmetic for Computers
- Appendix B: Assemblers, Linkers, and the SPIM Simulator
LECTURE NOTES
- Topic 1: Overview
- Topic 2: Information Representation I: Characters and Integers
- Topic 3: Instructions I: Arithmetic and Data Movement
- Topic 4: Instructions II: Control Flow
TOPICS
History
- why we care about computer organization
- philosophical view: should cover all principles underlying CS
- practical view: HW defines what SW does, so CompOrg helps us understand how SW works
- language levels
- high-level language (HLL)
- assembly language (ASM)
- machine language (ML)
- HLL as abstraction of machine-level operations
- relative power of each statement
- translation: HLL to ASM, ASM to ML
- internal representation of information
- analog vs. digital
- reason for using binary
- why
int isn't integer, float isn't real
- classic elements of computer organization
- memory, CPU (control unit, processor unit), input/output devices
- components: registers, buses, arithmetic unit, etc.
- datapath vs. control
- how ICs are made
- silicon wafers
- dies
- basics of the process: apply layers, testing, packaging, testing
- problems in manufacturing: defects
- costs drop over time (the "learning curve")
- concept of generations of computers
Information Representation: General
- internal form: binary
- must encode information to hold it in memory
- instructions
- data - integer, floating point, non-numeric
- size of thing in memory determines range of possible values
(n bits yields 2n representations):
| Bytes |
Bits |
# of representations |
| 1 |
8 |
256 |
| 2 |
16 |
65,536 |
| 4 |
32 |
4,294,967,296 |
Information Representation: Non-Numeric
- typically, characters
- mapping of bit patterns to characters defines a character set
- common character sets: ASCII (7-bit), BCD (6-bit), EBCDIC (8-bit), Unicode (16-bit)
- order of mappings defines the collating sequence for the set
- MIPS instructions for working with characters:
lb rt,n(rs) load byte, sign-extends to 24 bits
lbu rt,n(rs) load byte unsigned, zero-extends to 24 bits
sb rt,n(rs) store byte, stores low-order 8 bits
Information Representation: Integer
- numeric data
- representation of an abstract concept
- we represent "numbers" as a sequence of numerals
- numerals encode values using positional representation
- positional representation
- digits have values, as do positions
- "meaning" of a digit is its value multiplied by the value of its position
- important concept: any number can be represented in any radix (base) as a sequence of numerals
- common radix values:
- decimal: powers of 10, digits 0-9
- binary: powers of 2, digits 0-1
- octal: powers of 8, digits 0-7
- hexadecimal: powers of 16, digits 0-9 and A-F
- positional values are powers of the radix (base) of the representation
- positions to left of "radix point" are positive powers of the radix
- positions to right of "radix point" are negative powers of the radix
- converting numbers from one representation to another
- other base to decimal: use multiplication-based algorithm
- decimal to other base: use division-based algorithm
- between power-of-two bases (2, 8, 16, etc.): use bit groupings
- representing numeric data
- bits are numbered from 0 (rightmost, least significant) to N-1 (leftmost, most significant)
- rightmost byte is least significant (LSB)
- leftmost byte is most significant (MSB)
- MIPS stores these in big-endian form
- halfwords must be aligned on even boundaries
- words must be aligned on multiple-of-four boundaries
- all use fixed-size representations (1, 2, 4, or 8 bytes)
- all have the potential for overflow (result from operation won't fit in the representation)
- unsigned integers
- easy - interpret N-bit value as an unsigned binary value
- arithmetic is simple
- signed integers
- must encode sign along with value
- encoding schemes:
- sign-magnitude
- most significant bit is sign, other bits are (unsigned) magnitude
- arithmetic is complicated (esp. for differently-signed operands)
- two representations for 0 (positive 0, negative 0)
- diminished radix complement
- in binary, this is called one's complement
- representation is rn-1 - magnitude for n bits
- arithmetic is easier than with sign-magnitude, but still tricky (must use end-around-carry if generate a carry of 1 off the left end of the result)
- still two representations for 0
- radix complement
- in binary, this is called two's complement
- representation is rn - magnitude for n bits
- arithmetic is trivial - can ignore any carry off the left end
- only one representation for 0
- fundamental concept behind encoding: "value" of bit pattern
depends on the encoding being used
- ex:
0110 in a four-bit representation
- ex:
1011 in a four-bit representation
- 11 if unsigned
- -3 in sign-magnitude
- -4 in one's complement
- -5 in two's complement
- converting between different-sized representations
- two forms:
- sign-extended (complement schemes)
- used for signed quantities; result has same sign as original
- smaller to larger: fill on left with copies of original leftmost bit
- larger to smaller: harder - may lose significant digits, so magnitude may change
- zero-extended
- used for unsigned quantities
- smaller to larger: fill on left with zeroes
- easy when converting smaller to larger representation (just replicate zeroes)
- larger to smaller: again, may lose significant digits, so magnitude may change
- can convert smaller to larger with load instructions:
lb rt,n(rs) load byte, sign-extends to 32 bits
lbu rt,n(rs) load byte unsigned, zero-extends to 32 bits
lh rt,n(rs) load halfword, sign-extends to 32 bits
lhu rt,n(rs) load halfword unsigned, zero-extends to 32 bits
- can also do sign or zero extension with shift instructions;
- left logical shift:
sll rd,rs,shamt and sllv rd,rs,rt
- right logical shift:
srl rd,rs,shamt and srlv rd,rs,rt
- right arithmetic shift:
sra rd,rs,shamt and srav rd,rs,rt
Instructions
- concept: instruction set architecture (ISA)
- assembly language vs. machine language
- competing design philosophies
- CISC: Complex Instruction Set Computing (e.g., VAX, x86, 680x0)
- RISC: Reduced Instruction Set Computing (e.g., MIPS, SPARC, PowerPC)
- RISC design principles
- simplicity favors regularity
- smaller is faster
- make the common case fast
- good design demands good compromise
- concept: "word" of storage (32 bits)
- basic memory organization
- bytes, halfwords, words, doublewords
- addresses
- endianness: big- vs. little-endian
- alignment concept
- register vs. variables
- numbers: $0 through $31
- names: $zero, $at, $v0, $v1, $a0-$a3, $t0-$t9, $s0-$s7, $k0, $k1,
$gp, $sp, $fp, $ra
- restrictions on use: $zero, $at, $k0, $k1, $gp, $sp, $fp, $ra
- statement syntax: label, operation, operands, comment
- types of MIPS statements
- arithmetic: add, addi, sub, etc.
- data movement: lw, sw
- pseudo: move, la, li
- unconditional transfer: j, jr, jal, jalr
- conditional transfer: bne, beq
- condition testing: slt, slti
- assembler directives: .word, .byte, .ascii, etc.
- fundamental concept: everything is binary
- no difference between instructions and data
- "meaning" of a bit pattern determined by how you use it
- data structures
- arrays
- sequences of words
- subscript vs. offset into the array
- structures
- sequences of bytes forming fields
- byte offsets to beginning of fields
- linked lists
- nodes are structures
- "link" is the address of the next node in the list
- operands
- registers: $r
- immediates: n
- memory: n($r), effective address (EA); displacement addressing
- destination address for transfers
- implementing control structures
- basic concept: condition tests and conditional branches
- if-then-else, switch
- for, while loops; loop variations (pretest, posttest, etc.)
- procedure/function calls
- implementing pseudo-instructions
- assembler selects appropriate "real" instructions
- may involve more than one instruction
- examples: move, li, la
- implement using: lui, ori, $at
- subprogram linkage
- register usage
- return address in $ra
- parameters in $a0 through $a3
- return values in $v0 (and $v1 if needed)
- freely usable: $t0 through $t9
- must save/restore: $s0 through $s7
- issues when a called routine calls another routine
- use of runtime stack
- stack frame concept, $sp, $fp
- extra parameters
- register save area
- local variables