ECS 50, Computer Organization and Machine-Dependent Programming

Norm Matloff

Winter 2005

1  This Syllabus Is on Our Web Site

Important note: This syllabus, and lots of other important information, is available at
http://heather.cs.ucdavis.edu/~matloff/50.html

2  Common Syllabus for Both Sections

I am teaching both sections of ECS 50 being offered this quarter. This syllabus is for both sections. Note however that there may be slight differences in content for the two sections, and thus test coverage may differ slightly as well. Even for the material in common to the two sections, it might be presented on different days. Thus you cannot migrate back and forth between the sections. You cannot take exams or quizzes in a section in which you are not enrolled.

3  Consultation

3.1  Office and Office Hours

My office is in 3053 Kemper Hall, Ext. 2-1953. My office hours will be Mondays, 3:30-4:30 and Thursdays, 2-3. I enjoy my office hours very much, and look forward to interacting with you during them.
I am also available at other times if you have short questions.
Our TA will announce office hours soon.

3.2  E-Mail

You are welcome and encouraged to send me your questions via e-mail. I read my mail every day, including evenings and weekends.

4  Course Prerequisites

4.1   Prerequisities Strictly Enforced

Please note that prerequisites are strictly enforced. If you are already enrolled but do not meet the requirements, please drop the class immediately, as otherwise you would be dropped by the Registrar, or get an E-NWS ("enrolled, no work submitted") grade. The Homework Grader (Reader or TA) would not accept any homework from you, and your exam papers would not be graded. Similarly, if you are on the waiting list, you will not be allowed to enroll.

4.2  Importance

Note also that the prerequisite material is likely to be used as foundation in various exam questions. In other words, it could happen that you miss an exam question for lack of review of the prerequisite material. So, it is quite important that you make sure you have reviewed the prerequisite material:

4.3  ECS 40/C/C++/UNIX

This course has ECS 40 as a prerequisite. That means that you should HAVE A WORKING KNOWLEDGE of basic programming and UNIX concepts such as:
linked lists; files and directories, e.g. commands such as ls, cd, pwd, chmod; network use, e.g. e-mail, network addresses, ftp; processes, e.g. use of ctrl-z, & and the bg/fg and kill commands; C library and include files; argc/argv command-line variables; user-level windowing, e.g. creating and moving windows; shell conveniences, e.g. file name wild cards, the history command, etc.; modular program design, including separate compilation of source files; makefiles and the make program; pointers, & and * pointer operators; recursion; fprintf(), fscanf(), and fopen() or similar functions in C++; debugging aids such as gdb

5  Workload

The workload for this course, in the way I teach it, is substantial:

6  Course Content and Goals

6.1  Don't Call ECS 50 "the Assembly Language Course"

I know that you are thinking that ECS 50 is "the assembly language course," treating it as being devoted to learning just another language like C or C++. This is only partly true.

6.2  So, What IS This Course About, Then?

Instead of thinking of ECS 50 as "the assembly language course," you should think of it as these courses:
This course is an introduction to computer systems:
It is certainly true that you will do a large amount of assembly language programming in this course, but it is a means to the above goals, not an end in itself.

6.3  What Is Different About My Version of ECS 50

All instructors of a given course are supposed to cover the material listed in the Expanded Course Description (ECD) for the course.
However, there is still plenty of room left for individuality. My version of ECS 50 differs from those of other instructors in that:

6.4  Why Linux?

Linux, as you may know, is one of the many different versions of UNIX. Among them, it is the one which is "hot" today.
There are several important reasons why the main computing platform in our course will be Linux:

7  Course Materials

7.1  Printed Lecture Notes

There is no bound textbook. Instead, the text consists of my printed lecture notes (PLN). These are sold in the bookstore at the beginning of the quarter. Also, they are available as the PDF files in http://heather.cs.ucdavis.edu/~matloff/50/PLN.

7.2  Each Student Must Have His/Her Own Course Materials

Note that exams and quizzes are open-book, and thus there is no sharing of the PLN, books or other materials-including calculators1-during examsand quizzes. Thus every student must have his/her own copy of the PLN and other course materials.

7.3  Bring the Course Materials with You to Class

Bring the PLN to all lectures, discussion sections and exams and quizzes.

8  Examinations

8.1  Terminology

8.2  Exam Schedule

There will be three Exams, with Exam I approximately at the 3.5-week point, Exam II around the 6.5-week point, and Exam III on the last day of class, Tuesday, March 15.

Note: There is no final exam. Exam III is not a final exam; it only covers the material presented after Exam II, i.e. is not cumulative.

There are no early or late Exams. Provisions for oral makeup Exams will be made if you have a documented medical excuse.2

8.3  Open-Materials Policy

TESTS ARE TAKEN ON AN OPEN-MATERIALS BASIS. Bring the PLN with you to each exam. You are also welcome to bring whatever other materials you wish, e.g. your ECS 40 texts, dictionaries,3 whatever you want. Whatever you bring, make absolutely sure that you remember to bring all your course materials, as virtually all of the exam questions will refer to specific pages in them.
Note again that there is NO sharing of course materials, books, the PLN, calculators, papers, etc. during Tests.

8.4  How to Do Well on the Exams

8.4.1  Remember, This Is Not ECS 30/40

This course is primarily conceptual in nature, rather than being a programming course like ECS 30/40. Yes, you will do programming in the homework, and yes, some of the Test questions will ask you to do some programming, but most will not. Most will be "qualitative" questions which ask you about the nature of computer systems (albeit sometimes using programming as a vehicle to test your understanding).

8.4.2  Think, Not Memorize

The Exam questions test insight, not memorization.4 They assume active reading and thinking about the material.
If for example you encounter a statement in the reading which puzzles you, don't just skip it-ask me or the TA about it. An Exam question may later ask you to explain it.

8.4.3  Old Exams Yes, "Practice" Exams No


Please note carefully that I do not give practice exams.

This is because I believe that learning does not consist of memorizing, and because this course (in the way I teach it) is not like a "calculus-style" course:
Calculus courses can have practice exams because the real exams have predictable, technique-oriented content. In a calculus class, you might have a lecture on integration by parts, then have a homework assignment of integration-by-parts problems, and then on the exam there would be a couple of such problems.
This would be impossible in ECS 50-at least the way I teach it-because every Exam problem is unique, and the problems test understanding of concepts, rather than techniques. Thus, it would be impossible to have practice exams.
I do make my old Exams available on the Web, but they are NOT practice exams. Instead, I make them available so you can get an idea of the general "flavor" of my exam philosophy. Also, sometimes during a lecture I do mention a "focus area" that could be featured in an upcoming exam. For instance, I may say, "I really want you to know this particular example especially well," and then the Exam may contain a question (or even more than one question) on this example.

8.4.4  Homework-for-Learning Yes, Homework-as-Practice-for-Exams No

Similar to the point that I do not give practice exams, it is important to understand that the homework is not considered practice for Exams either. The goal of the homework is to give you a chance to think more deeply about the material, and to give you a chance to nonpassively implement some of the course concepts. Sometimes an Exam problem will indeed be similar to some homework problem, but most Exam problems do not look like any homework problem.
Again, the best way to prepare for Exams is to constantly sift the material through your mind in a nonpassive manner, thinking about questions involving How?, Why/Why Not? What is the goal? and so on. The homework will really help you prepare for Exams in this sense, because it will make you think thoroughly about the course material, but you should not expect problems to be explicitly similar to the homework.

8.4.5  Concentrate During Class

MAKE SURE TO LISTEN CAREFULLY IN CLASS.
Weird statement! What does it mean?

Many Exam problems will come from the answers I give to questions students ask during lecture, or will be related to off-hand remarks I make during lecture when I suddenly get an inspiration.

Therefore, listen carefully to questions students ask in class, and to the answers I give. Make a note of seemingly-casual comments I make in lecture, and think about them carefully at home. These things may well pop up in Exams. Such questions will still be answerable from the course materials if you miss class, but there is a definite advantage to paying close attention in class.

8.5  Please Note

An embarrassing subject which nevertheless must be mentioned is cheating on Tests. If a student is found to be cheating, it will be treated as a VERY SERIOUS matter, not a harmless prank; it will harm his/her standing at the university, and also possibly make it difficult for him/her to get a job when seeking employment after graduation.
Please work as follows during Tests:
During a Test, if your paper is exposed, I or the TA will come to you and mention this to you. Thanks very much for your help.

9  Lecture Format

9.1  Bring the Materials to Lecture

Make sure you bring the PLN to every lecture. They will play very active roles in the lectures.
I typically will ask you to open to a certain page, and then will call your attention to various sentences, examples and pictures on that page. The lectures will consist mainly of discussion and amplification of the examples in the PLN, with additional examples and comments. I will seldom write on the blackboard.
A MAJOR GOAL OF THE USE OF PRINTED LECTURE NOTES IS TO GIVE STUDENTS A CHANCE TO ASK QUESTIONS AND TO ENGAGE IN CLASS DISCUSSION. You are very much encouraged to bring up any questions you might have. Please don't be shy about asking questions; there is no such thing as a "dumb" question. Similarly, listen carefully to the questions the other students ask; this can be a very valuable source of insight, to which you should pay special attention.

10  The Discussion Section and Quizzes

The discussion section is required. It will be used for the purpose of giving Quizzes, and for presenting material not covered in lecture. (That material will appear on Tests.)
A Quiz will be given almost every week in discussion section. Quizzes will not be announced; assume that there will be one each week.
Quizzes will be short (10 minutes) and simple. The latter means that Quiz problems will be very straightforward and much easier than Exam questions. Their purpose is to ensure that you are keeping up with the material.
The Quizzes will be composed and graded by the TA, who will give you letter grades on them. They typically will be one or two questions in length.

11  The Class Newsgroup and Web Site

The likely names for the class newsgroups will be, depending on your section, ucd.class.ecs050.sec001 or ucd.class.ecs050.sec002.5
THE NEWSGROUP WILL PLAY A MAJOR ROLE IN OUR COURSE. IT IS REQUIRED THAT YOU READ THE NEWSGROUP EVERY DAY. Not only will announcements of homework assignments be posted there, but also there may be later corrections, hints, etc. And of course, dates of Exams and other related information will be announced on the newsgroup too.
You can read newsgroups using special-purpose programs such as tin or slrn; just type the program name, e.g. type tin when logged onto one of the CSIF machines. Or you can access newsgroup through general-purpose programs such as Web browsers.
Note that the newsgroup can be accessed only from a UCD Internet address. You will have this if you are using a campus computer or have connected to the Internet via the campus modem bank. If you are not in this setting, you can still read the newsgroup by using ssh to log on to one of the CSIF machines. and then typng tin or slrn at the UNIX command line.
Please note that ".d" newsgroups are for discussion among students. This was the original intention when they were established some years ago; it seems that instructors of ECS 30 and 40 have abandoned that concept, but I feel it is important for the students to have a place of their own, without interference from the instructor.

Thus I usually do not read the .d groups. If there is a message you want me to see, please send me e-mail, instead of posting a message which you hope I will see on the .d group.

12  Grading

12.1  Weighting

The formula used is
course grade = 0.70xExams grade + 0.15xHomework grade + 0.15xQuizzes grade

where the Exams, Homework and Quizzes grades are each on the 4-point scale (4 for an A, 3 for a B, etc.).

12.2  + and - Grades

The threshhold for a grade of n is (n-1).85; the threshhold for an `n-' grade is (n-1).6; the threshhold for a `+' grade is n.2. So, for example, if your weighted average from the above formula is between 2.6 and 2.84, your course grade is B-; if the average is between 2.85 and 3.19, your course grade is B; if the average is between 3.2 and 3.59, your grade is B+.

12.3  Exams Grade

Each exam grade will be used in letter grade form only (the numerical grades are recorded but not used).
IMPORTANT NOTE: If your first exam letter grade is lower than those of the other two Exams, and if your Homework and Quizzes grades are at least B, that first exam grade will be thrown out completely. In that case, your Exams grade will be the average of your second and third Exams. This, coupled with the fact that most of you will get a A's as your Homework and Quizzes grades, typically makes an important difference in the course grade for many students.
By the way, though, please note that this policy of course does not imply that you should not try very hard on the first exam, for many reasons:
Exam grading is noncompetitive (there is no "curve"), so it is possible for everyone to do well.

12.4  Quizzes Grade

You will get a letter grade on each Quiz.
In recognition of the fact that on (rare) occasions you will not be able to attend discussion section, your two lowest (letter) Quiz grades will be thrown out. Your other Quiz letter grades will be averaged to produce your overall Quizzes grade.
It is assumed/intended that, similar to the homework (see below), most of you will get an A grade overall for your Quizzes.

12.5  Homework Grade

12.5.1  Assignment of Letter Grades

Your letter grade on this homework will be as follows, based on your average homework score: 90-100%, A; 85-89%, A-; 80-84%, B; 70-79%, C; 60-69%, D; under 60%, F.

12.5.2  You Must Turn in All Assignments to Pass the Course

Note that all homework assignments must be completed in order to get a passing grade in the course.
In order to be considered "completed" the basic work must been done, though there may be errors. In the case of a programming assignment, for example, if the program has sections obviously missing, or if the program does not even compile, it is not considered complete.

12.5.3  You Should Get an A on the Homework

I aim for the vast majority of the class to get an A on the homework. Lots of help is available, so this aim should be achievable. (And it is; I use this policy in every course I teach, and it always works out that most people get A homework grades.)
The most important part of getting a good homework grade is to start an assignment as soon as it is assigned. Don't wait until a few days before the due date to start. And make sure you have read the PLN thoroughly before starting.

12.5.4  Back Up Your Files Frequently!

Accidental deletion or destruction of your homework files will generally not be grounds for extending the due date.

12.6  Accuracy of Records

At the end of the quarter, it will be your responsibility to make sure that the Homework Grader's records are correct as to your homework scores.

13  Machines

13.1  Linux PCs in CSIF

The main assembly language/hardware/OS we will be studying is Intel/Linux. Our base machines will be the Linux PCs in the CS instructional labs (CSIF). If you pre-enrolled in this course, or if you took a CS course last quarter, you should already have an account. Your account name will be your surname, and if that is not unique, it will be your surname followed by your first initial. Your initial password will be the last eight digits of your student number; change it immediately, using yppasswd. Note that all the instructional machines share a common file system, so you can access the files from any machine.

13.2  Linux on Your Own PC at Home

I strongly encourage you to install Linux on your PC, if you have not already done so. It will be especially useful in our course, since almost all of your homework assignments will be required to be done on Linux/Intel6 platforms.7 In addition, the mere act of installing and maintaining your own Linux system will in itself greatly deepen your insight into the course-it will be roughly the equivalent of adding 10 points to your average exam score.
Moreover, having a Linux system at home will help you with your homework in many future CS courses, and will help you do well in job interviews when you graduate.
I have a Linux installation tutorial at http://heather.cs.ucdavis.edu/~matloff/linux.html

14  Homework

14.1  Terminology

14.2  Announcements

Homework assignments will be announced in the class newsgroup. The homework files themselves will be on the course Web site, so look there when an assignment is announced.
Occasionally there will be news about a current homework assignment, such as clarifications, hints and so on. These will be announced in the class newsgroup.

14.3  Partners

You may work on and submit the homework by yourself, but you are allowed and encouraged to do your homework together with one (not more than one) partner. In the latter case, the two of you submit the homework together; make sure to inform the Homework Grader of this.
If you do work with a partner, you must work TOGETHER, instead of simply having one partner do one problem and another partner doing another problem. If the Homework Grader finds a pattern in which two partners are simply dividing the work among themselves rather than working together, he/she will not allow them to continue to work as partners.

14.4  Programming Style

Good programming "style"-good indenting, meaningful variable names, helpful comments-is extremely important. You will not be graded on style, but it is crucial for communications purposes. For example, suppose you are having trouble getting your program to work and you e-mail it to me for help. If I can't read it, I won't be able to help you.
Note that this means that you write your program in good style from the beginning. Do NOT insert indentation, comments, etc. only when you are finished with the program and ready to turn it in.
The same points apply to top-down programming. Do this not because it is required for grading (it isn't), but instead because it will make it easier for YOU, i.e. make it easier for you to write and debug your program, and easier for me to read if you ask me for help.
And for the same reason, create a Makefile, again not because you will be docked points if you don't have it but because it makes your work (and mine, if you seek help from me) easier.
By the way, speaking of programming style: You may have been taught that global variables are "evil," to be avoided like The Plague. That is far too extreme an attitude, and the reasoning used doesn't make much sense. Moreover, in many cases one must use globals. See a discussion on this at http://heather.cs.ucdavis.edu/~matloff/globals.html.

14.5  Analytical Work

Some of the homework questions may be non-programming in nature. Write these up in an ASCII text file with a name whose suffix is .txt.

14.6  Submitting the Homework

Since we use interactive grading (see below), you do not "turn in" your homework in the traditional way. However, you do have to send the Homework Grader an e-mail message of the following nature, to certify that you completed the work before the deadline.

14.6.1  Package Your Files

When you have finished all of a given homework assignment, first use the UNIX tar command to collect all your files for that assignment into one .tar file, say named Hwk2.tar. In the case of a program, this would be your files with suffixes such as .s, .c (or any standard C++ suffix), .h and your Makefile.

14.6.2  Timestamp Your Package

Then run the UNIX sum command on the .tar file to produce a checksum, which is kind of a code number which is (for all practical purposes) unique to that file. E-mail that checksum (two numbers, actually) and your .tar file name (but not the file itself), to the Homework Grader. The date and time on your e-mail will verify that you sent the mail before the deadline. Then later during the grading, the Homework Grader will run sum again, and the fact that the checksum has not changed will show that you have not changed the file subsequent to sending the e-mail.

14.7  Grading

We will use interactive grading. The Homework Grader will announce homework grading times, and each homework group will sign up for a time slot. In the case of group size of two, both members of the group must be present during the grading time. If a member misses that time, the other group member will be graded, but the one who misses the time must reschedule a time in order to receive credit for the assignment.
During a group's time slot, the group will log in to their account to access their files. They will then explain their homework solution, and in the case of a program demonstrate that it works. In the case of analytical homework, the group will explain the reasoning behind the work. The Homework Grader will ask each member of the group questions to confirm that he/she understood what they did. For example, such questions might ask why you wrote your program in a certain way, what the roles of the variables are, what numerical values the variables may have at times specified by the Homework Grader, why you did not choose certain alternative designs, and so on.
IMPORTANT NOTE: Each partner must be ready to answer questions about ALL the submitted work. This is because the two partners are supposed to work together on all the homework problems, which is very important. As a means of insuring this, the Homework Grader will assign separate grades for each group member. Normally these grades will be identical, but if there is a substantial disparity in the levels of understanding the different group members have regarding the assignment, the Homework Grader will assign different scores to each member. As mentioned earlier, if this occurs repeatedly, the Homework Grader will not allow the partners to submit work jointly anymore.

14.8  How to Do Well on the Homework

It is crucial to keep in mind that the primary purpose of the homework is to give you a chance to think about The Machine-that means high-level hardware and low-level software-rather than to develop programming skills per se. This class is not like ECS 30 and 40.
Example of what NOT to do: One time I taught this course, two students working as partners lost sight of this and got a poor grade on one homework assignment. The assignment asked the students to write two versions of a certain program and then run timing experiments to demonstrate that the version which took advantage of a certain machine feature would be faster. They found that that version ran more slowly. This should have signaled to them that they had done the program incorrectly, but they just ignored it, since they were still operating under the "ECS 30/40" mentality that the main goal is to write the program itself and get it to produce correct output. So, they lost points on that assignment. One can't blame them, but it was too bad that they got a poor grade on that assignment, and you will want to make sure you avoid such a situation.

14.9  If You Get Stuck

14.9.1  We Are Happy to Help If You Have Reached an Impasse

Please note that, unlike ECS 30/40, homework assignments here will NOT lay out a detailed recipe, with tons of hints, telling you how to do the programming problems.
The work is expected to be challenging, and is designed to be thought-provoking. This thought-provoking nature of the assignments is the vehicle by which you get to really understand the concepts. You are not necessarily expected to see right away how to do an assignment. Instead, you are expected to spend a considerable amount of time pondering the assignment, gradually seeing more and more, until you finally see how to do the whole thing. It is that thought process which will develop insight into the course material.
The TA and I will be quite happy to help you, including giving you hints individually-but only if, after giving a matter considerable thought, you still don't see what to do. Once you have reached the point where you cannot go any further, we very much encourage you to seek help from us. We want you to do well on the homework!

14.9.2  Use a Debugging Tool!

You will help yourself greatly-both in this course and in all courses in which you do programming-by making good use of a debugging tool, such as DDD/GDB.
Make sure you understand the content of my debugging slide show, at http://heather.cs.ucdavis.edu/~matloff/debug.html. Note carefully that what is important here is not merely how to use DDD, but what you should use it for. The latter consists of two categories of uses:
Category (b) here refers to confirming that each part of your code is working as you expect it to: You step through the code line-by-line, confirming that the variables have the values you expect them to, confirming that the condition in an if statement hold and don't hold, according to your expectations, etc. Eventually you will find a place where your expectation is not confirmed-and that will be a big hint as to the location and/or nature of your bug.
Keep in mind that in situation (b), DDD/GDB will not "automatically" find the location of your bug. You yourself must do that, through the confirmation process, but DDD/GDB makes this far more convenient and thus saves you a lot of time.
Do yourself a big favor: Get good at using DDD/GDB, both in this class and in others, and you will reap big benefits.
When you seek help from me or the TA, the first thing we will ask you is to show us your GDB output.8

14.9.3  When in Doubt, Check It Out!

A lot of questions are of such a nature that you can answer them on your own, just by trying it out on the computer. For example, suppose you have a question which you would like to ask which is something like "In the Intel movl instruction, can both operands be in memory?" You are welcome to ask me or the TA, but you will get your answer a lot faster if you simply try it out! Put that instruction in a small test program, and see if the assembler accepts it or not. And if you are not sure whether such an instruction does what you think it does, run the program and see!

14.9.4  Help by E-Mail

Again, you are welcomed and strongly encouraged to send me e-mail, at the address matloff@cs, for help on homework assignments. But you can help me if you keep the following in mind:

14.9.5  Start Early!

Please make sure to start the homework soon after it is assigned. Don't wait until the last couple of days before the due date, because when the due date approaches, I tend to be inundated with e-mail messages asking for help on the homework, and thus my answers at that time will necessarily be short and without details, since I won't have time to say more.

14.10  Late Work

An assignment is late if it is submitted to the Homework Grader after the due date.
If-this should never happen, but just if-you are late, you will be assessed a 5% penalty the first late day, and 10%-per-day penalty after that in your grade for that assignment. (Since e-mail is available every day, each of the seven days of the week counts as one day.) The maximum total penalty is 50%.
Each project group will be allowed a total of 2 late days over the quarter, time which is not penalized. You can use this as being late 2 days with no penalty on one assignment, or as being late 1 day with no penalty in each of two assignments.
In order to use this option, you must submit your work during the time you are using as your grace period. If for example you are 3 days late on an assignment, you will not be allowed to use your grace period time on that assignment; it will simply be counted as 3 days late.
Don't squander your grace period days in the first assignment. The subsequent ones will almost certainly be more difficult, so save your grace time for then.
The Homework Grader will keep the appropriate records as to how many days of grace period you have used..

14.11  Reading Homework

The reading-in the PLN-is extremely important, and should be considered "homework." As mentioned earlier, approximately 30-50% of the exam questions will come from the reading.
After each lecture, do the corresponding reading. Do the reading PROMPTLY, that same day, rather than getting behind. This is the only way that you can get any insight from the reading; doing the reading the night before an exam will not work. If you still have not done the reading as of the night before the exam, you actually will be better off not doing it, and getting more sleep instead, as cramming overnight won't be beneficial.

15  I Do Care!

I wish to emphasize that I care very much that you succeed in this course, and I look forward to getting to know all of you.

Footnotes:

1Not that you need a calculator anyway; you don't.
2Missed Quizzes are handled differently; see Section .
3For example, do you know what the words relinquish and discrepancy mean? These words have shown up in problem statements in Tests. I will be happy to explain any such words if you like during the Tests, but you may feel more comfortable with a dictionary.
4I've deliberately capitalized the word Exam here, in order to distinguish from Quizzes.
5I say "likely" here, because the campus IT administrators have not set up the groups yet.
6Or Intel clone chip.
7You cannot do this on a Mac. Even though Linux is also available for Macs, and even though the new Mac OS is UNIX-based, Macs use a different CPU chip, and thus have a different assembly language.
8DDD is nicer, and you should use it, but you'll need a text-based debugging session to send us, so re-do the debugging steps in GDB and send us that output.


File translated from TEX by TTH, version 3.30.
On 3 Jan 2005, 16:03.