CS 210: Assembly Language and Systems Programming (Spring 2005)
Lecture: Tuesday-Thursday 3:30pm-5:15pm (235 Harney Science Center)
Instructor:
Allan Cruse
Email:
cruse@usfca.edu
Phone: (415) 422-6562
Office: 212 Harney Science Center
Office Hours: (see my homepage)
Teaching Assistant:
Alex Lagor
TA consulting hours: Tues-Thurs 12:20pm-1:20pm
- This course introduces students to computer programming at the
machine language level, as a means of exploring some basic concepts
of microcomputer architecture, system software and peripheral hardware.
It is comprised of lectures, readings, discussions, demonstrations,
consultations, assigned design projects and scheduled exams.
- The course will focus primarily on the assembly language for Intel
Pentium processors running the Linux operating system
and will use the GNU assembler and program development tools.
Students are presumed to have prior experience with computer programming
in at least one high-level language (such as C/C++/java), and to be familiar
with basic operating system commands (e.g., as covered in CS 110/112).
- Class meetings will be held in the
Michael D. Kudlick computer classroom
(Room 235, Harney Science Center) which affords convenient opportunities
for combining formal instruction with "hands-on" programming exercises.
This facility, a gift of USF alumnus
Alfred S. Chuang ('82), was opened in Fall 2002.
Textbook (for collateral readings):
Kip R. Irvine,
Assembly Language Programming for Intel-Based Computers (Fourth Edition)
Prentice-Hall, Inc. (2003), ISBN 0-13-091013-9
"One of my goals is to help students approach programming problems with a
machine-level mind set... [and] give students the first-hand experience of
writing software in an environment that teaches them how the computer really
works...
The present edition includes topics that lead naturally into subsequent
courses in computer architecture, operating systems, and compiler writing."
-- Kip Irvine, Florida International University
Learning Outcomes:
- You will know the set of fundamental operations a computer can perform.
- You will know how to build complex computations out of simple operations.
- You will be able to "see through" code written in a high-level language.
- You will gain the capability to fully utilize features in modern CPUs.
- You will lay the conceptual ground for understanding later CS courses.
- You will acquire a skill-set of practical value in professional practice.
Resources
Readings
- Week 1: Textbook, Chapter 1: Basic Concepts
- Week 2: Textbook, Chapter 2: IA-32 Processor Architecture
- Week 3: Textbook, Chapter 3: Assembly Language Fundamentals
- Week 4: Textbook, Chapter 4: Data Transfers, Addressing, and Arithmetic
- Week 5: No new assignment; review for Midterm Exam I
- Week 6: Textbook, Chapter 5: Procedures
- Week 7: Textbook, Chapter 6: Conditional Processing
- Week 8: Textbook, Chapter 7: Integer Arithmetic
- Week 9: Textbook, Chapter 8: Advanced Procedures
- Week 10: No new assignment; review for Midterm Exam II
- Week 11: Textbook, Chapter 9: Strings and Arrays
- Week 12: Textbook, Chapter 12: High-Level Language Interface
- Week 13: Textbook, Chapter 17: Advanced Topics
- Week 14: No new assignment: review for the Final Examination
Handouts
- 0203-210-01: Course syllabus(.PDF)
- lesson1.ppt (Powerpoint Slides)
- Simple "high-level" programming example: demo1.c
- Example rewritten in assembler language: demo2.s
- Separate function (needed by 'demo2.s'): sprintf.s
- lesson2.ppt (Powerpoint Slides)
- Demo program: squares.s
illustrates the use of a program-loop to print out a mathematical table
- lesson3.ppt (Powerpoint Slides)
- Demo program: showdots.s
illustrates the 'Input-Process-Output' programming-structure paradigm
- lesson4.ppt (Powerpoint Slides)
- Demo program: reverse.s
shows a way to use the stack to reverse the order of stored characters
- Demo routine: eax2hex.s
procedure that converts EAX to a hexadecimal string at address EDI
- Demo program: factors.s
uses a command-line argument, and the x86 MUL and DIV instructions
- Demo routine: softmulb.s
performs an emulation with software of the ' mul %bl ' instruction
- Demo program: testmulb.s
provides an environment for testing this software-multiply routine
- Demo program: multest.cpp
performs exhaustive testing of our 8-bit software-multiply routine
- Demo routine: softdivb.s
performs an emulation with software of the ' div %bl ' instruction
<-- revised on 3/15/2006
- Demo program: testdivb.s
provides an environment for testing this software-divide routine
- Demo program: divtest.cpp
performs exhaustive testing of our 8-bit software-divide routine
- Exam exercise: powers.s
prints a short mathematical table showing nonegative powers of 2
- Exam solution: powers3.s
shows one possible solution for question V on the midterm exam
- lesson5.ppt (Powerpoint Slides)
- Demo program: noecho.cpp
shows how to disable echoing of keyboard input at the Linux terminal
- Demo program: noecho.s
this is an assembly language version of our 'noecho' demo-program
- Demo program: ttyinfo.cpp
shows information about, and contents of, the 'struct termios' object
- Demo program: password.s
here is the source-code that you are asked to enhance in Project 3
- Demo program: ledstate.s
illustrates the direct programming of a peripheral hardware device
- Demo program: redcolor.c
illustrates use of the 'rep stosw' instruction in a Linux kernel module
- Demo program: mywhoami.s
uses x86 string instructions to search for an environment variable
- Demo program: seestack.cpp
an application that displays the contents of its own program stack
- Demo program: xmas.s
an application that obtains its input-data from the command-line
- Debugging tool: db.tar.gz
it lets you single-step through your Linux assembly language programs
- Conversion-routines: asc2int.s
and int2asc.s convert between
ascii and numeric representations
- Conversion-routine: gpacalc.s
can be linked to symbols in both the .text and the .data sections
- Exam solution: born.s
shows one possible solution for question V on our second midterm exam
- Demo program: out2file.s
shows how you can directly invoke kernel system-calls to create a file
- Demo program: readdemo.s
shows how you can read a file into a dynamically allocated buffer area
- Demo program: brkdemo.cpp
illustrates the result of direct calls to the kernel's 'brk()' service
- Work-in-progress: mytracer.cpp
prototype for developing your own debugging tool (see Project #6)
- Demo program: noncanon.cpp
shows how to enable non-canonical input from the Linux terminal
- Demo program: tryfork.s
illustrates direct use of the Linux 'fork()' and 'waitpid()' system-calls
- Demo program: tryexec.s
illustrates direct use of the Linux kernel's 'execve()' system-call
- Demo program: intwatch.cpp
displays in real time the number of interrupts that have been generated
- Kernel module: activity.c
creates the pseudo-file named '/proc/activity' needed by our 'intwatch' demo
- Demo program: sigdemo.cpp
illustrates the basic steps in utilizing the Linux signaling mechanism
- Developer tool: run.cpp
allows us to easily see the value for an application-program's 'exit-status'
- Demo program: sigdemo1.s
reimplements our 'sigdemo.cpp' without linking to runtime-library code
- Demo program: sigdemo2.s
adds routines to 'sigdemo1.s' showing how signal-delivery uses the stack
- Demo program: pipedemo.cpp
illustrates a use of 'pipes' and 'signals' for interprocess communication
- Demo function: fact.s
illustrates the implementation of a recursive function using assembly language
- Demo program: fact.cpp
shows syntax needed by a C++ program to call an assembly language function
- In-class exercise: fib.cpp
this is the high-level portion in C++ of the Fibonacci recursion exercise
- Exercise solution: fib.s
shows a way to implement the recursive Fibonacci function in asembly language
- Demo program: forkdemo.cpp
explores the effect of calling the 'fork()' function within a program loop
- Exam problem: fifty.s
this short assembly language program contains several programming mistakes!
- Demo program: ShowEflags.java
shows how a Java program can call an external function written in C++
(in the source-file ShowEflags.cpp)
which also includes the use of some inline x86 assembly language!
Announcements
- Project 1: Due Noon Tuesday, 22 February 2005
- Midterm Exam 1: Thursday, 24 February 2005
- Project 2: Due Noon Thursday, 03 March 2005
- Project 3: Due Noon Thursday, 17 March 2005
- Project 4: Due Noon Thursday, 31 March 2005
- Midterm Exam 2: Tuesday, 05 April 2005
- Project 5: Due Noon Thursday, 14 April 2005
- Project 6: Due Noon Thursday, 05 May 2005
- FINAL EXAMINATION: Monday, 16 May 2005, 8:00am
Last updated on 03/15/2006