Computer Science 315 Lecture Notes


Table of Contents

Preface: Policies, Practices and Expectations
1. Using the Online Notes
2. Homework Policy
3. Extra Credit Sweepstakes
1. Preparing for a Career
1.1. Motivation
1.2. What is Success?
1.3. The Character of Success
1.4. Learning to Succeed
1.5. Success in College
1.6. Success in the Workplace
1.7. Homework
2. Enough Unix to Make You Dangerous
2.1. Motivation
2.2. Logging In
2.3. Tools
2.4. Unix Basics
2.5. The Unix Command Line
2.6. Homework
3. Software Development
3.1. Motivation
3.2. Language Types
3.3. Engineering Product Life Cycle
3.4. Homework
4. Data Representation
4.1. Motivation
4.2. Orders of Magnitude
4.3. Numeric Limitations of Computers
4.4. Fixed Point Number Systems
4.5. Binary Data Representation
4.6. The Arabic Numeral System
4.7. Binary Fixed Point
4.8. Converting to and from Decimal
4.9. Binary/Octal/Hexadecimal Conversions
4.10. Unsigned Binary Integers
4.11. Sign-Magnitude
4.12. One's complement
4.13. Two's Complement
4.14. Biased Notation
4.15. Hex and Octal with Signed Numbers
4.16. Floating Point
4.17. IEEE Floating Point Formats
4.18. Character Storage
4.19. Homework
5. The MIPS Architecture
5.1. Motivation
5.2. Hardware and Program Execution
5.3. The MIPS Register Files
5.4. MAL: MIPS Assembly Language
5.5. Architecture Classifications
5.6. The Instruction Cycle
5.7. MIPS Instruction Code Formats
5.8. Homework
6. SPIM, the MIPS Simulator
6.1. Motivation
6.2. The Normal Assembly Process
6.3. Using SPIM
6.4. SPIM Features
6.5. Homework
7. Code Quality Standards
7.1. Motivation
7.2. Comments
7.3. Formatting
7.4. Readability
7.5. Execution
7.6. Error Handling
7.7. Code Size
7.8. Structure and Subprograms
7.9. Homework
8. Program Flow in Assembly/Machine Language
8.1. Motivation
8.2. Arithmetic Expressions
8.3. If-Then-Else
8.4. Switch Statements
8.5. While Loops
8.6. Do-While (Repeat) Loops
8.7. For Loops
8.8. Homework
9. Assembly Macros
9.1. I/O Macros
9.2. Push and Pop
9.3. A Complete Example Program
9.4. Homework
10. Subprogram Calls and the Stack
10.1. Motivation
10.2. Modular Design
10.3. MIPS Subprograms
10.4. Memory Segments
10.5. Using the Stack with Subprograms
10.6. Value and Reference Arguments
10.7. The Stack Frame
10.8. Macros vs. Subprograms
10.9. Coding Practice
10.10. Top-down Programming and Stubs
10.11. Homework
11. Reentrant and Recursive Subprograms
11.1. Motivation
11.2. Introduction
11.3. Reentrance in Assembly Language
11.4. Recursion
11.5. A Recursive MAL Subprogram
11.6. Homework
12. Memory and Arrays
12.1. Motivation
12.2. When to use Arrays
12.3. Arrays in High-level Languages
12.4. Arrays in Assembly Language
12.5. Lookup Tables
12.6. Jump Tables
12.7. Dynamic Memory Allocation
12.8. Virtual Memory
12.9. Cache
12.10. Locality of Reference
12.11. Homework
13. Logic and Shift Operations
13.1. Motivation
13.2. Logic Operations
13.3. Shift Operations
13.4. Homework
14. Input/Output
14.1. Motivation
14.2. I/O Devices
14.3. Memory-Mapped I/O
14.4. Disk I/O
14.5. Homework
15. Exceptions
15.1. Motivation
15.2. Introduction
15.3. Traps
15.4. Interrupts
15.5. MIPS Exception Handling
15.6. Exceptions in SPIM
15.7. CPU Exception Response
15.8. The Exception Handler
15.9. Enabling I/O Interrupts
15.10. Example Code Using Interrupts
15.11. Interrupts and Queues
15.12. Other Architectures
15.13. Homework
16. Compilation and Assembly
16.1. Motivation
16.2. Mixed-Language Programs
16.3. Homework
17. A Pipelined Implementation
17.1. Motivation
17.2. Introduction
17.3. A Pipelined Datapath
17.4. Data Hazard
17.5. Control Hazard
17.6. Simulating Pipelined Implementation in SPIM
17.7. Sum of Integers Running in Pipelined Mode
17.8. A Function Call in Pipelined Mode
17.9. An Example where nops Cannot be Avoided
17.10. Homework

List of Figures

2.1. Sample of a Unix Filesystem

List of Tables

2.1. Man Command Keys
2.2. Standard Streams
3.1. Example MIPS Instruction
3.2. Selection Sort of 50,000 Integers
4.1. Binary/Octal/Hex Conversion
4.2. Unsigned Binary Integer Ranges
4.3. 8-bit sign-magnitude format
4.4. Two's Complement Integer Ranges
4.5. Floating Point Format
4.6. IEEE 32-bit Format
4.7. IEEE 64-bit Format
5.1. Big Endian Long Word
5.2. Little Endian Long Word
5.3. MIPS Registers
5.4. Data Allocation Directives
5.5. Syscall Codes
5.6. Addressing Modes
5.7. Register Instruction Format
5.8. Jump Instruction Format
5.9. Coprocessor Instruction Code Format
5.10. Immediate Instruction Code Format
5.11.
5.12.
10.1. Pass by Value
10.2. After Pass by Value
10.3. Pass by Reference
10.4. After Pass by Reference
10.5. Second Pass by Reference
10.6. After Second Pass by Reference
13.1. The AND Operator
13.2. The OR Operator
13.3. The NOT Operator
13.4. Adder Truth Table

List of Examples

4.1. A module-100 system
4.2. A fixed-point system
4.3. Conversion from Decimal
4.4. A 4-bit unsigned binary number system
7.1. Block Comment
7.2. Limit Block Comments to Interface
7.3. Internal Comments
7.4. Insulting Comments
7.5. Crammed Comment
7.6. Comments Referencing Other Modules
7.7. Prefixing Variables
7.8. Named Constants for Readable Code
7.9. Superstitiously initializing $t0 to 0
7.10. One Purpose Per Subprogram (Cohesion)
7.11. Prefix Variable Names
7.12. Generality of Design
7.13. Printing from Subprograms
7.14. Cohesive Code Segments
7.15. Elegant Code
10.1. Ordering Pizza
10.2. Sorting