Home
Colophon
Preface
Acknowledgements
Contents
1 Computer Arithmetic
1.1 Positional Notation
1.2 Binary Numbers
1.3 Addition and Subtraction
1.4 The Integers
1.5 Shifts
1.6 Summary
2 Machine Code
2.1 The von-Neumann Architecture
2.2 The RV32I ISA
2.3 The Assembler
2.4 Execution Traces
2.5 The Data Segment
2.6 Memory Segmentation
2.7 Linking
2.8 Calling Functions
3 Some Simple Algorithms
3.1 Number Conversion
3.2 The Sieve of Eratosthenes
3.3 Insertion Sort
3.4 Evaluating Polynomials with Horner’s Method
3.5 The Tortoise and the Hare
4 Introduction to C
4.1 Basics
4.2 Execution Traces
4.3 Imperative Variables
4.4 The C Memory Model
4.5 Translation Units
4.6 Number Types
4.7 Control Flow
4.8 Expressions
4.9 Calling Functions
4.10 Pointers
4.11 Examples
4.12 Dynamic Memory Management
4.13 Structs
4.14 Input and Output
4.15 Undefined Behavior
5 Algorithms and Data Structures
5.1 Lists
5.2 Trees
5.3 Hashing
5.4 Dynamic Programming
6 Formal Semantics
6.1 The Syntax of Programming Languages
6.2 The Abstract Syntax of C0
6.3 The Semantics of C0
6.4 Pointers (C0p)
6.5 Scopes (C0b)
6.6 A Simple Type System (C0t)
6.7 Summary and Further Reading
7 Testing and Verification
7.1 Functional Correctness
7.2 Failures
7.3 Testing
7.4 Verification
8 Object-Oriented Programming with Java
8.1 Compilation, Main Method, Packages
8.2 Types
8.3 Reference Types
8.4 Classes
8.5 Encapsulation
8.6 References, Aliasing, and Immutable Objects
8.7 Inheritance
8.8 Overloading Methods
8.9 The Java Collections Framework
8.10 Using Object Orientation Properly
8.11 The Expression Problem and the Visitor Pattern
8.12 Object-Oriented Programming with C
9 A Simple Compiler
9.1 A Brief Overview of Syntactic Analysis
9.2 Type Checking
9.3 Syntax-Directed Code Generation
A RISC-V Assembler Reference
A.1 Instruction Set Reference
A.2 OS Calls
A.3 Assembler Directives
B ASCII Table
C Course Structure
C.1 I: Course Introduction
C.2 R1: Computer Arithmetic
C.3 R2: Computer Arithmetic
C.4 M1: Introduction to Machine Code Programming
C.5 M2: Simple Algorithms in Machine Code
C.6 M3: Function Calls
C.7 C1: Introduction to C
C.8 C2: Expressions and Pointers
C.9 C3: Arrays, Structs, I/O
C.10 A1: Lists and Trees
C.11 A2: Dynamic Programming
C.12 S1: C0 Syntax and Semantics
C.13 S2: Extending C0 to Pointers and Scopes
C.14 S3: Correctness
C.15 S4: Testing
C.16 J1: Intro to Java
C.17 J2: Immutable Objects, Interfaces, Subtyping
C.18 J3: Abstract Classes, Object, Overriding and Overloading Methods
C.19 J4: Using OO Properly, OO in C, The Expression Problem, Visitor Pattern
C.20 A3: Java Collections Framework and Hashing
C.21 A4: Project Specific
C.22 O1: Compiler Introduction (Syntax Analysis, Static Semantics)
C.23 O2: Type Checking Examples, Implementation of Type Checking
C.24 O3: Syntax-Directed Code Generation
C.25 V1: Hoare Logics
C.26 V2: Loop Invariants and Mechanizing Verification
Exercise Solutions
List of Symbols
Index
Literature
PDF Course Website
An Introduction to Imperative Programming
[1] ISO, “ISO/IEC 9899:1999 Draft, ISO C Standard 1999.” [Online]. Available: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf
[2] Xi Wang, Haogang Chen, Alvin Cheung, Zhihao Jia, Nickolai Zeldovich, and M. Frans Kaashoek, Undefined Behavior: What happened to my code? . [Online]. Available: http://doi.acm.org/10.1145/2349896.2349905
[3] Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein, Introduction to Algorithms . MIT Press.
[4] Stefan Richter, Victor Alvarez, and Jens Dittrich, “A Seven-Dimensional Analysis of Hashing Methods and its Implications on Query Processing.” [Online]. Available: http://www.vldb.org/pvldb/vol9/p96-richter.pdf
[5] Michael Norrish, “C formalized in HOL.” [Online]. Available: https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-453.pdf
[6] Robert Krebbers, “The C standard formalized in Coq.” [Online]. Available: https://robbertkrebbers.nl/thesis.html
[7] Xavier Leroy and Sandrine Blazy, “Formal Verification of a C-like Memory Model and Its Uses for Verifying Program Transformations.” [Online]. Available: https://xavierleroy.org/publi/memory-model-journal.pdf
[8] Hanne Riis Nielson and Flemming Nielson, Semantics with applications: a formal introduction . John Wiley & Sons. [Online]. Available: https://www.cs.ru.nl/~herman/onderwijs/semantics2019/wiley.pdf
[9] Glynn Winskel, The Formal Semantics of Programming Languages: An Introduction . MIT Press.
[10] Robert Harper, Practical Foundations for Programming Languages . Cambridge University Press. [Online]. Available: https://www.cs.cmu.edu/~rwh/pfpl/2nded.pdf
[11] Benjamin Pierce, Types and Programming Languages . MIT Press. [Online]. Available: https://mitpress.mit.edu/books/types-and-programming-languages
[12] Mauro Pezzè and Michal Young, Software Testing and Analysis: Process, Principles and Techniques . Wiley.
[13] James Gosling, Bill Joy, Guy Steele, and Gilad Bracha, Java(TM) Language Specification, The 3rd Edition . Addison-Wesley. [Online]. Available: http://java.sun.com/docs/books/jls/third_edition/html/j3TOC.html
[14] Philip Wadler, “The Expression Problem.” [Online]. Available: https://homepages.inf.ed.ac.uk/wadler/papers/expression/expression.txt
[15] Reinhard Wilhelm, Helmut Seidel, and Sebastian Hack, Compiler Design - Syntactic and Semantic Analysis . Springer.
[16] Ravi Sethi and Jeffrey Ullman, “The Generation of Optimal Code for Arithmetic Expressions,” ACM .
[17] RISC-V International, “The RISC-V Instruction Set Manual Volume 1.” [Online]. Available: https://drive.google.com/file/d/1uviu1nH-tScFfgrovvFCrj7Omv8tFtkp/view