CS 350: Computer Organization & Assembly Language Programming

Staff

Instructor: Kyle C. Hale
  Office Hours: Wed. 4:30PM - 7:30PM (after lecture), or by appointment. (SB 237F)
  E-mail: khale [at] cs [dot] iit [dot] edu

TAs:

Chaoqi Ma (--)
  Office Hours: Mon. 12:00PM - 1:00PM;
    Tue. 1:00PM - 3:00PM (SB 004)
  E-mail: cma17 [at] hawk [dot] iit [dot] edu

Zhihao Ai (L01)
  Office Hours: Fri 2:00PM - 3:00PM (SB 108)
  E-mail: zai [at] hawk [dot] iit [dot] edu

Stephanie Vaccaro (L01)
  Office Hours: Fri 11:00AM - 12:00PM (SB 108)
  E-mail: svaccaro [at] hawk [dot] iit [dot] edu

Hannah Greenblatt (L02)
  Office Hours: Fri 4:10PM - 5:10PM (SB 108)
  E-mail: hgreenbl [at] hawk [dot] iit [dot] edu

Luke Logan (L02)
  Office Hours: Th 3:25PM - 4:25PM (SB 108)
  E-mail: llogan [at] hawk [dot] iit [dot] edu

Shreyas Moudgalya (L02)
  Office Hours: Fri 11:00AM - 12:00PM (SB 108)
  E-mail: smoudgal [at] hawk [dot] iit [dot] edu

Course Info

Course number: CS 350

Semester: Spring 2017

Lecture Time: Mod/Wed 3:15PM - 4:30PM

Lecture Location: Hermann Hall 002

Lab 01 Time: Fri 3:15PM - 4:05PM

Lab 01 Location: SB 108

Lab 02 Time: Fri 3:15PM - 4:05PM

Lab 02 Location: SB 112E/F

Overview

This course will be your entry into the world of computer systems. This is where you will begin to see the "nuts and bolts" of computers—how they're designed, how they're implemented, how they're programmed at the lowest levels, and how the whole system fits together. As such, this is a "bottom-up" course. By the end, when you write your high-level programs, whether they're in C, Python, Ruby, Node.js, or brainfuck, you should be able to reason about how the code you write turns into low-level operations on the hardware. You will be able to cut through levels of abstraction to gain a deeper understanding of how computer systems work. After finishing this course, you will no longer take for granted the mesmerizing array of languages and tools that "just work." The path will be open for you to become a practitioner of the dark arts of systems programming who shuns Clarke's third law and who, when in need of a Linux machine, writes it in C.

Note that CS 350 is a required core course for both the CS and CIS undergraduate curriculums

Communication

Please do not hesitate to interact with the instructor, the TAs, and your classmates. Do not wait until the last minute to come see your instructor! We will be primarily using Piazza as a course communication mechanism. If you have an issue or question that is not strictly private (especially one you think would benefit everyone were it answered), please use Piazza as your first resource. The instructors, the TAs, and your fellow classmates will be there to help. Note that you can also post anonymously if you so choose.

Lecture Schedule

Week Date Item Topic Notes Reading
1 Mon 1/9 Lec 1 Intro, logistics, abstraction No labs 1st week of class
Lec. 1 notes
Lec. 1 slides
Optional reading: Feynman Chs. 1/2
1 Wed 1/11 Lec 2 Digital representations I Lec. 2 notes
Lec. 2 slides
Optional reading: Annotated Turing (good book in general for intro to Turing Machines)
2 Mon 1/16 holiday MLK Day
2 Wed 1/18 Lec 3 Digital representations II Lec. 3 notes
Optional reading: It from Bit
3 Mon 1/23 Lec 4 Transistors Lec. 4 notes
Lec. 4 slides
Required reading: Weste & Harris Ch. 1 (through 1.5)
3 Wed 1/25 Lec 5 Boolean algebra & logic design Lec. 5 notes
4 Mon 1/30 Lec 6 Floating point; more logic Lec. 6 notes Required reading: Feynman Ch. 2
Optional Reading: Feynman Ch. 7
4 Wed 2/1 Lec 7 Combinational Logic Lec. 7 notes
5 Mon 2/6 Lec 8 Sequential Logic & Storage Elements Lec. 8 notes
5 Wed 2/8 Lec 9 Memory, Sequential Circuits, Flip Flops Lec. 9 notes
6 Mon 2/13 Quiz 1 (See Tests)
6 Wed 2/15 Lec 10 State Machines & the Von Neumann Architecture Lec. 10 notes Required reading: von Neumann's report on EDVAC, Sections 1-7
7 Mon 2/20 Lec 11 von Neumann Architecture, the instruction cycle Lec. 11 notes
7 Wed 2/22 Lec 12 The Simple Decimal Computer Lec. 12 notes
8 Mon 2/27 Lec 13 LC-3 Intro, LC-3 datapath, LC-3 control, instr. execution Lec. 13 notes Required reading: Patt & Patel Ch. 5
8 Wed 3/1 Lec 14 LC-3 operations & Control Lec. 14 notes
9 Mon 3/6 Lec 15 LC-3 ISA, assembly Lec. 15 notes
SDC ISA reference
LC-3 ISA reference
9 Tues 3/7 Exam 1 Review In HH 003: 6:00PM - 7:30PM
9 Wed 3/8 Exam 1 (See Tests)
10 Mon 3/13 holiday Spring Break (No classes)
10 Wed 3/15 holiday Spring Break (No classes)
10 Fri 3/17 holiday Spring Break (No classes)
11 Mon 3/20 Lec 16 Assembly language & assemblers Code examples posted on Fourier (see Piazza) Required Reading:Patt & Patel Ch. 7
11 Wed 3/22 Lec 17 Traps, subroutines, linkage Lec. 17 notes
12 Mon 3/27 Lec 18 The runtime stack, C execution model Optional reading: The stack
12 Wed 3/29 Lec 19 Dynamic memory, C execution model Lec. 18,19 notes
13 Mon 4/3 Lec 20 Linking & loading, Libraries, Buffer Overflows Lec. 20 notes
13 Wed 4/5 Quiz 2
13 Wed 4/5 Lec 21 Intro to I/O Lec. 21 notes
14 Mon 4/10 Lec 22 I/O programming Lec. 22 notes Required Reading: Patt & Patel Ch. 8
14 Wed 4/12 Lec 23 Computer Architecture I (Memory system) Lec. 23 notes Required Reading: Hennessy & Patterson 7.1-7.2
15 Mon 4/17 Lec 24 Computer Architecture II Lec. 24 notes
15 Wed 4/19 Lec 25 Computer Architecture III Lec. 25 notes
16 Mon 4/24 Lec 26 NO CLASS THIS DAY
16 Tues 4/25 Exam 2 Review In HH 003: 5:00PM - 6:30PM
16 Wed 4/26 Exam 2 (See Tests)

Exam Schedule

Week Date Item Length Covers File Date Note
6 Mon 2/13 Quiz 1 30 min Lec 1-7, Lab 0-2
9 Wed 3/8 Exam 1 75 min Apx 35% on Q1 material, 65% on Lec 8-14, Labs 3-6
13 Wed 4/5 Quiz 2 30 min Lec 13-19, Lab 7-8
16 Wed 4/26 Exam 2 75 min Apx 25% on Q2 material, 75% on Lec 19-end, Lab 9-end

Labs & Project

Lab Covers Lec Due Date Handout Notes (TBP = To Be Posted)
0 --- None Lab 0 Posted 1/8 (no hand-in)
Solutions posted 1/18
1 1-2 2/2/2017 11:59PM Lab 1 Posted 1/26; Solutions posted 2/6
2 3-4 2/9/2017 11:59PM Lab 2 Posted 2/2; Solutions posted 2/12
3 5-6 2/17/2017 11:59PM Lab 3 Posted 2/10; Solutions posted 2/22
4 7-8+ 2/23/2017 11:59PM Lab 4 Posted 2/16; Solutions posted 2/27
5 10-12 3/9/2017 11:59PM Lab 5 Posted 2/23
6 -- 3/23/2017 11:59PM Lab 6 Posted 3/9
7 13-17 3/30/2017 11:59PM Lab 7 Posted 3/24; Solutions posted 4/4
8 18-19 4/6/2017 11:59PM Lab 8 Posted 3/30; Solutions posted 4/10
9 20-23 4/24/2017 11:59PM Lab 9 Posted 4/13; Solutions posted 4/25
Final Project --- 4/28/2017 11:59PM Final Project Posted 3/31

Books

There are no required textbooks for this course. This means it is absolutely essential that you attend class, participate in discussions, and come to office hours. I am, however, recommending the following textbook for this course, as it is where the project will come from:

Introduction to Computing Systems: From Bits & Gates to C & Beyond (2nd Edition), by Yale Patt and Sanjay Patel, 2004 McGraw-Hill. The text's Student Resources website contains links to the LC-3 Simulator and lab manual.

A classic book on introductory computer architecture. If you'd like to learn more about processor architecture, and would like to learn how to design your own control and datapaths (this book uses MIPS), this is a great resource:

Computer Organization and Design (5th Edition), by David Patterson and John Hennessy, 2013 Morgan Kauffmann.

A good book dedicated to logic design, which we cover in the first half of this course.

Fundamentals of Logic Design (7th Edition) by Charles Roth and Larry Kinney, 2013 CL Engineering.

This is also a useful book to have on your shelf. It is a bit newer. It does not go into quite as much detail, but does guide you through building your own virtual computer:

The Elements of Computing Systems: Building a Modern Computer from First Principles (1st Edition), by Noam Nisan and Shimon Schocken, 2005 MIT Press.

This course takes a "bottom-up" approach to programming, in that we start from the principles of digital logic design and computer organization. You'll soon be taking CS 351, which is closely related and complementary to this course. If you want to get ahead, you should consider purchasing this book (you'll need it anyway) and skimming. There is a good deal of overlap, but from a slightly different perspective:

Computer Systems: A Programmer's Perspective (3rd Edition), by Randal Bryant and David O'Hallaron, 2015 Pearson.

Learning C

For this class, though our programs will be written in C on Linux, this is not a class on how to program in C on Linux. We'll spend some time in class looking at pointers and structures, but we won't cover all of the C and Linux you need for the course. You'll need to learn the rest on your own (or with other students (see Working Together On Labs below). If you are considering specializing in computer systems, e.g. computer architecture, operating systems, networking, and distributed systems, you'll find that a mastery of the C language is absolutely essential.

Here is a good interactive, online reference for learning C. If you can make it through this tutorial, you will likely be fine with C in this course. Here is a quick reference card for C syntax and common functionality.

The following book is one you will find on the shelf of any good systems programmer. It is the definitive reference for the original ANSI C language, written by its designers. While we will be mostly using the updated C99 specification of the language, it is still an excellent book to own:

The C Programming Language (2nd Edition), by Brian Kernighan and Dennis Ritchie, 1988 Prentice Hall.

Here is another decent book for learning C with a more practical bent. It is aimed towards people intending to build real, resilient systems with the C language:

Learn C the Hard Way: Practical Exercises on the Computational Subjects You Keep Avoiding (Like C) (1st Edition), by Zed Shaw, 2015 Addison-Wesley Professional.

Of course, the best way to learn a programming language is to see examples from master programmers. In this light, we will be looking at some examples from one of the most widely used and successful open-source codebases in existence, the Linux kernel. We will be looking at C design patterns used there, possibly including more advanced uses like object-oriented design patterns in C.

Learning the UNIX Environment

At this point, you are probably still used to using a Mac or a Windows system. In the CS world however, if you want to have any hope of being productive, you absolutely must learn to work in a UNIX-like environment (e.g. Linux, FreeBSD). I encourage you to use a desktop hypervisor (such as Parallels, VMware, or VirtualBox ), download a Linux distribution of your choice (Ubuntu, Mint, Debian, Fedora, OpenSUSE, and Arch are good choices), and boot it as a VM to get the lay of the land.

Probably the most useful skill you'll need to acquire is navigation at the UNIX command shell. Here is a good tutorial for that. Here is a nice reference that will allow you to look up commands that you encounter but do not know.

Here is a nice overview of UNIX programming, especially the design philosophies and common themes.

Here is a good book on programming in the UNIX environment, from the lowest levels:

Programming from the Ground Up by Jonathan Bartlett, 2016 CreateSpace Independent Publishing.

For more advanced shell usage and Linux system administration:

Linux Server Hacks: 100 Industrial-Strength Tips and Tools, by Rob Flickenger, 2003 O'Reilly Media.

Development Environment

You will be mostly writing C and assembly in this course. You are free to write it any way you like. You must, however, make sure it compiles and runs correctly on the course server, described below. You'll want to make sure that your compiler (gcc) is roughly the same version as that on the course server, otherwise you can expect strange differences. If you want to play it safe, just write your code on the course server.

Course Server

We'll be using the server named fourier.cs.iit.edu. If you have registered for the course already, you should already have received an e-mail notifying you of your account creation. If this is not the case, you need to let me know ASAP!

The first lab will have details on getting on the machine to do your work. If you want to get started early, you'll first want to use a terminal emulator. If you're on a Mac, you can just use the Terminal application (or iTerm2, which has some bells and whistles). If you're on Windows machine, you'll want to use Cygwin, which emulates a UNIX-like environment. If you're using a Linux distro, you probably don't even need to be reading this section.

From your terminal, you can log in to the course server this way:


$> ssh your-id@fourier.cs.iit.edu

Note that the $> above simply indicates that you are sitting at a terminal (it represents the prompt). You will probably see something different, depending on which machine and which shell you're using. For example, you might see a prompt like:

[kyle@localhost]$ 

The command you enter actually starts with the ssh component.

If you are not familiar with navigating in a command-line environment, now is the time. The sooner you wean yourself off a GUI-based point-and-click environment, the better off you'll be moving forward in your systems classes. See the Linux section for some pointers on how to get started.

Other Useful Links and Resources

This is a list of other resources that you might find useful for this class and for doing work in the systems area in general. Feel free to peruse them at your own convenience.

Books

These books are not all technical, but are broadly applicaable to computer systems, science, engineering, and programming.

Programming Pearls (2nd Edition) by Jon Bentley, 1999 Addison-Wesley. A good reference for design patterns and common idioms used in C and C++ programming.
CMOS VLSI Design: A Circuits and Systems Perspective (4th Edition), by Neil Weste and David Harris, 2010 Pearson. Probably the best textbook out there on VLSI design. You might find yourself curious about how all this stuff gets implemented on a silicon die. You won't encounter a course covering these topics in our department, however. You'll have to take an ECE course. However, this book gives a fairly gentle introduction to integrated circuit design for those dedicated enough for self study.
Feynman Lectures on Computation by Richard P. Feynman, 2000 Westview Press. A wonderful series of lectures given by the famous and brillian theoretical physicist. An unusual perspective on computing systems and computation in general. Highly recommended.
Racing the Beam: The Atari Video Computer System (Platform Studies), by Nick Montfort, 2009 MIT Press. A great book about the Atari console and the technical acheivements that made it possible. If you're interested in the intersection of computer systems and game programming, this is a book for you.
The Supermen: The Story of Seymour Cray and the Technical Wizards Behind the Supercomputer, by Charles J. Murray, 1997 Wiley. An engaging narrative about the development of the first supercomputers, from the Army Research Lab's code-breaking machines of WWII to the CDC6600 and the blazing machines from Seymour Cray. If you're interested in the history of computer science and engineering, this is a nice quick read.

Links