COMS W1004 Introduction to Computer Science
Download
Report
Transcript COMS W1004 Introduction to Computer Science
Announcements
• Homework #8 due Monday 6:00pm.
– extra credit tasks are described at bottom of
assignment page
• Upcoming office hours:
– Tomorrow: Sheng 12-1:30pm, Greg 1:30-3pm
– Saturday: Greg 2-4pm
– Sunday: Chris 2-4pm
– Monday: Sheng 12-2pm, Chris 2-4pm
• Please fill out the course evaluations!
Today
• Preview of CIT 595
• Final course grading
• Final exam stuff
CIT 595
• “Digital System Organization & Design”
•
•
•
•
Originally very hardware focused
Then some OS concepts introduced
Then pretty much an OS course
Now a systems programming course
What you’ll learn in CIT 595
• More C (function pointers)
• C++: “C with objects”
• Linux systems programming
– Interacting with the operating system
– Parallelism and synchronization
– Inter-process communication
– Networking
What to expect from CIT 595
• A lot of programming
• No, seriously, a
LOT
• Longer, more challenging programming
assignments
• More application and less theory
Grading Guidelines
•
•
•
•
•
•
Homeworks: 50%
Lab assignments: 10%
Midterm exam: 15%
Final exam: 25%
Current weighted average: 90.3%
Projected weighted average: 86.9%
97+
A+
87-90
B+
93-97
A
83-87
B
90-93
A-
80-83
B-
Final Grading
• Homework #6 should be graded by this weekend
• Homeworks #7 and 8 should be graded by the final
exam date (Dec 17)
• Final exams should be graded by Dec 19
• Final course grades should be posted on Dec 21
Final Exam Logistics
• Monday, Dec. 17, 6-8pm
• Location: DRL A6
• You can use your book, notes, etc.
• No electronic devices!
• Review session... when?
• Sandwiches, sodas, snacks, etc. will be provided
from 5-6pm that evening in Levine 307
Final Exam Material
• Patt & Patel chapters 2-14, 16, 18-19
–
in other words, pretty much the whole book
except for chapters 1, 15, and 17
• x86 architecture (Appendix B)
• Data structures
• No UNIX stuff from lab!
• No computer science history!
• About 25% pre-midterm stuff, 75% stuff from
after the midterm
Format of the exam
• Multiple-choice definitions/concepts
• Short answer and problem solving
– Like midterm and questions from book
• Understanding C and assembly code
• Modifying C and assembly code
• Writing C code (around 15-20 lines max)
– no writing LC-3 from scratch!
Preparing for the exam
• Documents in Blackboard:
–
–
–
study guide (list of questions from book)
practice questions (and solutions)
solutions to homework assignments
• Form a study group
• Ask questions on Piazza
Computer Numbers (Chp. 2)
• Unsigned binary integers
– Decimal-to-binary conversion
– Hexadecimal numbers
– Unsigned binary arithmetic
• Signed binary integers
– Sign/magnitude
– Two’s complement
– Overflow
Computer Numbers (cont.)
• Floating point representation
• Logical operations and bit vectors
• Character representation
– ASCII
– Unicode
Digital Logic (Chp. 3)
• p-type and n-type transistors
• NOT, AND, and OR gates
• Sum-of-products algorithm
Combinational Logic Circuits (Chp. 3)
• Adder (1-bit, 4-bit, n-bit)
• Decoder: n inputs, 2n outputs
• Demultiplexer: 1 input, n select lines, 2n output
• Multiplexer: 2n inputs, n select lines, 1 output
Memory (Chp. 3)
• R-S Latch: depends on “state”
• Gated D Latch: single bit of memory
• Register: some number of Gated D
Latches that form a single unit of memory
von Neumann Architecture (Chp. 4)
• Memory
–
–
address space vs. addressability
MAR and MDR
• Control Unit
–
–
–
fetch, decode, execute
IR and PC
ALU, registers
LC-3 Instruction Set Architecture (Chp. 4)
• Instruction format
– Opcode
– Operands
• Translating from assembly language to
machine language
• Types of instructions & what they do
– ALU operations
– Data movement operations
– Control operations
x86 Architecture (Appx. B)
• How is it different from LC-3?
–
–
–
–
–
–
addressability
address space
number of registers
size of registers
number of operations
size of instructions
Assembly Language (Chp. 7)
•
•
•
•
•
Symbol table
Finding and fixing bugs
What does this program do?
How can this program be improved?
Relation with higher-level language (like C)
• BLKW, FILL, and STRINGZ
Traps, Interrupts, Subroutines (Chp. 8-9)
• How are subroutines called? How does the
program know where to go back to?
• How do traps work? How does the program
know where to go back to?
• How do interrupts work? How is the state
saved? What happens when the handler
finishes?
• Traps: GETC, IN, OUT, PUTS, HALT
Memory and the Stack (Chp. 10)
• What is the stack used for?
• What is the stack pointer? Frame pointer?
• What values go on the stack when a
function is called?
C Basics (Chp. 11)
• Compilation process
– Preprocessor
– Compiler
– Linker
• Anatomy of a C program
• Primitive Datatypes
Variables and Operators (Chp. 12)
•
•
•
•
•
Legal variable names
Mathematical operators
Assignment shortcuts
Scope
printf and scanf
Loops & Conditionals (Chp. 13)
• Logical operators
• Comparison operators
• True & False
• if, if/else
• while, do/while, for
Functions (Chp. 14)
• Function declarations/prototypes
• Input & Output
• Call-by-reference vs. Call-by-value
Arrays & Strings (Chp. 16)
• Declaring and initializing arrays
• Indexing arrays
• Declaring strings
• Null-terminated strings
• String functions
– strlen, strcmp, strcat, strcpy
What gets printed?
1
char values[] = { '5', 73, '3', 0 };
2 int x = values[values[values[3]]-
values[2]];
3
int y = (char)x - '0';
4
int z = values[y];
5
if (z & values[z]) z = ++z;
6
printf(“z is: %d\n”, z);
1
int one(int a, int b) {
2
int k, t;
3
k = a - b;
4
t = a + b + 1;
5
if (k % 2 == 0) return t;
6
else return 0;
7
}
8
9
int two(int x, int y) {
10
int m;
11
return m + x + y;
12
}
13
14
main() {
15
int result = two(5, one(4, 3));
16
printf(“result is %d\n”, result);
17
}
Pointers (Chp. 16)
• pointer syntax
• passing pointers as function parameters
• pointers vs. arrays vs. strings
1
2
3
4
5
6
7
8
9
10
int apple;
int *ptr;
int **ind;
ind = &ptr;
*ind = &apple;
**ind = 123;
ind++;
*ptr++;
apple++;
printf(“%d %d %d”, ind, ptr,
apple);
Structs (Chp. 19)
• defining a struct
• typedef
• pointers to structs
Data Structures
•
•
•
•
•
Linked List
Stack
Queue
Binary Search Tree
Hashtable
• Concepts (how they work)
• Implementation in C
Final Exam Logistics
• Monday, Dec. 17, 6-8pm
• Location: DRL A6
• You can use your book, notes, etc.
• No electronic devices!
• Sandwiches, sodas, snacks, etc. will be provided
from 5-6pm that evening in Levine 307
Any questions?
The end.
(thanks!)