02-C-Introduction-P - ECE 175: Computer Programming for...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ECE 175: Computer Programming for Engineering Applications Introduction to Programming ECE 175: Computer Programming for Engineering Applications - Simple Data Types Computer software Programming languages High-level languages (e.g. C, C++, Fortran, Java) Assembly language (processor-specific language; e.g. MIPS, PowerPC, Intel 8086/8088) Machine languages (sequence of 0s and 1s) Advantages of high-level languages Closer to natural languages Portable - Can use the code in different machines (with a compiler) Disadvantages Speed - Good compilers help here 2 ECE 175: Computer Programming for Engineering Applications - Simple Data Types Preparing a program for execution Steps Editing Compilation Linking Loading Execution Delving into the depths reveals more information An abstraction omits unneeded detail Helps us cope with complexity What are some of the details that appear in these familiar abstractions? 3 swap(int v, int k) {int temp; temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; } swap: muli $2, $5,4 add $2, $4,$2 lw $15, 0($2) lw $16, 4($2) sw $16, 0($2) sw $15, 4($2) jr $31 00000000101000010000000000011000 00000000100011100001100000100001 10001100011000100000000000000000 10001100111100100000000000000100 10101100111100100000000000000000 10101100011000100000000000000100 00000011111000000000000000001000 Binary machine language program (for MIPS) C compiler Assembler Assembly language program (for MIPS) High-level language program (in C) ECE 175: Computer Programming for Engineering Applications - Simple Data Types Steps in preparing a C program for execution Editing Use pico or any other editor to write the program We write C programs - All filenames end with .c Example: example.c test.c hanoi.c test.c Compile/Link Usage: gcc <filename> Some flags may be added if special files need to be included during the linking process Creates an executable file called a.out Loading and executing Type a.out from the command line to execute the program The program is loaded into the memory (from disk), and then executed 4 ECE 175: Introductory C for Engineers Overview of C ECE 175: Computer Programming for Engineering Applications - Simple Data Types Comments and preprocessor directives Comments A comment is placed between /* and */ Comments can be placed anywhere in a C program Comments are ignored by the compiler Preprocessor directives Statements that instruct the C pre-processor to perform certain tasks e.g. Inclusion of some header files These directives are processed before compiling the program A pre-processor directive starts with # Most common directives: include and define 6 Syntax: /* comment text */ ECE 175: Computer Programming for Engineering Applications - Simple Data Types #include and #define #include Gives the program access to header files of standard libraries Example standard library header files: stdio.h, math.h, string.h, etc....
View Full Document

This note was uploaded on 04/03/2008 for the course ECE 175 taught by Professor Grubbs during the Spring '08 term at University of Arizona- Tucson.

Page1 / 29

02-C-Introduction-P - ECE 175: Computer Programming for...

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

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