C. C ? K & R C -- 1972 – The Kernighan and Richie classic ANCI C -- started 1983 – ANSI X3.159-1989 and ISO/IEC 9899:1990 – Standard C, C89, C90 C90 –

Slides:



Advertisements
Similar presentations
CPSC 441 TUTORIAL – JANUARY 16, 2012 TA: MARYAM ELAHI INTRODUCTION TO C.
Advertisements

Picture It Very Basic Game Picture Pepper. Original Game import java.util.Scanner; public class Game { public static void main() { Scanner scan=new Scanner(System.in);
Architecture Chapter 2 - Supplement Additional Features In Chapter 2.
Dr. Ken Hoganson, © August 2014 Programming in R COURSE NOTES 2 Hoganson Language Translation.
Stack buffer overflow
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Lecture 2: OS Programming Interface T.Yang, CS
Embedded Systems Programming Introduction to cross development techniques.
Principles of Object-Oriented Software Development The language Java.
Unix Continuum of Tools Do something once: use the command line Do something many times: –Use an alias –Use a shell script Do something that is complex.
JETT 2003 Java.compareTo(C++). JAVA Java Platform consists of 4 parts: –Java Language –Java API –Java class format –Java Virtual Machine.
Recitation 1 Session 5 Ishani Chakraborty. Machine Level Representation What happens to a C program when we compile it ? $ gcc prog.c Preprocessor (expands.
1 Homework Reading –PAL, pp , Machine Projects –Finish mp2warmup Questions? –Start mp2 as soon as possible Labs –Continue labs with your.
Advanced Programming in the UNIX Environment Hop Lee.
Compiler Construction
Introduction to C. A Brief History Created by Dennis Ritchie at AT&T Labs in 1972 Originally created to design and support the Unix operating system.
“C” Programming Language What is language ? Language is medium of communication. If two persons want to communicate with each other, they have to use.
M1G Introduction to Programming 2 4. Enhancing a class:Room.
Introduction to C Programming. A Brief History u Created by Dennis Ritchie at AT&T Labs in 1972 u Originally created to design and support the Unix operating.
Dr. José M. Reyes Álamo 1.  An assembly language that is easier to understand that regular assembly  Borrow some features from high-level languages.
GNU gcov (1/4) [from Wikipedia] gcov is a source code coverage analysis and statement- by-statement profiling tool. gcov generates exact counts of the.
Computing with C# and the.NET Framework Chapter 1 An Introduction to Computing with C# ©2003, 2011 Art Gittleman.
C for Java Programmers Tomasz Müldner Copyright:  Addison-Wesley Publishing Company, 2000 Introduction to C Muldner, Chapters 1, 2.
Programming With C.
Goals: To gain an understanding of assembly To get your hands dirty in GDB.
Introduction to C++ Programming Language
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 2: Operating-System Structures T.Yang, 2012 Partially based on the.
Recitation 6 – 2/26/01 Outline Linking Exam Review –Topics Covered –Your Questions Shaheen Gandhi Office Hours: Wednesday.
Overflows & Exploits. In the beginning 11/02/1988 Robert Morris, Jr., a graduate student in Computer Science at Cornell, wrote an experimental, self-replicating,
The course. Description Computer systems programming using the C language – And possibly a little C++ Translation of C into assembly language Introduction.
CS-1030 Dr. Mark L. Hornick 1 Java Review Interactive.
X86 Architecture.
What is exactly Exploit writing?  Writing a piece of code which is capable of exploit the vulnerability in the target software.
Windows Programming, C.-S. Shieh, KUAS EC, Chapter 0 Overview.
Overview of Java CSCI 392 Day One. Running C code vs Java code C Source Code C Compiler Object File (machine code) Library Files Linker Executable File.
OPERATING SYSTEMS 1 - HARDWARE PIETER HARTEL 1. Hardware 2.
Low Level Programming Lecturer: Duncan Smeed The Interface Between High-Level and Low-Level Languages.
1 CSC2100B Data Structure Tutorial 1 Online Judge and C.
CS429 Computer Architecture Topics Simple C program Basic structure, functions, separate files Compilation Phases, options Assembler GNU style, byte ordering,
First Compilation Rudra Dutta CSC Spring 2007, Section 001.
3/12/2013Computer Engg, IIT(BHU)1 MPI-1. MESSAGE PASSING INTERFACE A message passing library specification Extended message-passing model Not a language.
Java State Explorer by: Richard Sherman Stephanie Taylor.
Sung-Dong Kim Dept. of Computer Engineering, Hansung University Chapter 3 Programming Tools.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Buffer Overflow By Collin Donaldson.
Machine-Level Programming 2 Control Flow
Why don’t programmers have to program in machine code?
Assembly Language Specific to each machine Extremely low level
Conditional Branch Example
C Programming Hardik H. Maheta.
Command line arguments
C# and the .NET Framework
Mobile Development Workshop
Machine-Level Programming: Control Flow
C Prog. To Object Code text text binary binary Code in files p1.c p2.c
GNU gcov (1/4) [from Wikipedia]
Assembly Language Programming II: C Compiler Calling Sequences
Machine-Level Programming 2 Control Flow
Machine-Level Representation of Programs III
Introduction to C Programming
CNT4704: Analysis of Computer Communication Network Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Fall 2011.
System Calls David Ferry CSCI 3500 – Operating Systems
ECE 103 Engineering Programming Chapter 46 argc, argv, envp
C structures and Compilation to IA32
GNU gcov (1/4) [from Wikipedia]
C call R Using .R file in C T. B. Chen in NCTU 2019/5/29.
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2016.
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2010.
Compiler Construction CS 606 Sohail Aslam Lecture 1.
The ‘asm’ construct An introduction to the GNU C/C++ compiler’s obscure syntax for doing inline assembly language.
Presentation transcript:

C

C ? K & R C – The Kernighan and Richie classic ANCI C -- started 1983 – ANSI X and ISO/IEC 9899:1990 – Standard C, C89, C90 C90 – Another ANSI standard (adds C++ features) GCC

C with objects C++ – Used for business and gaming applications Java – Used for networking and user interface – Executes on a “virtual machine” C# – Used by Microsoft

Why C? Programs can be fast Programs can be small Runs on many platforms – Including embedded processors – Generally with some version of GCC Relatively easy to learn Useful “standard” library

Why not C? Can get very obscure – ++a = *p->q + b * (x>y ? 5 : 13) ; Can lack robustness – Many viruses “attack” servers written in C Hard to manage large software projects – Without object-oriented techniques C++ can be fast Java can be small

C program -- 1 of 2 #include void countdown(int n) { int i ; for (i=n; i>= 1; --i) printf("%4d\n", i) ; puts("*** blastoff ***") ; }

C program -- 2 of 2 int main(int argc, char *argv[]) { int count ; puts("Enter start of count!") ; scanf("%d", &count) ; countdown(count) ; return 0 ; }

Running NCSU ECE 209 style $ nano example.c $ ls -l example* -rw-r--r-- 1 brock Aug 17 17:48 example.c $ gcc -ansi -pedantic -Wall -Werror -o example example.c $ ls -l example* -rwxr-xr-x 1 brock Aug 17 17:48 example -rw-r--r-- 1 brock Aug 17 17:48 example.c $./example

Looking at object code $ nano example.c $ gcc -ansi -pedantic -Wall -Werror -c example.c $ ls -l example* -rw-r--r-- 1 brock Aug 17 17:48 example.c -rw-r--r-- 1 brock Aug 17 17:58 example.o $ gcc -o example example.c

Looking at assembly code $ gcc -ansi -pedantic -Wall -Werror -S example.c From example.s i=n movl 8(%ebp), %eax movl %eax, -12(%ebp) --i followed by i>=1 leal -12(%ebp), %eax subl $1, (%eax) L2: cmpl $0, -12(%ebp) jg L3