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
Index
A
absolute branch
1
abstract data type
1
abstract syntax
1
abstract syntax tree
1
accessor method
1
actual parameter
1
adder
carry-lookahead
1
ripple-carry
1
address
1
address patching
1
address space
1
ADT
see
abstract data type
(
1
)
aggregate type
1
aggregation
1
algebraic data type
1
alias
1
alignment
1
ALU
see
arithmetic logical unit
(
1
)
ambiguous
1
amortized runtime analysis
1
and
1
API
see
application programming interface
(
1
)
application programming interface
1
argument
1
arithmetic
two's complement
1
arithmetic logical unit
1
arity
1
array
1
array type
1
assembler
1
assembler directive
1
assertion
1
stronger
1
weaker
1
assertions
1
AST
see
abstract syntax tree
(
1
)
B
back-end
1
balanced
1
balanced tree
1
base
1
base address
1
big-step operational semantics
1
big-step semantics
1
binary code
1
binary file
1
binary search tree
1
binary tree
1
binomial coefficient
1
bit
1
bit string
1
black-box test
1
block
1
borrow bit
1
branch
1
absolute
1
conditional
1
relative
1
unconditional
1
branch instruction
1
break condition
1
BST
see
tree, binary search
(
1
)
bucket
1
buffer overflow
1
bug
1
bus
1
byte
1
C
C preprocessor
1
call by reference
1
call by value
1
callee-save
1
caller-save
1
calling convention
1
capacity
1
carry
1
carry bit
1
carry-lookahead adder
1
cause
1
central processing unit
1
child
1
class
1
class file
1
class invariants
1
code generation
syntax-directed
1
collision
1
comparison
1
compiler
1
complement
1
composition
1
concrete syntax
1
concrete type
1
conditional branch
1
configuration
1
constructor
1
default
1
constructors
1
container
1
correctness
functional
1
partial
1
total
1
coverage
test
1
CPU
see
central processing unit
(
1
)
D
dangling pointer
1
data
static
1
data segment
1
data type
algebraic
1
declaration
1
function
1
variable
1
default constructor
1
default value
1
defect
1
defensive programming
1
definition
function
1
depth tree
1
descendant
1
deterministic relation
1
digit
1
least significant
1
most significant
1
directed graph
1
directive
1
disassembly
1
divergence
1
divide and conquer
1
dynamic programming
1
dynamically-allocated memory
1
E
edit distance
1
encapsulation
1
environment
type
1
epilogue
1
error
1
error output
1
execution trace
1
external effect
1
F
factory method
1
failing test
1
failure
1
Fibonacci numbers
1
field
1
field struct
1
flag register
1
format strings
1
fprintf
1
frame pointer
1
free
1
front-end
1
fscanf
1
function
1
recursive
1
function body
1
function declaration
1
function definition
1
functional correctness
1
G
garbage collection
1
generic
1
getter
1
ghost variable
1
glass-box test
1
graph
directed
1
H
happy path
1
hardware-software interface
1
hash function
1
hash table
1
header files
1
heap
1
height tree
1
hexadecimal numbers
1
hiding
information
1
Hoare triple
1
I
identifier
1
immediate
1
indirect jump
1
information hiding
1
inheritance
1
instance
1
instruction
branch
1
pseudo
1
instruction set architecture
1
instruction word
1
integer
signed
1
unsigned
1
integration test
1
integration tests
1
interface
1
interpretation
signed
1
unsigned
1
interpreter
1
invariant
1
loop
1
iterator
1
iterators
1
J
Java bytecode
1
jump
1
indirect
1
K
key
1
keyword
1
L
L-evaluation
1
label
1
labelled tree
1
language
statically type-safe
1
type-safe
1
leaf
1
least significant bit
1
least significant digit
1
Levenshtein distance
1
lexer
1
lexing
1
LIFO
1
linear probing
1
linker
1
list
1
loop invariant
1
M
malloc
1
memoization
1
memory
dynamically-allocated
1
statically-allocated
1
memory assignment
1
memory leak
1
memory management
1
memory safety
1
merge sort
1
method
1
accessor
1
factory
1
static
1
minimum edit distance
1
mnemonic
1
model
1
most significant bit
1
most significant digit
1
N
namespace
1
null
1
number system
positional
1
O
object
1
object file
1
occurrence variable
1
offset
1
open addressing
1
operational semantics
1
big-step
1
small-step
1
optimal substructure
1
optimization problem
1
or
1
oracle
test
1
ordered labelled tree
1
out-of-bounds
1
overflow
1
unsigned addition
1
unsigned subtraction
1
overflow bit
1
overlapping sub-problems
1
override
1
P
parameter
1
parent
1
parser
1
parsing
1
partial correctness
1
passing test
1
patching
address
1
path
1
PC
see
program counter
(
1
)
pigeonhole principle
1
pointer
1
positional number system
1
postcondition
1
precondition
1
weakest
1
prefix tree
1
primitive type
1
printf
1
probing
1
linear
1
quadratic
1
program
well-typed
1
program counter
1
program representation
1
programming
defensive
1
prologue
1
prototype
1
pseudo instruction
1
Q
quadratic probing
1
qualification
1
qualifier
1
R
R-evaluation
1
record
1
recursion
1
recursive function
1
reference
1
reference type
1
register file
1
register names
1
regression
1
relative branch
1
return register
1
ripple-carry adder
1
RISC
1
RISC-V
1
RISC-V processor
1
root
1
rule of consequence
1
runtime system
1
S
satisfiable
1
scalar type
1
scanf
1
scope
1
visibility
1
semantics
1
big-step
1
operational
1
small-step
1
static
1
setter
1
sign extension
1
signed integer
1
signed interpretation
1
singleton
1
size tree
1
sizeof
1
small-step operational semantics
1
small-step semantics
1
spaghetti code
1
specification
1
specification-based test
1
stack
1
stack frame
1
stack pointer
1
standard input
1
standard output
1
state
1
statement
1
static
1
static data
1
static method
1
static semantics
1
static type
1
static type safety
1
statically type-safe language
1
statically-allocated memory
1
strict
1
stronger assertion
1
struct
1
field
1
structural test
1
stuck
1
subject under test
1
subtraction
1
subtype
1
symbol table
1
syntactic analysis
1
syntax
abstract
1
concrete
1
syntax analysis
1
syntax definition
1
syntax-directed code generation
1
system test
1
System tests
1
T
tail recursion
1
tail recursive
1
termination
1
test
1
black-box
1
coverage
1
failing
1
glass-box
1
oracle
1
passing
1
specification-based
1
structural
1
unit
1
white-box
1
test coverage
1
test oracle
1
test suite
1
theorem prover
1
token
1
tokens
1
tombstone
1
total correctness
1
trace
execution
1
translation unit
1
tree
1
balanced
1
binary
1
binary search
1
depth
1
height
1
labelled
1
ordered labelled
1
prefix
1
size
1
trie
1
two’s complement
1
two's complement arithmetic
1
type
1
aggregate
1
array
1
concrete
1
primitive
1
reference
1
scalar
1
static
1
type checking
1
type environment
1
type erasure
1
type safety
1
static
1
type-safe
1
type-safe language
1
U
unconditional branch
1
undefined behavior
1
unit test
1
unsatisfiable
1
unsigned addition overflow
1
unsigned integer
1
unsigned interpretation
1
unsigned subtraction overflow
1
V
valid
1
value
1
variable
1
ghost
1
occurrence
1
variable assignment
1
variable declaration
1
verification condition
1
virtual method table
1
visibility scope
1
visitor pattern
1
VMT
see
virtual method table
(
1
)
vtab
see
virtual method table
(
1
)
vtable
see
virtual method table
(
1
)
W
weaker assertion
1
weakest precondition
1
well-typed
1
well-typed program
1
white-box test
1
word size
1
X
xor
1
Z
zero extension
1