Tools of the Trade The C Language Laboration 04. Outline. 1 Tools of the Trade. 2 The C Language. 3 Laboration 04
|
|
- Piers Mosley
- 5 years ago
- Views:
Transcription
1 Outline 1 2 3
2 GNU Project GNU Project - Free Software(?) Licensed under GPL(v2 v3) - GNU Public Licence. Freedom to modify, bound to distribute source (if you distribute it!). Effort initiated (announced) by Richard Stallman in (Recursive acronym GNU s Not Unix)
3 Toolchain from MIPS Technologies (GNU-based) Tool Input Output sde-gcc C asm sde-as asm object sde-ld object executable sde-objdump (object executable) text make text n/a Called toolchain for the obvious reason, i.e. tools are chained to produce an executable: sde-gcc sde-as sde-ld.
4 GNU Compiler Collection Supported languages (front-ends) gcc C g++ C++ gfortran Fortran gcj Java gobjc Objective-C gobjc++ Objective-C++ gnat Ada
5 gcc (from GNU Compiler Collection) Why gcc? De facto standard compiler for UNIX-like systems. Very good support for both C89 and C99 (ANSI- and ISO-standards). Produces fairly optimized code (better for some targets, worse for others). Supports a large number of targets Approx. 20 in mainline (IA-32, IA-64, MIPS, ARM, etc.). At least 20 in branches (MSP430, PIC24, PDP-10, etc.). Why the C language? We will get back to this question later (when introducing the C language).
6 Toolchain from MIPS Technologies (GNU-based) Tool Input Output sde-gcc C asm sde-as asm object sde-ld object executable sde-objdump (object executable) text make text n/a Called toolchain for the obvious reason, i.e. tools are chained to produce an executable: sde-gcc sde-as sde-ld.
7 GNU Binutils Tools as Assembler ld Linker objdump Diplays information about object/executable files. (Many more but we will not discuss them today... ) Supported languages/targets IA-32, IA-64, MIPS, ARM, MSP430, etc. Why binutils? Straightforward translation from asm to binary format, no real reason to re-invent the wheel...
8 Toolchain from MIPS Technologies (GNU-based) Tool Input Output sde-gcc C asm sde-as asm object sde-ld object executable sde-objdump (object executable) text make text n/a Called toolchain for the obvious reason, i.e. tools are chained to produce an executable: sde-gcc sde-as sde-ld.
9 GNU Make make features Resolving build-dependencies Parallel compilation Scriptable (not always intuitive) Why make? Again, de facto standard on Unix-like systems. Is not tied to any specific language, hence you can use it for anything!
10 Toolchain from MIPS Technologies (GNU-based) Tool Input Output sde-gcc C asm sde-as asm object sde-ld object executable sde-objdump (object executable) text make text n/a Called toolchain for the obvious reason, i.e. tools are chained to produce an executable: sde-gcc sde-as sde-ld.
11 Putting it all together... make lib0.c lib0.s lib0.o lib.a lib1.c lib1.s lib1.o app.c app.s app.o app gcc as ld
12 Brief History Initially developed between 69 and 73 by Dennis Ritchie. Language for developing system software (operating systems). First standard in 78, The C Programming Language (or K&R). ANSI standard in 89, referred to as C89 (or ANSI-C). ISO standard in 90 (called C90) equivalent to C89. Second ISO standard in 99 (called C99) extends C89. Third ISO standard C1X is work in progress...
13 Features/Strengths/Weaknesses Low-level access to memory, and manual memory management. Straightforward compilation process (easy to write compilers). Designed to map efficiently to machine-specific instructions. Basic type-system, extendable with user-defined types. Higher abstraction level than assembly, but still low-level enough to replace assembly. Despite the low-level nature of the language, it s still used to write portable code. If there is a processor X, then there exists a C compiler Y for that processor (probably).
14 Numeric types char Integer, smallest a integer type. short Integer, larger or equal to char. int Integer, larger or equal to short (native type). long Integer, larger or equal to int. float Single-precision floating point number. double Double-precision floating point number. a Size is defined as number of bits.
15 Signedness of Integer Types All integer types can be prefixed with either signed or unsigned. char is either signed or unsigned (implementation defined), all other numeric types default to signed. Implementation-defined Behavior Allows the compiler-writer some leeway when implementing a feature of the language. However, the compiler-writer must document how implementation-defined features are implemented. Undefiend Behavior There is no definition of how the resulting program should behave when the source contains undefined behavior.
16 Implementation-defined Behavior Matters! Right-shifting in C is denoted by the >> operator (e.g., -1 >> 4). Is the right-shift operator arithmetic or logic? Implementation-defined, but as a rule-of-thumb: arithmetic if the processor has an arithmetic right-shift instruction.
17 Pointers Constructed using the address-of operator & (e.g., &value). The value that a pointer points to is obtained using the * operator (e.g., *pointer), a.k.a dereferencing. Either has a known type (e.g., int *, float *) or an unknown type void (i.e., void *). Increasing or decreasing a pointer value will automatically add the correct value (derived from the size of type). Pointer is invalid if equivalent to the NULL-pointer. The Second Commandment for C Programmers Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end.
18 Arrays Elements of an array have the same type (e.g., char string[4]). Arrays are (in essence) a continuous chunk of memory. Arrays are indexed using the [] operator (e.g., array[4]). Arrays elements are indexed from 0 (i.e., 0 is the first element). Accessing an element outside the array is undefined behavior (and no compiler will stop you!).
19 Arrays and Pointers It is very hard to distinguish between pointer and array variables just by looking at their usage (syntax). Compiler implicitly converts between pointers and arrays. Assuming that a variable is a pointer when it is an array can be fatal!
20 Reversing a String in C 1 #define STRING LENGTH 12 2 const char * const string in = Hello World! ; 3 char string out[string LENGTH+1] = {0}; 4 5 void rev(const char *, char *, int); 6 7 int main(void) 8 { 9 rev(string in, &string out[string LENGTH-1], STRING LENGTH); 10 } void rev(const char *from, char *to, int copy) 13 { 14 if (copy!= 0) { 15 rev(from+1, to-1, copy-1); 16 *to = *from; 17 } 18 }
21 Reversing a String in C 1 #define STRING LENGTH 12 2 const char * const string in = Hello World! ; 3 char string out[string LENGTH+1] = {0}; 4 5 void rev(const char *, char *, int); 6 7 int main(void) 8 { 9 rev(string in, &string out[string LENGTH-1], STRING LENGTH); 10 } void rev(const char *from, char *to, int copy) 13 { 14 if (copy!= 0) { 15 rev(from+1, to-1, copy-1); 16 *to = *from; 17 } 18 }
22 Reversing a String in C 1 #define STRING LENGTH 12 2 const char * const string in = Hello World! ; 3 char string out[string LENGTH+1] = {0}; 4 5 void rev(const char *, char *, int); 6 7 int main(void) 8 { 9 rev(string in, &string out[string LENGTH-1], STRING LENGTH); 10 } void rev(const char *from, char *to, int copy) 13 { 14 if (copy!= 0) { 15 rev(from+1, to-1, copy-1); 16 *to = *from; 17 } 18 }
23 Reversing a String in C 1 2 const char * const string in = Hello World! ; 3 char string out[13] = {0}; 4 5 void rev(const char *, char *, int); 6 7 int main(void) 8 { 9 rev(string in, &string out[11], 12); 10 } void rev(const char *from, char *to, int copy) 13 { 14 if (copy!= 0) { 15 rev(from+1, to-1, copy-1); 16 *to = *from; 17 } 18 }
24 Reversing a String in C 1 2 const char * const string in = Hello World! ; 3 char string out[13] = {0}; 4 5 void rev(const char *, char *, int); 6 7 int main(void) 8 { 9 rev(string in, &string out[11], 12); 10 } void rev(const char *from, char *to, int copy) 13 { 14 if (copy!= 0) { 15 rev(from+1, to-1, copy-1); 16 *to = *from; 17 } 18 }
25 Reversing a String in C 1 2 const char * const string in = Hello World! ; 3 char string out[13] = {0}; 4 5 void rev(const char *, char *, int); 6 7 int main(void) 8 { 9 rev(string in, &string out[11], 12); 10 } void rev(const char *from, char *to, int copy) 13 { 14 if (copy!= 0) { 15 rev(from+1, to-1, copy-1); 16 *to = *from; 17 } 18 }
26 Reversing a String in C 1 2 char *string in = Hello World! ; 3 char string out[13] = {0}; 4 5 void rev(char *, char *, int); 6 7 int main(void) 8 { 9 rev(string in, &string out[11], 12); 10 } void rev(char *from, char *to, int copy) 13 { 14 if (copy!= 0) { 15 rev(from+1, to-1, copy-1); 16 *to = *from; 17 } 18 }
27 Reversing a String in C 1 2 char *string in = Hello World! ; 3 char string out[13] = {0}; 4 5 void rev(char *, char *, int); 6 7 int main(void) 8 { 9 rev(string in, &string out[11], 12); 10 } void rev(char *from, char *to, int copy) 13 { 14 if (copy!= 0) { 15 rev(from+1, to-1, copy-1); 16 *to = *from; 17 } 18 }
28 Reversing a String in C 1 2 char *string in = Hello World! ; 3 char string out[13] = {0}; 4 5 void rev(char *, char *, int); 6 7 int main(void) 8 { 9 rev(string in, &string out[11], 12); 10 } void rev(char *from, char *to, int copy) 13 { 14 if (copy!= 0) { 15 rev(from+1, to-1, copy-1); 16 *to = *from; 17 } 18 }
29 Reversing a String in C 1 2 char *string in = Hello World! ; 3 char string out[13] = {0}; 4 5 void rev(char *, char *, int); 6 7 int main(void) 8 { 9 rev(string in, &string out[11], 12); 10 } void rev(char *from, char *to, int copy) 13 { 14 if (copy!= 0) { 15 rev(from+1, to-1, copy-1); 16 *to = *from; 17 } 18 }
30 Reversing a String in C 1 2 char *string in = Hello World! ; 3 char string out[13] = {0}; 4 5 void rev(char *, char *, int); 6 7 int main(void) 8 { 9 rev(string in, &string out[11], 12); 10 } void rev(char *from, char *to, int copy) 13 { 14 if (copy!= 0) { 15 rev(from+1, to-1, copy-1); 16 *to = *from; 17 } 18 }
31 Reversing a String in C 1 2 char *string in = Hello World! ; 3 char string out[13] = {0}; 4 5 void rev(char *, char *, int); 6 7 int main(void) 8 { 9 rev(string in, string out+11, 12); 10 } void rev(char *from, char *to, int copy) 13 { 14 if (copy!= 0) { 15 rev(from+1, to-1, copy-1); 16 *to = *from; 17 } 18 }
32 Reversing a String in C 1 2 char *string in = Hello World! ; 3 char string out[13] = {0}; 4 5 void rev(char *, char *, int); 6 7 int main(void) 8 { 9 rev(string in, string out+11, 12); 10 } void rev(char *from, char *to, int copy) 13 { 14 if (copy!= 0) { 15 rev(from+1, to-1, copy-1); 16 *to = *from; 17 } 18 }
33 Reversing a String in C 1 2 char *string in = Hello World! ; 3 char string out[13] = {0}; 4 5 void rev(char *, char *, int); 6 7 int main(void) 8 { 9 rev(string in, string out+11, 12); 10 } void rev(char *from, char *to, int copy) 13 { 14 if (copy!= 0) { 15 rev(from+1, to-1, copy-1); 16 *to = *from; 17 } 18 }
34 Reversing a String in C 1 2 char *string in = Hello World! ; 3 char string out[13] = {0}; 4 5 void rev(char *, char *, int); 6 7 int main(void) 8 { 9 rev(string in, string out+11, 12); 10 } void rev(char *from, char *to, int copy) 13 { 14 if (copy!= 0) { 15 rev(from+1, to-1, copy-1); 16 *to = *from; 17 } 18 }
35 Reversing a String in C 1 2 char *string in = Hello World! ; 3 char string out[13] = {0}; 4 5 void rev(char *, char *, int); 6 7 int main(void) 8 { 9 rev(string in, string out+11, 12); 10 } void rev(char *from, char *to, int copy) 13 { 14 if (copy!= 0) { 15 rev(from+1, to-1, copy-1); 16 *to = *from; 17 } 18 }
36 Reversing a String in C 1 2 char *string in = Hello World! ; 3 char string out[13] = {0}; 4 5 void rev(char *, char *, int); 6 7 int main(void) 8 { 9 rev(string in, string out+11, 12); 10 } void rev(char *from, char *to, int copy) 13 { 14 if (copy!= 0) { 15 rev(from+1, to-1, copy-1); 16 *to = *from; 17 } 18 }
37 The Compiled Result (of function rev, compiled with -O1) : 27 bdffe0 addiu sp, sp, : afbf0018 sw ra, 24( sp ) : afb10014 sw s1, 20( sp ) c : afb00010 sw s0, 16( sp ) : move s0, a : 10 c00007 beqz a2, <rev+0x34> : 00 a08821 move s1, a c : addiu a0, a0, : 24 a 5 f f f f a d d i u a1, a1, : 0c j a l <rev> : 24 c 6 f f f f a d d i u a2, a2, c : l b u v0, 0 ( s0 ) : a sb v0, 0 ( s1 ) : 8 fbf0018 lw ra, 24( sp ) : 8 fb10014 lw s1, 20( sp ) c : 8 fb00010 lw s0, 16( sp ) : 03 e00008 j r ra : 27 bd0020 a d d i u sp, sp,32
38 What is the lab about? Implementing lab1b in C. Analyzing the resulting assembly-code of codgen at different optimization levels: -O0, -O1, -O2, and -O3. Try to reverse-engineer the compiler, what kind of optimizations does it perform? The gcc manual can be of great help here, just make sure you have the manual from the correct version (v3.4.4).
CS 110 Computer Architecture. Lecture 2: Introduction to C, Part I. Instructor: Sören Schwertfeger.
CS 110 Computer Architecture Lecture 2: Introduction to C, Part I Instructor: Sören Schwertfeger http://shtech.org/courses/ca/ School of Information Science and Technology SIST ShanghaiTech University
More informationProgramming Fundamentals (CS 302 ) Dr. Ihsan Ullah. Lecturer Department of Computer Science & IT University of Balochistan
Programming Fundamentals (CS 302 ) Dr. Ihsan Ullah Lecturer Department of Computer Science & IT University of Balochistan 1 Outline p Introduction p Program development p C language and beginning with
More informationHacking in C. The C programming language. Radboud University, Nijmegen, The Netherlands. Spring 2018
Hacking in C The C programming language Radboud University, Nijmegen, The Netherlands Spring 2018 The C programming language Invented by Dennis Ritchie in the early 70s First Hello World program written
More informationCS 110 Computer Architecture. Lecture 2: Introduction to C, Part I. Instructor: Sören Schwertfeger.
CS 110 Computer Architecture Lecture 2: Introduction to C, Part I Instructor: Sören Schwertfeger http://shtech.org/courses/ca/ School of Information Science and Technology SIST ShanghaiTech University
More informationCS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor
CS 261 Fall 2017 Mike Lam, Professor C Introduction Variables, Memory Model, Pointers, and Debugging The C Language Systems language originally developed for Unix Imperative, compiled language with static
More informationCS 61C: Great Ideas in Computer Architecture Lecture 2: Introduction to C, Part I
CS 61C: Great Ideas in Computer Architecture Lecture 2: Introduction to C, Part I Instructors: Vladimir Stojanovic & Nicholas Weaver http://inst.eecs.berkeley.edu/~cs61c/ 1 Agenda Everything is a Number
More informationEL2310 Scientific Programming
Lecture 6: Introduction to C (pronobis@kth.se) Overview Overview Lecture 6: Introduction to C Roots of C Getting started with C Closer look at Hello World Programming Environment Schedule Last time (and
More informationEL2310 Scientific Programming
(yaseminb@kth.se) Overview Overview Roots of C Getting started with C Closer look at Hello World Programming Environment Discussion Basic Datatypes and printf Schedule Introduction to C - main part of
More informationModule 2: GNU Tools and Compilation Process Introduction to GCC and History The original GNU C Compiler is developed by Richard Stallman in 1984 to create a complete UNIX like operating systems as free
More informationReview (1/2) IEEE 754 Floating Point Standard: Kahan pack as much in as could get away with. CS61C - Machine Structures
Review (1/2) CS61C - Machine Structures Lecture 11 - Starting a Program October 4, 2000 David Patterson http://www-inst.eecs.berkeley.edu/~cs61c/ IEEE 754 Floating Point Standard: Kahan pack as much in
More informationApplication Specific Signal Processors S
1 Application Specific Signal Processors 521281S Dept. of Computer Science and Engineering Mehdi Safarpour 23.9.2018 Course contents Lecture contents 1. Introduction and number formats 2. Signal processor
More informationHacking in C. The C programming language. Radboud University, Nijmegen, The Netherlands. Spring 2018
Hacking in C The C programming language Radboud University, Nijmegen, The Netherlands Spring 2018 The C programming language Invented by Dennis Ritchie in the early 70s First Hello World program written
More informationMotivation was to facilitate development of systems software, especially OS development.
A History Lesson C Basics 1 Development of language by Dennis Ritchie at Bell Labs culminated in the C language in 1972. Motivation was to facilitate development of systems software, especially OS development.
More informationC Introduction. Comparison w/ Java, Memory Model, and Pointers
CS 261 Fall 2018 Mike Lam, Professor C Introduction Comparison w/ Java, Memory Model, and Pointers Please go to socrative.com on your phone or laptop, choose student login and join room LAMJMU The C Language
More informationECE 30 Introduction to Computer Engineering
ECE 30 Introduction to Computer Engineering Study Problems, Set #3 Spring 2015 Use the MIPS assembly instructions listed below to solve the following problems. arithmetic add add sub subtract addi add
More informationC Language Part 1 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee
C Language Part 1 (Minor modifications by the instructor) References C for Python Programmers, by Carl Burch, 2011. http://www.toves.org/books/cpy/ The C Programming Language. 2nd ed., Kernighan, Brian,
More informationWe will study the MIPS assembly language as an exemplar of the concept.
MIPS Assembly Language 1 We will study the MIPS assembly language as an exemplar of the concept. MIPS assembly instructions each consist of a single token specifying the command to be carried out, and
More informationTwo s Complement Review. Two s Complement Review. Agenda. Agenda 6/21/2011
Two s Complement Review CS 61C: Great Ideas in Computer Architecture (Machine Structures) Introduction to C (Part I) Instructor: Michael Greenbaum http://inst.eecs.berkeley.edu/~cs61c/su11 Suppose we had
More informationContents of Lecture 3
Contents of Lecture 3 Repetition of matrices double a[3][4]; double* b; double** c; Terminology Linkage Types Conversions Jonas Skeppstedt (js@cs.lth.se) Lecture 3 2014 1 / 33 A global matrix: double a[3][4]
More informationComputer Architecture I Midterm I
Computer Architecture I Midterm I April 11 2017 Computer Architecture I Midterm I Chinese Name: Pinyin Name: E-Mail... @shanghaitech.edu.cn: Question Points Score 1 1 2 12 3 16 4 14 5 18 6 17 7 22 Total:
More informationAgenda. CS 61C: Great Ideas in Computer Architecture. Lecture 2: Numbers & C Language 8/29/17. Recap: Binary Number Conversion
CS 61C: Great Ideas in Computer Architecture Lecture 2: Numbers & C Language Krste Asanović & Randy Katz http://inst.eecs.berkeley.edu/~cs61c Numbers wrap-up This is not on the exam! Break C Primer Administrivia,
More informationCS 61C: Great Ideas in Computer Architecture. Lecture 2: Numbers & C Language. Krste Asanović & Randy Katz
CS 61C: Great Ideas in Computer Architecture Lecture 2: Numbers & C Language Krste Asanović & Randy Katz http://inst.eecs.berkeley.edu/~cs61c Numbers wrap-up This is not on the exam! Break C Primer Administrivia,
More informationIntroduction to C Language
Introduction to C Language Instructor: Professor I. Charles Ume ME 6405 Introduction to Mechatronics Fall 2006 Instructor: Professor Charles Ume Introduction to C Language History of C Language In 1972,
More informationIntroduction to Computing Lecture 01: Introduction to C
Introduction to Computing Lecture 01: Introduction to C Assist.Prof.Dr. Nükhet ÖZBEK Ege University Department of Electrical&Electronics Engineering ozbek.nukhet@gmail.com Topics Introduction to C language
More informationFeatures of C. Portable Procedural / Modular Structured Language Statically typed Middle level language
1 History C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC
More informationPresented By : Gaurav Juneja
Presented By : Gaurav Juneja Introduction C is a general purpose language which is very closely associated with UNIX for which it was developed in Bell Laboratories. Most of the programs of UNIX are written
More informationTDDB68 Concurrent Programming and Operating Systems. Lecture 2: Introduction to C programming
TDDB68 Concurrent Programming and Operating Systems Lecture 2: Introduction to C programming Mikael Asplund, Senior Lecturer Real-time Systems Laboratory Department of Computer and Information Science
More informationA Plan 9 C Compiler for RISC-V
A Plan 9 C Compiler for RISC-V Richard Miller r.miller@acm.org Plan 9 C compiler - written by Ken Thompson for Plan 9 OS - used for Inferno OS kernel and limbo VM - used to bootstrap first releases of
More informationISA: The Hardware Software Interface
ISA: The Hardware Software Interface Instruction Set Architecture (ISA) is where software meets hardware In embedded systems, this boundary is often flexible Understanding of ISA design is therefore important
More informationSpring 2018 NENG 202 Introduction to Computer Programming
Spring 2018 NENG 202 Introduction to Computer Programming Introductory programming course based on the C language Course Website: http://www.albany.edu/~yx152122/neng202-18.html Instructor: Prof. Y. Alex
More informationMotivation was to facilitate development of systems software, especially OS development.
A History Lesson C Basics 1 Development of language by Dennis Ritchie at Bell Labs culminated in the C language in 1972. Motivation was to facilitate development of systems software, especially OS development.
More informationCHW 469 : Embedded Systems
CHW 469 : Instructor: Dr. Ahmed Shalaby http://bu.edu.eg/staff/ahmedshalaby14# https://piazza.com/fci.bu.edu.eg/spring2017/chw469/home Assignment no. 3 kindly read the following paper [Software Engineering
More informationLecture 3: Instruction Set Architecture
Lecture 3: Instruction Set Architecture CSE 30: Computer Organization and Systems Programming Summer 2014 Diba Mirza Dept. of Computer Science and Engineering University of California, San Diego 1. Steps
More informationProgramming in C. What is C?... What is C?
C Programming in C UVic SEng 265 Developed by Brian Kernighan and Dennis Ritchie of Bell Labs Earlier, in 1969, Ritchie and Thompson developed the Unix operating system We will be focusing on a version
More informationProgramming in C UVic SEng 265
Programming in C UVic SEng 265 Daniel M. German Department of Computer Science University of Victoria 1 SEng 265 dmgerman@uvic.ca C Developed by Brian Kernighan and Dennis Ritchie of Bell Labs Earlier,
More informationProgramming in C. What is C?... What is C?
Programming in C UVic SEng 265 C Developed by Brian Kernighan and Dennis Ritchie of Bell Labs Earlier, in 1969, Ritchie and Thompson developed the Unix operating system We will be focusing on a version
More informationCS 61C: Great Ideas in Computer Architecture. C Arrays, Strings, More Pointers
CS 61C: Great Ideas in Computer Architecture C Arrays, Strings, More Pointers Instructor: Justin Hsia 6/20/2012 Summer 2012 Lecture #3 1 Review of Last Lecture C Basics Variables, Functions, Flow Control,
More informationLAB A Translating Data to Binary
LAB A Translating Data to Binary Create a directory for this lab and perform in it the following groups of tasks: LabA1.java 1. Write the Java app LabA1 that takes an int via a command-line argument args[0]
More informationLecture 7: Examples, MARS, Arithmetic
Lecture 7: Examples, MARS, Arithmetic Today s topics: More examples MARS intro Numerical representations 1 Dealing with Characters Instructions are also provided to deal with byte-sized and half-word quantities:
More informationCS 61c: Great Ideas in Computer Architecture
Introduction to C, Pointers June 24, 2014 Review of Last Lecture Six Great Ideas in Computer Architecture Number Representation Bits can represent anything! n bits can represent up to 2 n things Unsigned,
More informationOutline. 1 About the course
Outline EDAF50 C++ Programming 1. Introduction 1 About the course Sven Gestegård Robertz Computer Science, LTH 2018 2 Presentation of C++ History Introduction Data types and variables 1. Introduction 2/1
More informationCS 61C: Great Ideas in Computer Architecture Intro to Assembly Language, MIPS Intro
CS 61C: Great Ideas in Computer Architecture Intro to Assembly Language, MIPS Intro 1 Levels of Representation/Interpretation Machine Interpretation High Level Language Program (e.g., C) Compiler Assembly
More informationCS241 Computer Organization Spring Data Alignment
CS241 Computer Organization Spring 2015 Data Alignment 3-26 2015 Outline! Data Alignment! C: pointers to functions! Memory Layout Read: CS:APP2 Chapter 3, sections 3.8-3.9 Quiz next Thursday, April 2nd
More informationAssembler. #13 Running a Program II
CS61C L13 Running a Program II (1) inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures #13 Running a Program II aka Compiling, Assembling, Linking, Loading (CALL) 2007-7-17 Scott Beamer, Instructor
More informationCS61C : Machine Structures
inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures #13 Running a Program II aka Compiling, Assembling, Linking, Loading (CALL) 2007-7-17 Scott Beamer, Instructor Green Subscription Based PC Announced
More informationLectures 5-6: Introduction to C
Lectures 5-6: Introduction to C Motivation: C is both a high and a low-level language Very useful for systems programming Faster than Java This intro assumes knowledge of Java Focus is on differences Most
More informationM2 Instruction Set Architecture
M2 Instruction Set Architecture Module Outline Addressing modes. Instruction classes. MIPS-I ISA. Translating and starting a program. High level languages, Assembly languages and object code. Subroutine
More informationProgramming in C and C++
Programming in C and C++ 1. Types Variables Expressions & Statements Dr. Anil Madhavapeddy University of Cambridge (based on previous years thanks to Alan Mycroft, Alastair Beresford and Andrew Moore)
More informationProcedure Calling. Procedure Calling. Register Usage. 25 September CSE2021 Computer Organization
CSE2021 Computer Organization Chapter 2: Part 2 Procedure Calling Procedure (function) performs a specific task and return results to caller. Supporting Procedures Procedure Calling Calling program place
More informationPage 1. Today. Last Time. Is the assembly code right? Is the assembly code right? Which compiler is right? Compiler requirements CPP Volatile
Last Time Today Compiler requirements CPP Volatile Advanced C What C programs mean int my_loop (int base) { int index, count = 0; for (index = base; index < (base+10); index++) count++; urn count; my_loop:
More informationECE260: Fundamentals of Computer Engineering
Accessing and Addressing Memory James Moscola Dept. of Engineering & Computer Science York College of Pennsylvania Based on Computer Organization and Design, 5th Edition by Patterson & Hennessy American
More informationLectures 5-6: Introduction to C
Lectures 5-6: Introduction to C Motivation: C is both a high and a low-level language Very useful for systems programming Faster than Java This intro assumes knowledge of Java Focus is on differences Most
More informationPointers, Dynamic Data, and Reference Types
Pointers, Dynamic Data, and Reference Types Review on Pointers Reference Variables Dynamic Memory Allocation The new operator The delete operator Dynamic Memory Allocation for Arrays 1 C++ Data Types simple
More informationPage 1. Agenda. Programming Languages. C Compilation Process
EE 472 Embedded Systems Dr. Shwetak Patel Assistant Professor Computer Science & Engineering Electrical Engineering Agenda Announcements C programming intro + pointers Shwetak N. Patel - EE 472 2 Programming
More informationIRIX is moving in the n32 direction, and n32 is now the default, but the toolchain still supports o32. When we started supporting native mode o32 was
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2002 Handout 23 Running Under IRIX Thursday, October 3 IRIX sucks. This handout describes what
More informationC Language, Token, Keywords, Constant, variable
C Language, Token, Keywords, Constant, variable A language written by Brian Kernighan and Dennis Ritchie. This was to be the language that UNIX was written in to become the first "portable" language. C
More informationBinghamton University. CS-120 Summer Introduction to C. Text: Introduction to Computer Systems : Chapters 11, 12, 14, 13
Introduction to C Text: Introduction to Computer Systems : Chapters 11, 12, 14, 13 Problem: Too Many Details For example: Lab 7 Bubble Sort Needed to keep track of too many details! Outer Loop When do
More informationEC 413 Computer Organization
EC 413 Computer Organization Program Compilation Process Prof. Michel A. Kinsy The Full View System Applica2ons So)ware Hardware Systems So)ware The Full View System Processor Applica2ons Compiler Firmware
More informationThe component base of C language. Nguyễn Dũng Faculty of IT Hue College of Science
The component base of C language Nguyễn Dũng Faculty of IT Hue College of Science Content A brief history of C Standard of C Characteristics of C The C compilation model Character set and keyword Data
More informationLecture Outline. Code Generation. Lecture 30. Example of a Stack Machine Program. Stack Machines
Lecture Outline Code Generation Lecture 30 (based on slides by R. Bodik) Stack machines The MIPS assembly language The x86 assembly language A simple source language Stack-machine implementation of the
More informationCrash Course into. Prof. Dr. Renato Pajarola
Crash Course into Prof. Dr. Renato Pajarola These slides may not be copied or distributed without explicit permission by all original copyright holders C Language Low-level programming language General
More informationEC 413 Computer Organization
EC 413 Computer Organization C/C++ Language Review Prof. Michel A. Kinsy Programming Languages There are many programming languages available: Pascal, C, C++, Java, Ada, Perl and Python All of these languages
More information>B<82. 2Soft ware. C Language manual. Copyright COSMIC Software 1999, 2001 All rights reserved.
>B
More informationIntroduction to the C Programming Language
Introduction to the C Programming Language Michael Griffiths Corporate Information and Computing Services The University of Sheffield Email m.griffiths@sheffield.ac.uk Course Outline Part 1 Introduction
More informationData Storage. August 9, Indiana University. Geoffrey Brown, Bryce Himebaugh 2015 August 9, / 19
Data Storage Geoffrey Brown Bryce Himebaugh Indiana University August 9, 2016 Geoffrey Brown, Bryce Himebaugh 2015 August 9, 2016 1 / 19 Outline Bits, Bytes, Words Word Size Byte Addressable Memory Byte
More informationCSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community
CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community http://csc.cs.rit.edu History and Evolution of Programming Languages 1. Explain the relationship between machine
More informationCode Generation. Lecture 30
Code Generation Lecture 30 (based on slides by R. Bodik) 11/14/06 Prof. Hilfinger CS164 Lecture 30 1 Lecture Outline Stack machines The MIPS assembly language The x86 assembly language A simple source
More informationImportant From Last Time
Important From Last Time Embedded C Pros and cons Macros and how to avoid them Intrinsics Interrupt syntax Inline assembly Today Advanced C What C programs mean How to create C programs that mean nothing
More informationECE 15B COMPUTER ORGANIZATION
ECE 15B COMPUTER ORGANIZATION Lecture 17 Executing Programs: Compiling, Assembling, Linking and Loading (Part II) Project #3 Due June 10, 5pm Announcements Submit via email Homework #4 Due June 5, 5pm
More informationPage 1. Today. Important From Last Time. Is the assembly code right? Is the assembly code right? Which compiler is right?
Important From Last Time Today Embedded C Pros and cons Macros and how to avoid them Intrinsics Interrupt syntax Inline assembly Advanced C What C programs mean How to create C programs that mean nothing
More informationCS240: Programming in C
CS240: Programming in C Lecture 2: Hello World! Cristina Nita-Rotaru Lecture 2/ Fall 2013 1 Introducing C High-level programming language Developed between 1969 and 1973 by Dennis Ritchie at the Bell Labs
More informationLECTURE 17. Expressions and Assignment
LECTURE 17 Expressions and Assignment EXPRESSION SYNTAX An expression consists of An atomic object, e.g. number or variable. An operator (or function) applied to a collection of operands (or arguments)
More informationProgramming in C++ 5. Integral data types
Programming in C++ 5. Integral data types! Introduction! Type int! Integer multiplication & division! Increment & decrement operators! Associativity & precedence of operators! Some common operators! Long
More informationCS 61C: Great Ideas in Computer Architecture Intro to Assembly Language, MIPS Intro
CS 61C: Great Ideas in Computer Architecture Intro to Assembly Language, MIPS Intro Instructors: Vladimir Stojanovic & Nicholas Weaver http://inst.eecs.berkeley.edu/~cs61c/sp16 1 Machine Interpretation
More informationCS 61C: Great Ideas in Computer Architecture Lecture 2: Introduction to C, Part I
CS 61C: Great Ideas in Computer Architecture Lecture 2: Introduction to C, Part I Instructors: Vladimir Stojanovic & John Wawrzynek http://inst.eecs.berkeley.edu/~cs61c/ 1 Agenda Compile vs. Interpret
More informationSWEN-250 Personal SE. Introduction to C
SWEN-250 Personal SE Introduction to C A Bit of History Developed in the early to mid 70s Dennis Ritchie as a systems programming language. Adopted by Ken Thompson to write Unix on a the PDP-11. At the
More informationMachine Language Instructions Introduction. Instructions Words of a language understood by machine. Instruction set Vocabulary of the machine
Machine Language Instructions Introduction Instructions Words of a language understood by machine Instruction set Vocabulary of the machine Current goal: to relate a high level language to instruction
More informationImportant From Last Time
Important From Last Time Embedded C Ø Pros and cons Macros and how to avoid them Intrinsics Interrupt syntax Inline assembly Today Advanced C What C programs mean How to create C programs that mean nothing
More informationQuiz 0 Answer Key. Answers other than the below may be possible. Multiple Choice. 0. a 1. a 2. b 3. c 4. b 5. d. True or False.
Quiz 0 Answer Key Answers other than the below may be possible. Multiple Choice. 0. a 1. a 2. b 3. c 4. b 5. d True or False. 6. T or F 7. T 8. F 9. T 10. T or F Itching for Week 0? 11. 00011001 + 00011001
More informationLecture 2: C Programming Basic
ECE342 Introduction to Embedded Systems Lecture 2: C Programming Basic Ying Tang Electrical and Computer Engineering Rowan University 1 Facts about C C was developed in 1972 in order to write the UNIX
More informationCS201 - Lecture 1 The C Programming Language
CS201 - Lecture 1 The C Programming Language RAOUL RIVAS PORTLAND STATE UNIVERSITY History of the C Language The C language was invented in 1970 by Dennis Ritchie Dennis Ritchie and Ken Thompson were employees
More informationCS 61c: Great Ideas in Computer Architecture
Arrays, Strings, and Some More Pointers June 24, 2014 Review of Last Lecture C Basics Variables, functioss, control flow, types, structs Only 0 and NULL evaluate to false Pointers hold addresses Address
More informationProgramming in C and C++
Programming in C and C++ 10. C Semantics: Undefined Behaviour & Optimization Issues Dr. Anil Madhavapeddy University of Cambridge (based on previous years thanks to Alan Mycroft, Alastair Beresford and
More informationLecture 07 Debugging Programs with GDB
Lecture 07 Debugging Programs with GDB In this lecture What is debugging Most Common Type of errors Process of debugging Examples Further readings Exercises What is Debugging Debugging is the process of
More informationInstruction Set Architectures
Instruction Set Architectures ISAs Brief history of processors and architectures C, assembly, machine code Assembly basics: registers, operands, move instructions 1 What should the HW/SW interface contain?
More information2012 LLVM Euro - Michael Spencer. lld. Friday, April 13, The LLVM Linker
lld Friday, April 13, 2012 The LLVM Linker What is lld? A system linker Produce final libraries and executables, no other tools or runtime required Understands platform ABI What is lld? A system linker
More informationInformation Science. No. For each question, choose one correct answer and write its symbol (A E) in the box.
For each question, choose one correct answer and write its symbol (A E) in the box. (A E) Q16. When compiling the program below, the name of which is prog.c, the following error is reported. Which program
More informationPointers (continued), arrays and strings
Pointers (continued), arrays and strings 1 Last week We have seen pointers, e.g. of type char *p with the operators * and & These are tricky to understand, unless you draw pictures 2 Pointer arithmetic
More informationCS 102 Computer Architecture. Lecture 2: Introduction to C, Part I. Instructor: Sören Schwertfeger.
CS 102 Computer Architecture Lecture 2: Introduction to C, Part I Instructor: Sören Schwertfeger http://shtech.org/courses/ca/ School of Information Science and Technology SIST ShanghaiTech University
More informationC: Introduction, Pointers Instructors: Steven Ho, Nick Riasanovsky
C: Introduction, Pointers Instructors: Steven Ho, Nick Riasanovsky Overflow Overflow is when the result of an arithmetic operation can t be represented by the (FINITE) hardware bits i.e. the result is
More informationAgenda. Peer Instruction Question 1. Peer Instruction Answer 1. Peer Instruction Question 2 6/22/2011
CS 61C: Great Ideas in Computer Architecture (Machine Structures) Introduction to C (Part II) Instructors: Randy H. Katz David A. Patterson http://inst.eecs.berkeley.edu/~cs61c/sp11 Spring 2011 -- Lecture
More informationedunepal_info
facebook.com/edunepal.info @ edunepal_info C interview questions (1 125) C interview questions are given with the answers in this website. We have given C interview questions faced by freshers and experienced
More informationUnit. Programming Fundamentals. School of Science and Technology INTRODUCTION
INTRODUCTION Programming Fundamentals Unit 1 In order to communicate with each other, we use natural languages like Bengali, English, Hindi, Urdu, French, Gujarati etc. We have different language around
More information2 Compiling a C program
2 Compiling a C program This chapter describes how to compile C programs using gcc. Programs can be compiled from a single source file or from multiple source files, and may use system libraries and header
More informationECE 3210 Laboratory 1: Develop an Assembly Program
ECE 3210 Laboratory 1: Develop an Assembly Program Spring 2018 1 Objective To become familiar with the development system s software: screen editor, assembler, linker, and debugger. After finishing this
More informationProgramming in C Quick Start! Biostatistics 615 Lecture 4
Programming in C Quick Start! Biostatistics 615 Lecture 4 Last Lecture Analysis of Algorithms Empirical Analysis Mathematical Analysis Big-Oh notation Today Basics of programming in C Syntax of C programs
More informationRoadmap. Java: Assembly language: OS: Machine code: Computer system:
Roadmap C: car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Assembly language: Machine code: Computer system: get_mpg: pushq movq... popq ret %rbp %rsp, %rbp
More informationPointers (continued), arrays and strings
Pointers (continued), arrays and strings 1 Last week We have seen pointers, e.g. of type char *p with the operators * and & These are tricky to understand, unless you draw pictures 2 Pointer arithmetic
More informationMIPS Functions and Instruction Formats
MIPS Functions and Instruction Formats 1 The Contract: The MIPS Calling Convention You write functions, your compiler writes functions, other compilers write functions And all your functions call other
More informationCS 61C: Great Ideas in Computer Architecture Introduction to C
CS 61C: Great Ideas in Computer Architecture Introduction to C Instructors: Vladimir Stojanovic & Nicholas Weaver http://inst.eecs.berkeley.edu/~cs61c/ 1 Agenda C vs. Java vs. Python Quick Start Introduction
More information