2018 CMSI 2210: Computer Systems Organization

CMSI 2210: Welcome to Week 01


Today, the first day of the semester, will be a pretty typical 'first day of class'. We'll cover the course syllabus, then take a brief tour of the course website so you'll know where to find your reading and homework assignment information.

Then during the rest of the week we will begin to look at some of the fundamental tools and development environment things you will need for the semester.

Finally, we'll end up with a little coding exercise which will make sure your C programming environment is set up.

The Grand Tour

First things first:

A little welcome message…

First we need to cover the basics, since fundamentals are critical to success in anything!

Helpful Links and Programming Information

Textbook links

There is no assigned textbook for this course. There are a number of books that address the concepts we will study, but they are all very expensive. While they do collect the information all in once place for convenience, you can find all the information on the Internet if you just apply yourself a bit. In addition, here are some very useful and informative links to related material:

Tools you will use during the semester

The following items will be stuff you need to do the work in this course:

Initial Roll Call And Other Sundries

…Just to make sure we're adults…

And now for the dreaded pariah of all classes, the tell-the-professor-all-about-me excercise, which is guaranteed to have you all shifting uneasily in your seats! So, tell me a little about yourself, including:

Assignment Submissions

Homework assignments for this class will be done in pairs. For each assignment, you and your partner will turn in ONE copy of the assignment. Assignments are mixed, with exercises consisting of both programming projects and short answer questions. As many of you may have heard, I'm a big believer in fostering critical thinking skills, so there will be questions that are intended to make you think about what you are doing in various respects like morals, ethics, and decomposition of problem statements.

All homework will be submitted in GitHub. Please get an account if you don't already have one, and make a repository for this class. NOTE: because the assignments will be done in threes, you will need a single account for your team. If you WANT to make three accounts you are welcome to do so, but please be sure that I know which account will be the one you are using for the submissions. Note that means ONLY one account for submissions for the ENTIRE SEMESTER! I don't want to go chasing around through multiple repo's to find your submissions.

Please name your repo using the phrase "CMSI-2210" in the name, followed by the names of the team members. For example, if Anais Nin, Talia Shire, and Pablo Picasso are in a group, name your repo CMSI-2210_NinPicassoShire. Under your repository, please generate the following FOLDER structure:

I will be using this folder structure to perform the evaluations of your work. I use the GitHub desktop on my Windows machine to duplicate [clone] your repo locally for doing those evaluations, and I have several scripts that I set up to facilitate compiling/assembling and running your programs. Any deviation from the above structure means my scripts will not work with your submissions, and you will NOT earn any credit.

The time for submitting code with compile errors is past with the passing of CMSI 185/186/1010. In those courses, I had a nominal policy of correcting compile errors if there were only one or two obvious ones. I will NOT be following that policy in this course, so make sure your code compiles/assembles FROM THE COMMAND LINE before you turn it in. I will be demonstrating how to do that in class in case you are unfamiliar.

REMEMBER: I use the command line for compiling/assembling and running your programs. If you are using an IDE like NetBeans, VS-Code, or Eclipse, be sure your program can be successfully compiled/assembled from the REAL command line, and that it runs that way as well. It's an extra step for some of you, yes, but this operation/activity reflects the real world of software development – just because it works for you in Eclipse doesn't mean that the USERS who run your code will be running it from Eclipse, if they even HAVE Eclipse. Most of your users will think Eclipse is that thing that happens in the sky with the sun.

Development Notes

You will be learning the C language during this course. You won't be experts, but you will be learning enough to be able to complete the course and to understand the concept of pointers, addressing, and memory allocation.

You will also be learning assembly language during this course. Again, you won't become an expert, but you WILL get experience with how assembly lets you access the lowest levels of processor operations, which s a fundamental knowledge of how programs and applications work. Many students absolutely HATE assembly, because it can be difficult to get things to work properly since the concepts are so low-level. However, if you apply yourself and take the challenge, assembly can actually be fun, because you have full control of the computer and can make it do all sorts of things that are much more difficult [even impossible!] in any other language.

Homework Assignments…

Since there is not a textbook, homework assignments will be taken from other places. Most, if not all, of the programming assignments can be found, with their corresponding [potential] solutions, on the Internet. However, as clearly stated on the syllabus page, copying code from the Internet is plagiarism, unless you cite where you got it! If you download a solution to turn in, put a comment in the code in a header at the top of the file that says where it came from. You had also better be able to tell me HOW IT WORKS AND WHY IT'S A GOOD SOLUTION so that I can assess if you really understand it. Deviation from this policy will earn you a grade of zero on the assignment.

Basics of C

Practically since the time it was invented, people have hated programming in this language. It can be very tricky to use, since even though it is considered a 'higher level' language, it is only one step removed from assembly language. This makes it very fast, and speed is essential to success in many applications such as embedded sensor systems, avionics, automobiles, and operating systems. However, the idea of memory allocation, pointers, structures, and other such concepts are very confusing at first.

C is a compiled language, but it's not compiled like Java. As you know, when you make a Java program, you compile it to byte code, then you start the JVM to run the program. The JVM handles all the access to operating system functions for you. However, with C you must handle such things yourself. There is no virtual machine middleware, your program is compiled directly to binary that the computer can execute, and is linked with a set of libraries that handle a lot of the low-level operating system calls for you.

First things first: we will be using the command line! There is a brief list of common commands on the course web site at this link. I recommend that you read it and get familiar with these commands. Second, you are free to use an IDE to develop your code if you wish; but be aware that when I evaluate your work, I will be using the command line! Any code that doesn't work when I type in the command manually will not be given a grade.

The definitive book on the C language is still the K & R book written by Kernighan and Ritchie sometime in the last century. In some ways, the language has changed a lot. In other basic ways, it is pretty much the same as it always was. It is those same parts we'll be using. If you can find a copy of the book you might snag a copy for yourself. For those who are looking to get into embedded systems programming it will be WAY more than just a doorstop or paperweight. The ISBN is 978-0131103627.

Traditionally, the first program in any language is the hello world program. Actually, this probably started with C, since it is the first thing in the book. The program looks like this:

   #include <stdio.h>

   int main( int argc, char * argv[] ) {

      printf( "\n\n   Hello, world!\n\n" );


This should look very Java-esque to you, and for good reason. In fact, Java syntax [according to the Nutshell book] was initially modeled on the C language. I'll pick this program apart during class. This is the first program you will use to verify that your development environment is set up and working properly.

Much of the language consists of standard libraries. There are quite a few of them, but you will most often use the stdio, stdlib, string, and a few others. We'll see them during the course. The point here, though, is to notice the #include line at the top of the file [which is pronounced pound include]. Here is a link to a very good [reference] website for learning all about the C standard library.

C is statically typed, just like Java. You must declare the variables' types, and they must remain that type for the duration of the program or module [scope-based]. There are LOTS of types, and there is type coersion and casting as you'd expect. Vanilla C doesn't have objects, and that's another reason people don't like it; instead you have structs or structures, which allow you to define aggregated user-defined data types, that are like an object, but are NOT an object. There are 'strings', but they are treated as sequences [arrays] of characters and always must end with a null character, which in this language is the sequence \0. Sometimes it is put on the end of the string automatically by a function, and sometimes you have to add it yourself. Another thing which gives people fits is variable addressing, also known as pointers. This concept allows the programmer to de-reference a variable. We'll see how all this works as we go along.

We Have Sample Programs…
Get 'em While They Are HOT!!!

One of the first things we'll learn about C programming is that there are LOTS of ways to make the programs and make them correctly. To start with, let's take a look at an old standby, a program to convert Fahrenheit to Celsius. Here is what it looks like in JavaScript:

   let f = parseFloat( prompt( "Enter a temperature in degrees Fahrenheit: " ))
   alert( f + " degrees F is " + (((f - 32) * 5) / 9) + " degrees C." );

Note that it's two simple lines.

In Python it looks like this:

   f = float( input( "Enter a temperature in degrees Fahrenheit: " ) )
   print( f, "degrees F is ", (((f - 32) * 5) / 9), " degrees C" )

In Java it looks like this:

   import java.util.Scanner;
   class CtoFconverter {
      public static void main( String args[] ) {
         System.out.println( "Enter a temperature in degrees Fahrenheit: ");
         Scanner myInput = new Scanner( System.in );
         double degreesF = Double.parseDouble(myInput.nextLine());
         System.out.println( degreesF + " degrees F is " + (((degreesF - 32.0) * 5.0) / 9.0) + " degrees C." );

[Note to self: several things about this code to the class.]

Now, here it is in C:

#include <stdio.h>
#include <stdlib.h>

int main( int argc, char * argv[] ) {

   double degreesf;
   char   input[25];
   printf( "Enter a temperature in degrees Fahrenheit: " );
   degreesF = atof( gets( input ) );
   printf( "%10.3f degrees F is %10.3f degrees C. ", degreesF, (((degreesF - 32.0) * 5.0) / 9.0) );
   exit( 0 );


[Note to self: several things about this code to the class.]

The Venerable Command Line

As far as commanding the computer goes, ANYTHING you can do in a GUI, you can do from the command line!

Sometimes this seems a bit counter-intuitive, because we have all become so used to using the Graphical User Interface [GUI] that we don't even stop to think about it. However, back in the days BEFORE there WAS a GUI, there was ONLY the command line, and we got along just fine! [An interesting read about this by author Neal Stephenson of Snow Crash fame is available for download as either a zip file for Windows or a stuffit file for Mac at this link.]

The first thing to realize is there are two different versions of the command line, one for Windows and one for Mac, and they have different commands to do the same operations. We'll see how this goes in a few minutes.

The second thing to realize is, there are multiple versions of the command line based on which version of UNIX/Linux you are using. For most Mac users, that will be the bash shell, which may be familiar to many of you. The word shell is applied to the Command Line Interpreter, also known as the CLI, which is the part of the O/S that interprets typed user commands on the command line.

However, once we get into Ubuntu, you are allowed to use any one of several different shells that are all shipped with the Ubuntu O/S. These shells have many MANY commands in common, but tend to handle some of the more esoteric options differently. We'll be using the Bash shell for all of our stuff in this class, when we talk about Mac O/S, and the cmd window for everything Windows-related.

For now, just know that there are many shells, including bash, c-shell, Bourne shell, korn shell, Fish shell, Z-shell, and several others.

Some of the VERY basic commands are listed on this page of the web site so that you can have easy access to them. A simple Internet search will turn up hundreds or thousands of help pages as well, no matter what platform you are using.

[move along to demonstrate some common commands in Windows. Don't forget to bring in a Mac if possible, or borrow one from a student to plug in for a terminal window demonstration.]

In-class Assignment #1

The purpose of this assignment is to make sure that you have all the parts set up for doing the work that will be part of this course. There are two parts: in part one you will work in class to get the coding environment set up and verify that it works; in part two you will modify the initial code from this classwork exercise

  1. Install a text editor on your computer if you haven't already done so.
  2. Install the GCC compiler on your computer if you haven't already done so; check to see if it's there on a Mac by opening a terminal window and typing gcc.
  3. If you type gcc and press ENTER and you get an error message that says:
    gcc: fatal error: no input files
    compilation terminated.

    …then you are good to go. This error simply means the operating system found the gcc program but you didn't give it a source file to work with.
  4. Create a file called sayhello.c in a directory of your choosing by whatever method you are comfortable with.
  5. Edit the file and create a program that will simply print Hello, World! to the console using printf(); you'll need to include the stdio.h header file. Use the code shown in the previous example for F to C conversions as a model.
  6. Compile your program with the GCC compiler using the command:
       gcc sayhello.c -o sayhello
  7. Run your program to make sure everything works.
  8. Go to GitHub and set up your repo and submission structure if you haven't already done so.
  9. Upload and commit your completed sayhello.c file to your repo.
  10. Pat yourself on the back for a job well done! [Just don't hurt yourself…]

Homework Assignment #1

I wanted to give you a heads-up on the homework assignments that you will be doing this semester. They are all available from the syllabus page, but just to make sure… Assignment number one is due Wednesday/Thursday this week. Assignment number two is due in week 3, which will give you a little extra time to incorporate the material to which that assignment pertains.

Week One Wrap-up

That's probably enough for the first week. Be sure to check out the links to the related materials that are listed on the class links page. Also, don't forget the project page!

I hear, and I forget.
I see, and I remember.
I do, and I understand.
Ancient Chinese Proverb