ECE 209 Computer Systems Programming - Fall 2024 PDF
Document Details
![FabulousYellow3747](https://quizgecko.com/images/avatars/avatar-3.webp)
Uploaded by FabulousYellow3747
NC State University
Tags
Summary
This document appears to be lecture notes for a computer systems programming course at NC State University. The course covers topics such as course overview, syllabus review, high-level languages, and course content. It also mentions programming language concepts, like C and LC3, and problem-solving using pseudocode and flowchart.
Full Transcript
ECE 209 Computer Systems Programming @NCStateECE Course Overview Syllabus Review High-Level Languages Course Content C Language Programming Debugging LDR R0, R5, #0 ADD R0, R1, R0 BRnp NEXT STR R0, R5, #-2 C -> LC3...
ECE 209 Computer Systems Programming @NCStateECE Course Overview Syllabus Review High-Level Languages Course Content C Language Programming Debugging LDR R0, R5, #0 ADD R0, R1, R0 BRnp NEXT STR R0, R5, #-2 C -> LC3 NULL Data Structures Course Overview Syllabus Review High-Level Languages Texts and Tools Interactive exercises Homework Program Development Chapters 11-19 Review Ch 1-10 as needed Discussion Forum Program/HW questions Questions are Encouraged! Questions During class Please ask questions anytime Raise hand, or otherwise get my attention Outside of class Discord – feel free to answer questions, also If code-related, make it private and attach code Come By Office hours: 12:30 to 2:30 T TH Generally available 10:00 to 5:00 M W F I may request you come back later if I am busy. TA help: see Announcements/Discord for how to contact Grading Learning Activities and Assessment (50%) Practice (50%) Homework: 25% Exams: 37.5% Problem Sessions (6): 5% Final Exam: 12.5% Programs (3): 20% What you do What you know Problem Sessions In-person, required Not this week! Wait for announcement. Recommended -- bring and use your own laptop. Install CLion and make sure it works before the first problem session!!! https://upload.wikimedia.org/wikipedia/commons/c/cb/Wikimania_2016_Hackathon_01.jpg Ignore # points. Click to open assignment. Click on Assignments tab to see homeworks. Banner at the top of a section that is assigned for homework. Click on link to take you to the section. Only participation activities are assigned. Exams are hard. Exams are not easy. Exams are challenging! My Expectations want to learn attend class participate respect each other act with integrity Image generated by DALL-E 3, 7/30/24. Academic Integrity Exam C/LC3 Reference sheet Code of Student Conduct Programming MOSS = Measure of Software Similarity Academic Integrity https://scoutmastercg.com/electric-fence-bear-country/ I am committed to creating and maintaining an environment free of discrimination and harassment of any kind. Questions are Encouraged! Course Overview Syllabus Review High-Level Languages Problem Algorithm Instructions Data Registers User Interface Memory Addresses Problem Algorithm Programming Instructions Data Language Registers User Interface Memory Addresses Problem Algorithm Instructions Data Registers User Interface Memory Addresses mental effort Instructions Registers Memory Addresses Problem Algorithm Instructions Data Registers User Interface Memory Addresses Instructions Registers Memory Addresses Power of Abstraction Assembly Language: bricklaying High-Level Language: architecture High-Level Languages tip = (bill - tax) * tipRate; variables operators High-Level Languages tip = (bill - tax) * tipRate; LC3 doesn't have multiply instruction. LC3 doesn't support floating-point. NO PROBLEM!! High-Level Languages No explicit branches or labels. while (...) { if (...) { // blah blah conditional: TRUE iterative } else { // blah blah conditional: FALSE } } High-Level Languages i7 ARM i7 LC3 K. Bobrov, Grokking Concurrency, 2024 THINK! K. Bobrov, Grokking Concurrency, 2024 THINK! DO! K. Bobrov, Grokking Concurrency, 2024 THINK! DO! K. Bobrov, Grokking Concurrency, 2024 UNDERSTAND THINK! pseudocode flowchart illustration K. Bobrov, Grokking Concurrency, 2024 Program Structures Sequential Do one task after another. Conditional Do a task only if a particular condition is TRUE.... OR... Choose between two tasks, depending on whether a condition is TRUE or FALSE. Iterative Do a task again and again, until some exit condition is TRUE. What is “pseudocode”? Written version of an algorithm p: ticket price that “sort of” looks like code, age: age of buyer but using an informal, relaxed syntax. if age < 65 then print “Senior discount applies” p ← 12.50 Intended for design, not coding. else Think through the tasks that need to be done p ← 17.50 and the logic needed to control the actions. end Create your own style that allows you to think print p about the structure of the problem, and how to solve it, without worrying about coding. Define variables: symbols used to p: ticket price represent the state of the computation. age: age of buyer if age < 65 then Use keywords and indentation to print “Senior discount applies” expose the structure of the code. p ← 12.50 else p ← 17.50 Think about what must be done, end not how to do it or how to express it in a specific language. print p Sequential Conditional a,b: known sides of triangle if ____ then if ____ then do something c: unknown side do something x,y,z: temporary variables else end do this end x ← a * a // a times a y ←b * b z ←x + y c ← sqrt(z) Iterative for i from 1 to n while ____ do something a,b: known sides of triangle do something end c: unknown side c ← sqrt(a*a + b*b) end for each item in array These are examples: find a syntax that’s do something easy and comfortable for you. end Interpreter Program translate execute Compiler Program translate execute 0101011011110100 1001001010100101 1111000010101001 0101010010001110 1101001001001010 0101111000000101 0010100100100100 1110100100100010 0101010011101001 Executable The C Compiler Analysis C Source Code C Source Code.c Symbol.c Table Compiler (gcc) Library Code Generation files and Optimization Executable Other Object File Linker object.o (ld) files Linker icon made by Freepik Writing a C Program Step Tools Define/understand program Specification document objectives Consultation with client Design program Flow chart/pseudocode Design document Write source code Text editor Compile source code to create Compiler executable Linker Run executable Loader OS/runtime system Test and debug executable Debugger Testing framework #include Use the C standard library for I/O. int main() { Every program has a main function, executed when program runs. int age = 0; printf("Enter your age: "); Get information from the user. fflush(stdout); scanf("%d", &age); printf("That's %d in dog years!\n", age * 7); return 0; Calculate and print the result. } Exercise for later: Write this same program in LC3 assembly language. #include int main() { What sequence of characters int age = 0; is recognized by the compiler? printf("Enter your age: "); What keywords are defined fflush(stdout); by the language? scanf("%d", &age); printf("That's %d in dog years!\n", age * 7); return 0; } #include int main() { What is the meaning of the code? int age = 0; What is the programmer telling the computer to do? printf("Enter your age: "); fflush(stdout); scanf("%d", &age); printf("That's %d in dog years!\n", age * 7); return 0; }