Week 1 Notes - Week 1 Notes What is covered History...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Week 1 Notes What is covered History Assembly vs. C Speed and Optimization in C Exceptions Errors Syntax Example 1 - hello.c Writing Programs Example 2 - mygrep.c C Preprocessor - Intro Makefiles Int and Char memory usage Testall Script Example 3 - count.c Strings in C Example 4 - sum.c Argument Checking History -Invented by Dennis Ritchie in 1972 -Used to write UNIX 98% Written in C 2% Written in Assembly -C is easier to port to other architectures since it does not need to be rewritten for each -C is a High-Level Assembly Language Assembly vs. C Code Example Creates three variables a, b, and c. Initializes a to 3, b to 6, and c to a + b. Then c is put into allocated memory. -Assembly has a fixed number of registers for use -Arithmetic operations work with registers in assemly Assembly #a is reg1 #b is reg2 #c is reg3 load reg1,#3 load reg2,#6 add reg1,reg2,reg3 mov reg3,mem
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
C int a,b,c; a = 3 ; b = 6 ; c = a + b; mem = c; Assembly code changes for each processor architecture -x86-x64 -ARM -SPARC -IA-64 Assembly code lookes different for each of these processor architectures, which means code in assembly needs to be rewritten for each architecture it is put on Speed and Optimization in C C will not get in your way when optimizing your program. It can be translated directly to assembly code. Other languages have a layer of code to optimize your program correctly. Java -Program code is stored in bytecode -Bytecode is given to the JVM (Java Virtual Machine) to be translated to machine code -Code is then sent to the CPU C -Program stored in assembly code -Assembly code is sent to the CPU Exceptions C has no exceptions and will not stop you from accessing data outside of an initialized array. Java on the other hand will check to make sure that the index you are trying to access is actually in the allocated memory for the array. This requires runtime to go through each call to access an
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/18/2012 for the course CS 240 taught by Professor Rego during the Fall '08 term at Purdue University-West Lafayette.

Page1 / 8

Week 1 Notes - Week 1 Notes What is covered History...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online