CS2340 Computer Architecture
Spring 2023

Instructor: John Cole
Section 005 Monday/Wednesday from 1:00 to 2:15
Office and Hours  Room: RH West 2.401

Teaching Assistant: None

Last update: 12/23/2022
Syllabus is on Coursebook Schedule
Textbook: Computer Organization and Design, MIPS Version, sixth edition, by Patterson & Hennesey

Some consider this to be a difficult course, in part because of the low level of abstraction.  It requires a lot of work and a different way of looking at computers and programming.  On the plus side, your instructor is available outside of class, conducts review sessions, and is very knowledgeable and helpful.  So get ready to work right down on the bare metal!

Given the low level of abstraction, a 32-bit value represents exactly one thing: a 32-bit value.  What it "means" is entirely up to you.  It may be a counter, the address of the start of a list of numbers, a subroutine return address, anything.  One of the things you will figure out quickly in this class is that if you don't understand C++ pointers you will be at a serious disadvantage. If you are not clear on binary arithmetic or basics like how many bits are in a byte, take some time to review. 

Up to this point, all of your programming courses have used high-level languages with many built-in functions, classes, and other constructs that hid the inner workings of the computer from you.  Those things are great, and make it easy to write code that focuses on the task at hand.  Consider, though, that someone had to write those library functions, or the low-level drivers in the operating system, or the embedded code in your thermostat, and often at least some of that is written in assembly language.  Also consider that if you are going to understand cybersecurity, this level of comprehension of how processors actually work is essential.  Thus the need for a course in the details of computer architecture.  And besides, are you not curious as what is really going on inside the box?

As to background, I have written a great many programs in various assembly languages, starting with the Univac 1108 mainframe and, most recently, MIPS in preparation for teaching this course.  You may also be aware that at least once a year I give an introductory tutorial on x86 assembly language to the Computer Security Group.  Thus one of the unstated objectives is to teach you how to write good assembly code, not just hack together something that mostly works. This means, among other things:
  • Writing modules that assemble separately
  • Writing clean, coherent, commented, readable code, not spaghetti code
  • Using the .eqv directive and constructs like '\n' instead of the number 10 so you don't have magic numbers in your code
  • Optimizing the use of registers to make your code run fast
  • Error handling
As with any course I teach, you will do a lot of programming, which is the only way to learn how to program. (As the immortal Fred Brooks told one of his classes, "If you want to learn software engineering you have got to go out there and do software engineering.") This course will also require considerable reading.  If you do not read the textbook, you will most likely fail the course.  Trying to slide by using only the PowerPoint slides is also a really bad idea. 

Spend the time early in the semester when you are not as busy.  Learn MIPS.  Refresh yourself on the basics.  Learn how to use your study time efficiently.  It WILL pay off.   This course will require at least 6 hours per week outside of the classroom.


Since assembly language has no built-in functions the way Java and C++ do, you will have to write these.  The good news is that if you write, say, a string copy function, you can reuse it if you need it in another assignment for this class.  (You still can't use one someone else wrote.)

I will be taking attendance, and although it will not figure directly into your grade, I tend to be unsympathetic to poor students who miss a lot of classes.

I begin every class with a breathing exercise to get you centered. If you are late, please do not disturb the class if we are in the middle of it. Wait until we are done to enter or to sit down, and make as little noise as possible.

Some observations:  There are three things which most students seem nto to know that are a serious problem in this class.  If you are not intimately familiar with these concepts, now is a good time for a review.  Scroll down for some videos I recorded.  They are:
  • How C++ pointers work
  • Two's complement binary arithmetic.  Include in this hexadecimal conversion.
  • How the function call stack works
Here is a link to a hilarious article on the value of systems programming, which goes to the edge of the abyss of how things work and dives in:
The Night Watch

Interesting video on What's inside a .EXE file?  Good explanation of what happens between compiling a high-level language program and running it, as well as why we have machine code at all.

Course Topics in Detail

This course will teach you how to understand and write programs in assembly language.  While this is specific to the MIPS processor, the general techniques will be applicable to most machines.  Topics include:

  1. Basic design of modern stored-program digital computers
  2. Numbering systems and numeric formats, including floating-point numbers represented in binary
  3. Instruction set architecture
  4. Register set
  5. Assembly-language directives (also called pseudo-operations)
  6. System calls for operating system functions
  7. Translation from C to assembly language
  8. Translation from assembly language to machine code
  9. Performance calculation
  10. Memory hierarchy
  11. Processor data path and pipelining
Assembly language coding conventions

1. Use tabs.  Labels should be in column 1.  Instructions and directives should be tabbed to column 10 or 11.  Operands should be tabbed to column 18.

2. Comments on individual instructions should be tabbed to about column 30, and on the same line, not the line above.

3. Do not indent assembly code.  There is no structuring the way you would structure C++ or Java, and it makes it less readable, not more

4. Use meaningful labels.  "Do" and "while" and "loop" are not meaningful.

5. Re-read the slides from Appendix A.

For more information, see Documentation Standards


Get the MIPS simulator here: http://courses.missouristate.edu/kenvollmar/mars/

Some Mac users have had trouble getting MARS to run.  Thanks to Josh Brown, a former student, we have this:

You need to allow Full Disk Access in your System Preferences in macOS. Here they mention that you need to search for 'JavaLauncher.app'. This is an issue due to macOS changes with security management. To give Full Disk Access to JAR files on macOS:

1. Go to System Preferences.
2. Click on Security and Privacy.
3. Search for 'Full Disk Access'.
4. Click on the lock at the bottom left to be able to make changes.
5. Click on the '+' icon at the bottom left of the FDA panel and a Finder prompt will appear.
6. Go to System/Library/CoreServices/JavaLauncher.app
7. Select the JavaLauncher.app and click 'Open'


That's it. You should be able to access files through your Java application. This helped to fix my issue with MARS MIPS not saving files properly on my laptop. I constantly needed to save it elsewhere.

 

Video of Binary Arithmetic

Video of the Function Call Stack

Video of Pointers

Exam Rules