CA
Computer Architecture
Computer Architecture
Course Description Overview of computer system organization and communications; introduction to combinational and sequential logic, arithmetic, CPU, memory, microprocessors, and interfacing; assembly language programming; microarchitecture and microprogramming.
TA none :(
Textbooks
(required) A.S. Tanenbaum, "Structured Computer Organization," 6th ed., Prentice Hall, Upper Saddle River, NJ, 2005; ISBN-13: 978-0132916523.
(optional reference) Intel® 64 and IA-32 Architectures Software Developer’s Manual Combined Volumes: 1, 2A, 2B, 2C, 2D, 3A, 3B, 3C, 3D, and 4
(additional, optional) Kip Irvine, "Assembly Language for x86 Processors"
Required Windows Software Visual Studio Community 2019 (or newest version). Install Visual C++. Currently available for free download from here.
Course Learning Objectives
develop an understanding of computer systems organization
become proficient at binary arithmetic
be able to compare and contrast current, popular CPUs with regard to microarchitecture and instruction set architecture
become proficient at 32-bit Pentium 4 assembly language programming
become familiar with microcontrollers
Course Learning Outcomes
An ability to apply knowledge of computing and mathematics appropriate to the discipline. Performance indicators: Use discrete mathematics, probability, statistics, and/or calculus.
An ability to analyze a problem, and identify and define the computing requirements appropriate to its solution. Performance indicators: Identify algorithms necessary for a solution; suggest two or more solutions, and select the best solution.
An ability to use current techniques, skills, and tools necessary for computing practice. Performance indicators: Program in a suitable computer language; utilize problem solving skills, tools, and techniques to complete the task.
Prerequisites An introductory programming course in Java, C, or C++ (or permission of instructor).
Major Topics
milestones in computer architecture
Pentium, microcontrollers, and JVM
computer systems organization
binary numbers & arithmetic
instruction set architecture level
assembly language level
microarchitecture level
digital logic level
functions (chapter 5)
addressing modes (chapter 5)
inline assembler
If you have not done so already, install Visual C++ yesterday! The purpose of this assignment is to explore basic Intel integer arithmetic instructions. Create a new VC++ console app as described in class. Your project should consist of main.cpp (where main resides), and an asm file called addem.asm. Here is the complete code for main.cpp:
//main.cpp : This file contains the 'main' function.
// Program execution begins and ends here in main.
#include <stdio.h>
extern "C" {
int tst ( void ); //an external assembler function
};
int main ( int argc, char* argv[] ) {
int result = tst();
printf( "sum is %d \n", result );
return 0;
}
In addem.asm, define 2 symbols, A and B, with the values of 1 and 12 (octal), respectively. Also define 2 32-bit integer variables, X and Y, and initialize them with the values of A1 (hex) and 11001001 (binary), respectively. (Enter the values in these bases. Do not convert them to other bases (like base 10) and then enter them (in base 10).) Also define a 32-bit integer variable called sum.
i. Define a function (a proc) called tst (in addem.asm).
ii. Add all 4 of them together (in addem.asm).
iii. Save the sum in a variable called sum (in addem.asm).
iv. Before tst returns, make sure eax contains the sum.
v. Using the debugger, set a breakpoint in tst at the return instruction. Run your program with the debugger. Display the contents of the registers. Make a screen capture to submit later.
Deliverables: Submit main.cpp, addem.asm, and the screen capture via Canvas. Also, submit your answers to the following questions.
(a) What value for sum is in eax?
(b) What return value is printed in main.cpp?
(c) Why are they not the same?
(d) Create (typically via print or save as) a pdf of addem.asm so that I can make sure that you properly indented your code. All and only line labels should appear in column 1. (Exception: Major/important comments may appear in column 1 as well.) All opcodes and pseudo ops should be indented and line up with each other. All operands and pseudo op data should be indented and line up with each other. Each line should end with a comment that is indented and line up with each other.
Use the program that you developed for the previous assignment as the basis for this assignment. Here is the code for main.cpp.
//main.cpp: This file contains the 'main' function.
// Program execution begins and ends here in main.
#include <stdio.h>
extern "C" {
int avg ( void ); //an external assembler function
//int divZero ( void ); //an external assembler function
};
int main ( int argc, char* argv[] ) {
int result = avg();
printf( "avg is %d \n", result );
//divZero();
return 0;
}
The purpose of this assignment is to explore the div or idiv integer arithmetic instructions. Create a file called moreMath.asm. In it, create a function called avg that calculates the sum and average. Before avg returns, make sure eax contains the average. Using the debugger, set a breakpoint in avg at the return instruction. Run your program with the debugger. Display the contents of the registers. Make a screen capture to send later. Answer the following questions. Q1. What and where are the values of the result and remainder (as calculated by the processor)? Q2. What is the average value in eax? Q3. What return value is printed in main.cpp? Q4. Why does the value in Q2 appear to different from Q3?
After you have the above working properly, uncomment the divZero extern and function call in main.cpp. Then copy your avg function to another one called divZero. Then modify it as follows. Instead of your code calculating the average, change the code to purposely divide the sum by 0. Answer the following question. Q5. What (if anything) happens when you run your program?
Upload your work into Canvas.
Here is C++ code for main that you must use for this assignment:
//
// use this to front-end calc.asm.
//
#include <stdio.h>
//vars and funcs defined elsewhere (in asm)
extern "C" {
void calc ( void );
int getSum ( void );
int getAvg ( void );
int getMin ( void );
int getMax ( void );
int getCnt ( void );
};
int main ( int argc, char* argv [] ) { //where the magic begins!
printf( "hello \n" );
calc();
printf( "sum = %d \n", getSum() );
printf( "avg = %d \n", getAvg() );
printf( "min = %d \n", getMin() );
printf( "max = %d \n", getMax() );
printf( "cnt = %d \n", getCnt() );
printf( "goodbye \n" );
return 0;
}
Use the assembler code that you developed for the previous assignment as the basis for this assignment. (If you have difficulties, do it Java first.) The purpose of this assignment is to explore conditional branch instructions. Define 5 32-bit signed integer variables, X0, X1, X2, X3, and X4. Initialize them with the values 5, 1, 100, 90, and -10 (all base 10), respectively. Then do the following.
Part A. Define a function/proc called calc that does the following:
Add all of these variables together. Save the sum in a variable called sum (that you define, of course).
Determine the (integer) average of the values. Save the result in a variable called avg.
Determine the min of these values and save it in a variable called min.
Determine the max of these values and save it in a variable called max.
Count the number of these values that are less than the average and save it in a variable called cnt.
Part B. We need an easy way to "communicate" the above calculated values back to the C/C++ world. Until we explore more advanced techniques, simply code additional functions like below for each of the calculated variables sum, avg, min, max, and cnt.
getSum proc
mov eax, sum
ret
getSum endp
Deliverables: Upload calc.asm. Run your program, obtain a screen capture, and upload it.
midterm: 1.1, 1.7, 1.9, 1.10, 1.11, 2.1-4, 2.7-10, 2.11, 2.18, 2.26, 2.26
final: 5.1, 5.6, 5.8, 5.23, 5.24, 5.26, 5.34, 7.1, 7.4, 7.5, 7.6, 7.8, 7.9-12