C Programming. A quick introduction for embedded systems. Dr. Alun Moon UNN/CEIS. September 2008

Size: px
Start display at page:

Download "C Programming. A quick introduction for embedded systems. Dr. Alun Moon UNN/CEIS. September 2008"

Transcription

1 C Programming A quick introduction for embedded systems Dr. Alun Moon UNN/CEIS September 2008 Dr. Alun Moon (UNN/CEIS) C Programming September / 13

2 Programming is both an art and a science. It is an art in the sense of a master craftsman. In this guide I hope to introduce the thinking behind programming. It is aimed at those needing to program in C, but the skills of a programmer are independent of the language used. Remember, programming cannot be learnt by simply reading a book. It has to be learnt through practice writing programs! Take the time to practice, write your own solutions to the problems here and the exercises given. Look at my solutions, but they will be different to yours, after all I ve been doing this a lot longer. Take the time to read through and learn from my solutions. But don t forget to write your own. Dr. Alun Moon (UNN/CEIS) C Programming September / 13

3 Program Design I a few simple steps Identifying features in the program. Is the first step taking the problem into the design. It is the process of identifying what the essential functions of the program are to be. Just as important is identifying what is not needed. Breaking the problem down into smaller pieces. Most problems can be broken down into smaller pieces. Either as distinct sub-programs or as a series of tasks within a program, or even function. This functional decomposition allows a complex task to be reduced to smaller simpler pieces that fit together to perform the task. Dr. Alun Moon (UNN/CEIS) C Programming September / 13

4 Program Design II a few simple steps Identifying functions and writing the prototype. Once the tasks have been found, often they can be written down as the names of functions to use. With the name goes the information that the function needs and the values it returns. Writing the program logic. Once the functions are known, what they do can be transfered into the program logic. The logic for a function can be very simple or complex depending on the task. Dr. Alun Moon (UNN/CEIS) C Programming September / 13

5 File contents C programming Good practice Program source files are simply text files. Dr. Alun Moon (UNN/CEIS) C Programming September / 13

6 File contents C programming Good practice Program source files are simply text files. They can be worked on by any editor Dr. Alun Moon (UNN/CEIS) C Programming September / 13

7 File contents C programming Good practice Program source files are simply text files. They can be worked on by any editor All an IDE does is wrap up an editor and the invocation of the tools in a single front-end. Dr. Alun Moon (UNN/CEIS) C Programming September / 13

8 File contents C programming Good practice Program source files are simply text files. They can be worked on by any editor All an IDE does is wrap up an editor and the invocation of the tools in a single front-end. the linker control file is another text file Dr. Alun Moon (UNN/CEIS) C Programming September / 13

9 C programming Good practice File contents Program source files are simply text files. They can be worked on by any editor All an IDE does is wrap up an editor and the invocation of the tools in a single front-end. the linker control file is another text file Corollary Since source files are text, they can be created and edited by other programs. Dr. Alun Moon (UNN/CEIS) C Programming September / 13

10 C programming Good practice File contents Program source files are simply text files. They can be worked on by any editor All an IDE does is wrap up an editor and the invocation of the tools in a single front-end. the linker control file is another text file Corollary Since source files are text, they can be created and edited by other programs. Corollary (Treat programs as documents) Dr. Alun Moon (UNN/CEIS) C Programming September / 13

11 C programming Good practice File contents Program source files are simply text files. They can be worked on by any editor All an IDE does is wrap up an editor and the invocation of the tools in a single front-end. the linker control file is another text file Corollary Since source files are text, they can be created and edited by other programs. Corollary (Treat programs as documents) express concepts with clarity Dr. Alun Moon (UNN/CEIS) C Programming September / 13

12 C programming Good practice File contents Program source files are simply text files. They can be worked on by any editor All an IDE does is wrap up an editor and the invocation of the tools in a single front-end. the linker control file is another text file Corollary Since source files are text, they can be created and edited by other programs. Corollary (Treat programs as documents) express concepts with clarity readability Dr. Alun Moon (UNN/CEIS) C Programming September / 13

13 C programming Good practice File contents Program source files are simply text files. They can be worked on by any editor All an IDE does is wrap up an editor and the invocation of the tools in a single front-end. the linker control file is another text file Corollary Since source files are text, they can be created and edited by other programs. Corollary (Treat programs as documents) express concepts with clarity readability comment when code is not clear Dr. Alun Moon (UNN/CEIS) C Programming September / 13

14 C programming Good practice File contents Program source files are simply text files. They can be worked on by any editor All an IDE does is wrap up an editor and the invocation of the tools in a single front-end. the linker control file is another text file Corollary Since source files are text, they can be created and edited by other programs. Corollary (Treat programs as documents) express concepts with clarity readability comment when code is not clear reference them Dr. Alun Moon (UNN/CEIS) C Programming September / 13

15 Rob Pike rules[7] C programming Good practice 1 You can t tell where a program is going to spend its time. Bottlenecks occur in surprising places, so don t try to second guess and put in a speed hack until you ve proven where the bottleneck is. Dr. Alun Moon (UNN/CEIS) C Programming September / 13

16 Rob Pike rules[7] C programming Good practice 1 You can t tell where a program is going to spend its time. Bottlenecks occur in surprising places, so don t try to second guess and put in a speed hack until you ve proven where the bottleneck is. 2 Measure. Don t tune for speed until you ve measured, and even then don t unless one part of the code overwhelms the rest. Dr. Alun Moon (UNN/CEIS) C Programming September / 13

17 Rob Pike rules[7] C programming Good practice 1 You can t tell where a program is going to spend its time. Bottlenecks occur in surprising places, so don t try to second guess and put in a speed hack until you ve proven where the bottleneck is. 2 Measure. Don t tune for speed until you ve measured, and even then don t unless one part of the code overwhelms the rest. 3 Fancy algorithms are slow when n is small, and n is usually small. Fancy algorithms have big constants. Until you know then n is frequently going to be big, don t get fancy. (Even if n does get big, use Rule 2 first.) Dr. Alun Moon (UNN/CEIS) C Programming September / 13

18 Rob Pike rules[7] C programming Good practice 1 You can t tell where a program is going to spend its time. Bottlenecks occur in surprising places, so don t try to second guess and put in a speed hack until you ve proven where the bottleneck is. 2 Measure. Don t tune for speed until you ve measured, and even then don t unless one part of the code overwhelms the rest. 3 Fancy algorithms are slow when n is small, and n is usually small. Fancy algorithms have big constants. Until you know then n is frequently going to be big, don t get fancy. (Even if n does get big, use Rule 2 first.) 4 Fancy algorithms are buggier than simple ones, and they re much harder to implement. Use simple algorithms as well as simple data structures. Dr. Alun Moon (UNN/CEIS) C Programming September / 13

19 Rob Pike rules[7] C programming Good practice 1 You can t tell where a program is going to spend its time. Bottlenecks occur in surprising places, so don t try to second guess and put in a speed hack until you ve proven where the bottleneck is. 2 Measure. Don t tune for speed until you ve measured, and even then don t unless one part of the code overwhelms the rest. 3 Fancy algorithms are slow when n is small, and n is usually small. Fancy algorithms have big constants. Until you know then n is frequently going to be big, don t get fancy. (Even if n does get big, use Rule 2 first.) 4 Fancy algorithms are buggier than simple ones, and they re much harder to implement. Use simple algorithms as well as simple data structures. 5 Data dominates. If you ve chosen the right data structures and organised things well, the algroithms will always be self-evident. Data structures, not algorithms, are central to programming. Dr. Alun Moon (UNN/CEIS) C Programming September / 13

20 C programming Good practice Philosopy of good programs I The Art of Unix Programming[8] 1 Rule of Modularity: Write simple parts connected by clean interfaces. 2 Rule of Clarity: Clarity is better than cleverness. 3 Rule of Composition: Design programs to be connected to other programs. 4 Rule Rule of Separation: Separate policy from mechanism; separate interfaces from engines. 5 Rule of Simplicity: Design for simplicity; add complexity only where you must. 6 Rule of Parsimony: Write a big program only when it is clear by demonstration that nothing else will do. 7 Rule of Transparency: Design for visibility to make inspection and debugging easier. Dr. Alun Moon (UNN/CEIS) C Programming September / 13

21 C programming Good practice Philosopy of good programs II The Art of Unix Programming[8] 8 Rule of Robustness: Robustness is the child of transparency and simplicity. 9 Rule of Representation: Fold knowledge into data so program logic can be stupid and robust. 10 Rule of Least Surprise: In interface design, always do the least surprising thing. 11 Rule of Silence: When a program has nothing surprising to say, it should say nothing. 12 Rule of Repair: When you must fail, fail noisily and as soon as possible. 13 Rule of Economy: Programmer time is expensive; conserve it in preference to machine time. Dr. Alun Moon (UNN/CEIS) C Programming September / 13

22 C programming Good practice Philosopy of good programs III The Art of Unix Programming[8] 14 Rule of Generation: Avoid hand-hacking; write programs to write programs when you can. 15 Rule of Optimization: Prototype before polishing. Get it working before you optimize it. 16 Rule of Diversity: Distrust all claims for one true way. 17 Rule of Extensibility: Design for the future, because it will be here sooner than you think. Dr. Alun Moon (UNN/CEIS) C Programming September / 13

23 Reading I C programming Good practice S. P. Harbison and G. L. Steel, C: A Reference Manual, Prentice Hall, 5 ed., March Good reference, covers the C99 standard. S. Holmes, C programming. Internet tutorial, University of Strathclyde Computer Centre. An excellent online tutorial for C programming, (recommended). A. Hunt and D. Thomas, The Pragmatic Programmer, Addison-Wesley, Oct A good book on the practice of writing programs. Not tied to a particular language, and has examples in C, Java etc. Has some very useful ideas about orgainising the process of programming. B. W. Kernighan and D. Ritchie, C Programming Language (2nd Edition), Prentice Hall PTR, March Dr. Alun Moon (UNN/CEIS) C Programming September / 13

24 Reading II C programming Good practice S. Kochan, Programming in C, Sams, 3 ed., July A good book for students who are serious about C. M. McGrath, C in easy steps, ineasy steps, Computer Step, 2 ed., June A good conversion text that covers the basics. R. Pike, Notes on programming in c. E. S. Raymond, The Art of Unix Programming, Professional Computing Series, Addison-Wesley, Dr. Alun Moon (UNN/CEIS) C Programming September / 13

25 Program structure Program structure There are a number of repeated patterns that occur in programs. These are both how the program interacts with the outside world and the internal structure of the program. Understanding how these patterns work and applying them to the implemetation of probles is the key to effective programming. Dr. Alun Moon (UNN/CEIS) C Programming September / 13

26 Program structure External External structure Cooperating programs Programs can be designed to act together, the output from one becomes the input to the next. The actual mechanism is handled by the outside environment. input Program a Program b output Dr. Alun Moon (UNN/CEIS) C Programming September / 13

27 Program structure External Corollary The upshot of this is that the formats of the input and output data are important in designing a program. Dr. Alun Moon (UNN/CEIS) C Programming September / 13

28 Program structure External Corollary The upshot of this is that the formats of the input and output data are important in designing a program. Corollary Design programs to cooperate. Dr. Alun Moon (UNN/CEIS) C Programming September / 13

29 Program structure External Corollary The upshot of this is that the formats of the input and output data are important in designing a program. Corollary Design programs to cooperate. Corollary Sometimes a problem can be split into separate cooperating programs. Dr. Alun Moon (UNN/CEIS) C Programming September / 13

30 Program structure Internal structure There are two basic patterns that are useful at this stage for thinking about the internal structure of a program. These can apply at any level Most programs have the same basic internal structure. 1 initialise the program. Set up data structures, parameters and constants. initialise 2 process perform the operations of the program. process finish 3 finish clean up after the program. This pattern applies at any scale, the program as a whole, a function, a loop within a block of code. Dr. Alun Moon (UNN/CEIS) C Programming September / 13

31 Program structure Internal structure The processing performed by the program follows a similar pattern read 1 read some data 2 process the data process 3 write the results. write Usually there is some loop wrapped around this pattern. Depending on the problem the processing can occur for each item read, or all the data needs to be read before the processing can occur. Dr. Alun Moon (UNN/CEIS) C Programming September / 13

32 Unix C programs are written to run under Unix. any text editor, vi, emacs, gedit, scite, etc. will do. gcc is a command line tool that combines the functions of compiler assembler linker the files likely to be encountered are C source C header object executable Dr. Alun Moon (UNN/CEIS) C Programming September / 13

33 Unix framework assembler converts assembly code into object files compiler converts c-code into object filrs linker combines object files together debugger controls running of the program to allow execution of single instructions and examine contents of variables There are a number of commonly used file extensions used in C and assembly programming. Most of these are common to all systems. The various tools assume these extensions are used. input Program output Dr. Alun Moon (UNN/CEIS) C Programming September / 13

34 Unix framework Program source files are simply text files. They can be worked on by any editor All an IDE does is wrap up an editor and the invocation of the tools in a single front-end. Corollary the linker control file is another text file Since source files are text, they can be created and edited by other programs. Dr. Alun Moon (UNN/CEIS) C Programming September / 13

35 Tools Object files An object file contains the output generated by assemblers and compilers. The bulk of the content is the image for blocks of memory, describing the address-range and the contents. some blocks are given absolute (fixed) addresses some blocks are relocatable in that the block as a whole can be put at any valid location in memory Object files contain unresolved references to labels. i.e.memory addresses and subroutine calls using address labels that do not yet have a known address. Example mov a, data jsr double jsr sin mov b, scale data dc.w 1024 double mov a,b add b,a Dr. Alun Moon rts (UNN/CEIS) C Programming September / 13

36 Tools Assembler The assembler is a simple program that takes an assembly language program and generates an object file..o.s Assembler Dr. Alun Moon (UNN/CEIS) C Programming September / 13

37 Tools Compiler The compiler is a complex program that grenerate an object file from a C source file. (Strictly it generates an assemly language source that is then assembled.). However there is a problem in that the compiler complains about unresolved function and variable names. Which is why we have header files. Dr. Alun Moon (UNN/CEIS) C Programming September / 13

38 Tools Compiler C does not like forward references Definition (Forward reference) A forward reference is where we can use a function or variable in the program, before we have declared it to exist It is a similar problem to that of unresolved references in assembly language programs. Corollary We have to tell the compiler about functions and variables before we need them. Dr. Alun Moon (UNN/CEIS) C Programming September / 13

39 Tools Compiler Example (dblib.h) e x t e r n double p o w e r f a c t o r ; double d e c i B e l l ( doubl Example (dblib.c) #i n c l u d e <math. h> double p o w e r f a c t o r ; double d e c r a t i o ) { r e t u r n 10.0 l o g 1 0 ( r a t i o ) ; } Example (prog.c) #i n c l u d e d B l i b. h v o i d main ( v o i d ) { p o w e r f a c t o d e c i B e l l ( ) ; } Dr. Alun Moon (UNN/CEIS) C Programming September / 13

40 Tools Compiler The preprocessor handles the include! and define! lines in the c source file. the include! reads in the given file at that point in the program, where the preprocessor looks for the file depends on the quoting, angle brackets <>: look in the standard system locations quotes "": look in the working directory Dr. Alun Moon (UNN/CEIS) C Programming September / 13

41 Tools Linker Dr. Alun Moon (UNN/CEIS) C Programming September / 13

A Quick guide to C. Dr Alun Moon September 16, Contents. Introduction 2 Unix 2 On Program design 4. C programming Good practice 4

A Quick guide to C. Dr Alun Moon September 16, Contents. Introduction 2 Unix 2 On Program design 4. C programming Good practice 4 A Quick guide to C Dr Alun Moon September 16, 2014 Contents Introduction 2 Unix 2 On Program design 4 a few simple steps 4 C programming Good practice 4 File contents 4 Rob Pike rules 5 Philosopy of good

More information

Unix Philosophy Some Rights Reserved Villa Sant Ignazio Trento

Unix Philosophy Some Rights Reserved  Villa Sant Ignazio Trento Unix Philosophy Author: Contact: Copyright: Location: Version: Note: Daniele Pizzolli ors@tovel.it 2010 Some Rights Reserved http://creativecommons.org/licenses/by-sa/3.0/ Villa Sant Ignazio Trento Draft

More information

Room 3P16 Telephone: extension ~irjohnson/uqc146s1.html

Room 3P16 Telephone: extension ~irjohnson/uqc146s1.html UQC146S1 Introductory Image Processing in C Ian Johnson Room 3P16 Telephone: extension 3167 Email: Ian.Johnson@uwe.ac.uk http://www.csm.uwe.ac.uk/ ~irjohnson/uqc146s1.html Ian Johnson 1 UQC146S1 What is

More information

Week - 01 Lecture - 04 Downloading and installing Python

Week - 01 Lecture - 04 Downloading and installing Python Programming, Data Structures and Algorithms in Python Prof. Madhavan Mukund Department of Computer Science and Engineering Indian Institute of Technology, Madras Week - 01 Lecture - 04 Downloading and

More information

Computing and compilers

Computing and compilers Computing and compilers Comp Sci 1570 to Outline 1 2 3 4 5 Evaluate the difference between hardware and software Find out about the various types of software Get a high level understanding of how program

More information

CSE 303: Concepts and Tools for Software Development

CSE 303: Concepts and Tools for Software Development CSE 303: Concepts and Tools for Software Development Dan Grossman Spring 2007 Lecture 19 Profiling (gprof); Linking and Libraries Dan Grossman CSE303 Spring 2007, Lecture 19 1 Where are we Already started

More information

CS 211 Programming I for Engineers

CS 211 Programming I for Engineers CS 211 Programming I for Engineers Instructor: Tom Bartenstein Course Web Page: http://www.cs.binghamton.edu/~tbartens/cs211_fall_2018/ 1 Catalog Description Introduction to computer programming with engineering

More information

CS354 gdb Tutorial Written by Chris Feilbach

CS354 gdb Tutorial Written by Chris Feilbach CS354 gdb Tutorial Written by Chris Feilbach Purpose This tutorial aims to show you the basics of using gdb to debug C programs. gdb is the GNU debugger, and is provided on systems that

More information

These are notes for the third lecture; if statements and loops.

These are notes for the third lecture; if statements and loops. These are notes for the third lecture; if statements and loops. 1 Yeah, this is going to be the second slide in a lot of lectures. 2 - Dominant language for desktop application development - Most modern

More information

C: Program Structure. Department of Computer Science College of Engineering Boise State University. September 11, /13

C: Program Structure. Department of Computer Science College of Engineering Boise State University. September 11, /13 Department of Computer Science College of Engineering Boise State University September 11, 2017 1/13 Scope Variables and functions are visible from the point they are defined until the end of the source

More information

Introduction. A Brief Description of Our Journey

Introduction. A Brief Description of Our Journey Introduction If you still write RPG code as you did 20 years ago, or if you have ILE RPG on your resume but don t actually use or understand it, this book is for you. It will help you transition from the

More information

SKILL AREA 304: Review Programming Language Concept. Computer Programming (YPG)

SKILL AREA 304: Review Programming Language Concept. Computer Programming (YPG) SKILL AREA 304: Review Programming Language Concept Computer Programming (YPG) 304.1 Demonstrate an Understanding of Basic of Programming Language 304.1.1 Explain the purpose of computer program 304.1.2

More information

Analysis of the Test Driven Development by Example

Analysis of the Test Driven Development by Example Computer Science and Applications 1 (2013) 5-13 Aleksandar Bulajic and Radoslav Stojic The Faculty of Information Technology, Metropolitan University, Belgrade, 11000, Serbia Received: June 18, 2013 /

More information

B. Subject-specific skills B1. Problem solving skills: Supply the student with the ability to solve different problems related to the topics

B. Subject-specific skills B1. Problem solving skills: Supply the student with the ability to solve different problems related to the topics Zarqa University Faculty: Information Technology Department: Computer Science Course title: Programming LAB 1 (1501111) Instructor: Lecture s time: Semester: Office Hours: Course description: This introductory

More information

Lecture 03 Bits, Bytes and Data Types

Lecture 03 Bits, Bytes and Data Types Lecture 03 Bits, Bytes and Data Types Computer Languages A computer language is a language that is used to communicate with a machine. Like all languages, computer languages have syntax (form) and semantics

More information

Starting Embedded C Programming CM0506 Small Embedded Systems

Starting Embedded C Programming CM0506 Small Embedded Systems Starting Embedded C Programming CM0506 Small Embedded Systems Dr Alun Moon 19th September 2016 This exercise will introduce you to using the development environment to compile, build, downnload, and debug

More information

Language Translation. Compilation vs. interpretation. Compilation diagram. Step 1: compile. Step 2: run. compiler. Compiled program. program.

Language Translation. Compilation vs. interpretation. Compilation diagram. Step 1: compile. Step 2: run. compiler. Compiled program. program. Language Translation Compilation vs. interpretation Compilation diagram Step 1: compile program compiler Compiled program Step 2: run input Compiled program output Language Translation compilation is translation

More information

Introduction to Basis and Practice in Programming

Introduction to Basis and Practice in Programming Introduction to Basis and Practice in Programming Fall 2015 Jinkyu Jeong (jinkyu@skku.edu) 1 Course Overview Course Basics! Class hour GEDB029-45: Mon. 13:00 ~ 14:50 GEDB029-46: Tue. 13:00 ~ 14:50 1~2

More information

Introduction to Python

Introduction to Python A sample Training Module from our course WELL HOUSE CONSULTANTS LTD 404, The Spa Melksham, Wiltshire SN12 6QL United Kingdom PHONE: 01225 708225 FACSIMLE 01225 707126 EMAIL: info@wellho.net 2004 Well House

More information

Introduction to Programming Systems

Introduction to Programming Systems Introduction to Programming Systems CS 217 Thomas Funkhouser & Bob Dondero Princeton University Goals Master the art of programming Learn how to be good programmers Introduction to software engineering

More information

Reliable programming

Reliable programming Reliable programming How to write programs that work Think about reliability during design and implementation Test systematically When things break, fix them correctly Make sure everything stays fixed

More information

CSE 230 Intermediate Programming in C and C++ Functions

CSE 230 Intermediate Programming in C and C++ Functions CSE 230 Intermediate Programming in C and C++ Functions Fall 2017 Stony Brook University Instructor: Shebuti Rayana shebuti.rayana@stonybrook.edu http://www3.cs.stonybrook.edu/~cse230/ Concept of Functions

More information

Chapter 9. Introduction to High-Level Language Programming. INVITATION TO Computer Science

Chapter 9. Introduction to High-Level Language Programming. INVITATION TO Computer Science Chapter 9 Introduction to High-Level Language Programming INVITATION TO Computer Science 1 Objectives After studying this chapter, students will be able to: Explain the advantages of high-level programming

More information

Chapter 3: Modules. Starting Out with Programming Logic & Design. Second Edition. by Tony Gaddis

Chapter 3: Modules. Starting Out with Programming Logic & Design. Second Edition. by Tony Gaddis Chapter 3: Modules Starting Out with Programming Logic & Design Second Edition by Tony Gaddis Copyright 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter Topics 3.1 Introduction

More information

COMP1917: Computing 1 1. Introduction

COMP1917: Computing 1 1. Introduction COMP1917: Computing 1 1. Introduction Reading: Moffat, Chapter 1. COMP1917 12s2 Introduction 1 Course Web Site http://www.cse.unsw.edu.au/~cs1917/12s2 Please check this Web Site regularly for updated information,

More information

Chapter Twelve. Systems Design and Development

Chapter Twelve. Systems Design and Development Chapter Twelve Systems Design and Development After reading this chapter, you should be able to: Describe the process of designing, programming, and debugging a computer program Explain why there are many

More information

In addition to name. Each variable in C program is characterized by its Type Scope Storage Class. Type Have already discussed

In addition to name. Each variable in C program is characterized by its Type Scope Storage Class. Type Have already discussed Variables, Storage Class, Scope, Multiple File Multiple Module Projects Overview Will examine how variables characterized Will introduce and study variable s storage class Will examine a variable s visibility

More information

1. Introduction. Course Web Site. COMP1917: Computing 1. Textbook. Occupational Health and Safety (OHS)

1. Introduction. Course Web Site. COMP1917: Computing 1. Textbook. Occupational Health and Safety (OHS) COMP1917 14s2 Introduction 1 COMP1917: Computing 1 1. Introduction Reading: Moffat, Chapter 1. Course Web Site http://www.cse.unsw.edu.au/~cs1917/14s2 Please check this Web Site regularly for updated information,

More information

2. Numbers In, Numbers Out

2. Numbers In, Numbers Out COMP1917: Computing 1 2. Numbers In, Numbers Out Reading: Moffat, Chapter 2. COMP1917 15s2 2. Numbers In, Numbers Out 1 The Art of Programming Think about the problem Write down a proposed solution Break

More information

Ray Smith Database Administrator Portland General Electric

Ray Smith Database Administrator Portland General Electric Ray Smith Database Administrator Portland General Electric Objectives Philosophical alignment Context of quality Define quality in scripted solutions What are the common elements of good scripts? 40 slides

More information

PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILERS

PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILERS Objective PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILERS Explain what is meant by compiler. Explain how the compiler works. Describe various analysis of the source program. Describe the

More information

gcc hello.c a.out Hello, world gcc -o hello hello.c hello Hello, world

gcc hello.c a.out Hello, world gcc -o hello hello.c hello Hello, world alun@debian:~$ gcc hello.c alun@debian:~$ a.out Hello, world alun@debian:~$ gcc -o hello hello.c alun@debian:~$ hello Hello, world alun@debian:~$ 1 A Quick guide to C for Networks and Operating Systems

More information

Embedded Systems. 2. Software Development. Lothar Thiele. Computer Engineering and Networks Laboratory

Embedded Systems. 2. Software Development. Lothar Thiele. Computer Engineering and Networks Laboratory Embedded Systems 2. Software Development Lothar Thiele Computer Engineering and Networks Laboratory Remember: Computer Engineering I Compilation of a C program to machine language program: textual representation

More information

contain a geometry package, and so on). All Java classes should belong to a package, and you specify that package by typing:

contain a geometry package, and so on). All Java classes should belong to a package, and you specify that package by typing: Introduction to Java Welcome to the second CS15 lab! By now we've gone over objects, modeling, properties, attributes, and how to put all of these things together into Java classes. It's perfectly okay

More information

COMP1917: Computing 1 1. Introduction

COMP1917: Computing 1 1. Introduction COMP1917: Computing 1 1. Introduction Reading: Moffat, Chapter 1. COMP1917 15s2 Introduction 1 Course Web Site http://www.cse.unsw.edu.au/~cs1917/15s2 Please check this Web Site regularly for updated information,

More information

Computer Organization & Assembly Language Programming

Computer Organization & Assembly Language Programming Computer Organization & Assembly Language Programming CSE 2312 Lecture 11 Introduction of Assembly Language 1 Assembly Language Translation The Assembly Language layer is implemented by translation rather

More information

COSC 2P91. Bringing it all together... Week 4b. Brock University. Brock University (Week 4b) Bringing it all together... 1 / 22

COSC 2P91. Bringing it all together... Week 4b. Brock University. Brock University (Week 4b) Bringing it all together... 1 / 22 COSC 2P91 Bringing it all together... Week 4b Brock University Brock University (Week 4b) Bringing it all together... 1 / 22 A note on practicality and program design... Writing a single, monolithic source

More information

y

y The Unfit tutorial By Dr Martin Buist Initial version: November 2013 Unfit version: 2 or later This tutorial will show you how to write your own cost function for Unfit using your own model and data. Here

More information

What s next. Computer Systems A Programmer s Perspective

What s next. Computer Systems A Programmer s Perspective What s next Computer Systems A Programmer s Perspective 198 The role of the operating system Protect the computer from misuse Provide an abstraction for using the hardware so that programs can be written

More information

GDB Tutorial. A Walkthrough with Examples. CMSC Spring Last modified March 22, GDB Tutorial

GDB Tutorial. A Walkthrough with Examples. CMSC Spring Last modified March 22, GDB Tutorial A Walkthrough with Examples CMSC 212 - Spring 2009 Last modified March 22, 2009 What is gdb? GNU Debugger A debugger for several languages, including C and C++ It allows you to inspect what the program

More information

CS201 - Introduction to Programming FAQs By

CS201 - Introduction to Programming FAQs By CS201 - Introduction to Programming FAQs By What are pointers? Answer: A pointer is a variable that represents/stores location of a data item, such as a variable or array element What s the difference

More information

Programmers Life made easy through Smart Source Code Generator

Programmers Life made easy through Smart Source Code Generator International Journal of Engineering& Scientific Research Vol.5 Issue 4, April 2017, ISSN: 2347-6532 Impact Factor: 6.660 JournalHomepage:http://www.ijmra.us,Email:editorijmie@gmail.com Double-Blind Peer

More information

RIS shading Series #2 Meet The Plugins

RIS shading Series #2 Meet The Plugins RIS shading Series #2 Meet The Plugins In this tutorial I will be going over what each type of plugin is, what their uses are, and the basic layout of each. By the end you should understand the three basic

More information

CIS* Programming

CIS* Programming CIS*1300 - Programming CALENDAR DESCRIPTION This course examines the applied and conceptual aspects of programming. Topics may include data and control structures, program design, problem solving and algorithm

More information

CE221 Programming in C++ Part 1 Introduction

CE221 Programming in C++ Part 1 Introduction CE221 Programming in C++ Part 1 Introduction 06/10/2017 CE221 Part 1 1 Module Schedule There are two lectures (Monday 13.00-13.50 and Tuesday 11.00-11.50) each week in the autumn term, and a 2-hour lab

More information

Computer Programming & Problem Solving ( CPPS ) Turbo C Programming For The PC (Revised Edition ) By Robert Lafore

Computer Programming & Problem Solving ( CPPS ) Turbo C Programming For The PC (Revised Edition ) By Robert Lafore Sir Syed University of Engineering and Technology. Computer ming & Problem Solving ( CPPS ) Functions Chapter No 1 Compiled By: Sir Syed University of Engineering & Technology Computer Engineering Department

More information

Lecture 19 CSE August You taught me Language, and my profit on t is I know how to curse. William Shakspere, The Tempest, I, ii.

Lecture 19 CSE August You taught me Language, and my profit on t is I know how to curse. William Shakspere, The Tempest, I, ii. Lecture 19 CSE 110 5 August 1992 You taught me Language, and my profit on t is I know how to curse. William Shakspere, The Tempest, I, ii. 1 Left-Over Language Features Today was the day we saw the last

More information

CS133 C Programming. Instructor: Jialiang Lu Office: Information Center 703

CS133 C Programming. Instructor: Jialiang Lu   Office: Information Center 703 CS133 C Programming Instructor: Jialiang Lu Email: jialiang.lu@sjtu.edu.cn Office: Information Center 703 1 Course Information: Course Page: http://wirelesslab.sjtu.edu.cn/~jlu/teaching/cp2014/ Assignments

More information

Chapter - 2 The Basics of Programming. Practical C++ Programming Copyright 2003 O'Reilly and Associates Page1

Chapter - 2 The Basics of Programming. Practical C++ Programming Copyright 2003 O'Reilly and Associates Page1 Chapter - 2 The Basics of Programming Practical C++ Programming Copyright 2003 O'Reilly and Associates Page1 What is a program? A program is a set of instructions that a computer or someone else follows.

More information

2. Numbers In, Numbers Out

2. Numbers In, Numbers Out REGZ9280: Global Education Short Course - Engineering 2. Numbers In, Numbers Out Reading: Moffat, Chapter 2. REGZ9280 14s2 2. Numbers In, Numbers Out 1 The Art of Programming Think about the problem Write

More information

Coding Tools for Research

Coding Tools for Research Coding Tools for Research Jack Baker Jack Baker Coding Tools for Research 1 / 11 Good Coding Practice in One Slide Modular: write code in small functions which do one thing. Indent!! Self documenting:

More information

Control Structures. Code can be purely arithmetic assignments. At some point we will need some kind of control or decision making process to occur

Control Structures. Code can be purely arithmetic assignments. At some point we will need some kind of control or decision making process to occur Control Structures Code can be purely arithmetic assignments At some point we will need some kind of control or decision making process to occur C uses the if keyword as part of it s control structure

More information

Concepts in Programming Languages

Concepts in Programming Languages Concepts in Programming Languages Marcelo Fiore Computer Laboratory University of Cambridge 2012 2013 (Easter Term) 1 Practicalities Course web page: with lecture

More information

CS2304 Spring 2014 Project 3

CS2304 Spring 2014 Project 3 Goal The Bureau of Labor Statistics maintains data sets on many different things, from work place injuries to consumer spending habits, but what you most frequently hear about is employment. Conveniently,

More information

Why are there so many programming languages? Why do we have programming languages? What is a language for? What makes a language successful?

Why are there so many programming languages? Why do we have programming languages? What is a language for? What makes a language successful? Chapter 1 :: Introduction Introduction Programming Language Pragmatics Michael L. Scott Why are there so many programming languages? evolution -- we've learned better ways of doing things over time socio-economic

More information

CSE 374 Programming Concepts & Tools

CSE 374 Programming Concepts & Tools CSE 374 Programming Concepts & Tools Hal Perkins Fall 2017 Lecture 11 gdb and Debugging 1 Administrivia HW4 out now, due next Thursday, Oct. 26, 11 pm: C code and libraries. Some tools: gdb (debugger)

More information

ECE 3210 Laboratory 1: Develop an Assembly Program

ECE 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 information

Component V Supporting Materials / Learn More Interesting Facts. Interesting Facts

Component V Supporting Materials / Learn More Interesting Facts. Interesting Facts Component V Supporting Materials / Learn More 1.4.1 Interesting Facts No. Interesting Facts 1. All computers operate by following machine language programs. 2. Machine language programs are long sequence

More information

C++ Style Guide. 1.0 General. 2.0 Visual Layout. 3.0 Indentation and Whitespace

C++ Style Guide. 1.0 General. 2.0 Visual Layout. 3.0 Indentation and Whitespace C++ Style Guide 1.0 General The purpose of the style guide is not to restrict your programming, but rather to establish a consistent format for your programs. This will help you debug and maintain your

More information

Building a COFFEE POT simulation on CCESS for Blackfin BF533

Building a COFFEE POT simulation on CCESS for Blackfin BF533 Building a COFFEE POT simulation on CCESS 2.6.0 for Blackfin BF533 Last lecture covered some detailed ideas Let step back and do something simpler to get an introduction of ideas needed for Lab0 and Assignment

More information

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA 1 TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson, and instructor materials prepared

More information

The compiler is spewing error messages.

The compiler is spewing error messages. Appendix B Debugging There are a few different kinds of errors that can occur in a program, and it is useful to distinguish between them in order to track them down more quickly. Compile-time errors are

More information

High Performance Computing MPI and C-Language Seminars 2009

High Performance Computing MPI and C-Language Seminars 2009 High Performance Computing - Seminar Plan Welcome to the High Performance Computing seminars for 2009. Aims: Introduce the C Programming Language. Basic coverage of C and programming techniques needed

More information

CS 403: Lab 6: Profiling and Tuning

CS 403: Lab 6: Profiling and Tuning CS 403: Lab 6: Profiling and Tuning Getting Started 1. Boot into Linux. 2. Get a copy of RAD1D from your CVS repository (cvs co RAD1D) or download a fresh copy of the tar file from the course website.

More information

Smaller, simpler, subcomponent of program Provides abstraction

Smaller, simpler, subcomponent of program Provides abstraction C Function Overview Function Smaller, simpler, subcomponent of program Provides abstraction» hide low-level details» give high-level structure to program, easier to understand overall program flow» enables

More information

Reviewing gcc, make, gdb, and Linux Editors 1

Reviewing gcc, make, gdb, and Linux Editors 1 Reviewing gcc, make, gdb, and Linux Editors 1 Colin Gordon csgordon@cs.washington.edu University of Washington CSE333 Section 1, 3/31/11 1 Lots of material borrowed from 351/303 slides Colin Gordon (University

More information

Reversing. Time to get with the program

Reversing. Time to get with the program Reversing Time to get with the program This guide is a brief introduction to C, Assembly Language, and Python that will be helpful for solving Reversing challenges. Writing a C Program C is one of the

More information

Code::Blocks Student Manual

Code::Blocks Student Manual Code::Blocks Student Manual Lawrence Goetz, Network Administrator Yedidyah Langsam, Professor and Theodore Raphan, Distinguished Professor Dept. of Computer and Information Science Brooklyn College of

More information

Rule 1-3: Use white space to break a function into paragraphs. Rule 1-5: Avoid very long statements. Use multiple shorter statements instead.

Rule 1-3: Use white space to break a function into paragraphs. Rule 1-5: Avoid very long statements. Use multiple shorter statements instead. Chapter 9: Rules Chapter 1:Style and Program Organization Rule 1-1: Organize programs for readability, just as you would expect an author to organize a book. Rule 1-2: Divide each module up into a public

More information

Debugging (Part 1) The material for this lecture is drawn, in part, from The Practice of Programming (Kernighan & Pike) Chapter 5

Debugging (Part 1) The material for this lecture is drawn, in part, from The Practice of Programming (Kernighan & Pike) Chapter 5 Debugging (Part 1) The material for this lecture is drawn, in part, from The Practice of Programming (Kernighan & Pike) Chapter 5 1 For Your Amusement When debugging, novices insert corrective code; experts

More information

CS4023 Week04 Lab Exercise

CS4023 Week04 Lab Exercise CS4023 Week04 Lab Exercise Lab Objective: We will use this lab to log in to our Linux accounts and to look at some simple programs that perform a few elementary system calls. By the end of the lab we will

More information

The Parts of a C++ Program

The Parts of a C++ Program HOUR 2 The Parts of a C++ Program What You ll Learn in This Hour:. Why you should choose C++. The specific parts of any C++ program. How the parts work together. What a function is and what it does Why

More information

Pointers. A pointer is simply a reference to a variable/object. Compilers automatically generate code to store/retrieve variables from memory

Pointers. A pointer is simply a reference to a variable/object. Compilers automatically generate code to store/retrieve variables from memory Pointers A pointer is simply a reference to a variable/object Compilers automatically generate code to store/retrieve variables from memory It is automatically generating internal pointers We don t have

More information

9/3/2016. ECE 120: Introduction to Computing. Few Programmers Write Instructions (Assembly Code) Spend a Week Learning the C Programming Language

9/3/2016. ECE 120: Introduction to Computing. Few Programmers Write Instructions (Assembly Code) Spend a Week Learning the C Programming Language University of Illinois at Urbana-Champaign Dept. of Electrical and Computer Engineering ECE 120: Introduction to Computing Introduction to the C Programming Language Few Programmers Write Instructions

More information

Finding and Fixing Bugs

Finding and Fixing Bugs C Finding and Fixing Bugs C.1 Introduction As you will quickly find the BUG is the pain of all programmers existence. This section looks at the most common types of BUGS and some of the strategies for

More information

Code::Blocks Student Manual

Code::Blocks Student Manual Code::Blocks Student Manual Lawrence Goetz, Network Administrator Yedidyah Langsam, Professor and Theodore Raphan, Distinguished Professor Dept. of Computer and Information Science Brooklyn College of

More information

6.088/6.084 Robotics Project Subject Information and Syllabus

6.088/6.084 Robotics Project Subject Information and Syllabus 6.088/6.084 Robotics Project Subject Information and Syllabus Staff: Prof. Daniela Rus (Course Coordinator), Rm 32-374, rus@csail.mit.edu, x8-7567 Dr. Nikolaus Correll, Rm 32-375, nikolaus@csail.mit.edu,

More information

Continue: How do I learn C? C Primer Continued (Makefiles, debugging, and more ) Last Time: A Simple(st) C Program 1-hello-world.c!

Continue: How do I learn C? C Primer Continued (Makefiles, debugging, and more ) Last Time: A Simple(st) C Program 1-hello-world.c! Continue: How do I learn C? C Primer Continued (Makefiles, debugging, and more ) Hello Word! ~/ctest/ In addition to syntax you need to learn: the Tools the Libraries. And the Documentation. Maria Hybinette,

More information

Programming. Introduction to the course

Programming. Introduction to the course Programming Introduction to the course Motivation 2 What is Programming? } Some definitions: } Telling a very fast moron exactly what to do } A plan for solving a problem on a computer } The process of

More information

Working with Macros. Creating a Macro

Working with Macros. Creating a Macro Working with Macros 1 Working with Macros THE BOTTOM LINE A macro is a set of actions saved together that can be performed by issuing a single command. Macros are commonly used in Microsoft Office applications,

More information

How To Get Your Word Document. Ready For Your Editor

How To Get Your Word Document. Ready For Your Editor How To Get Your Word Document Ready For Your Editor When your document is ready to send to your editor you ll want to have it set out to look as professional as possible. This isn t just to make it look

More information

Basic Computer Skills: An Overview

Basic Computer Skills: An Overview Basic Computer Skills: An Overview Proficiency in the use of computers and common software packages is essential to completing technical tasks and in communicating results. The basic skills required include:

More information

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 1. Spring 2011

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 1. Spring 2011 Oregon State University School of Electrical Engineering and Computer Science CS 261 Recitation 1 Spring 2011 Outline Using Secure Shell Clients GCC Some Examples Intro to C * * Windows File transfer client:

More information

C Compilation Model. Comp-206 : Introduction to Software Systems Lecture 9. Alexandre Denault Computer Science McGill University Fall 2006

C Compilation Model. Comp-206 : Introduction to Software Systems Lecture 9. Alexandre Denault Computer Science McGill University Fall 2006 C Compilation Model Comp-206 : Introduction to Software Systems Lecture 9 Alexandre Denault Computer Science McGill University Fall 2006 Midterm Date: Thursday, October 19th, 2006 Time: from 16h00 to 17h30

More information

LECTURE 0: Introduction and Background

LECTURE 0: Introduction and Background 1 LECTURE 0: Introduction and Background September 10, 2012 1 Computational science The role of computational science has become increasingly significant during the last few decades. It has become the

More information

Introduction to C. CS2023 Winter 2004

Introduction to C. CS2023 Winter 2004 Introduction to C CS2023 Winter 2004 Outcomes: Introduction to C After the conclusion of this section you should be able to Recognize the sections of a C program Describe the compile and link process Compile

More information

Kindle Books The C Programming Language

Kindle Books The C Programming Language Kindle Books The C Programming Language The authors present the complete guide to ANSI standard C language programming. Written by the developers of C, this new version helps readers keep up with the finalized

More information

Data Modeling, Normalization and Denormalization

Data Modeling, Normalization and Denormalization Data Modeling, Normalization and Denormalization Nordic PgDay 2018, Oslo Dimitri Fontaine CitusData March 13, 2018 Dimitri Fontaine (CitusData) Data Modeling, Normalization and Denormalization March 13,

More information

A function is a named piece of code that performs a specific task. Sometimes functions are called methods, procedures, or subroutines (like in LC-3).

A function is a named piece of code that performs a specific task. Sometimes functions are called methods, procedures, or subroutines (like in LC-3). CIT Intro to Computer Systems Lecture # (//) Functions As you probably know from your other programming courses, a key part of any modern programming language is the ability to create separate functions

More information

Introduction to Computer Systems

Introduction to Computer Systems Introduction to Computer Systems Web Page http://pdinda.org/ics Syllabus See the web page for more information. Class discussions are on Piazza We will make only minimal use of Canvas (grade reports, perhaps

More information

Think of drawing/diagramming editors. ECE450 Software Engineering II. The problem. The Composite pattern

Think of drawing/diagramming editors. ECE450 Software Engineering II. The problem. The Composite pattern Think of drawing/diagramming editors ECE450 Software Engineering II Drawing/diagramming editors let users build complex diagrams out of simple components The user can group components to form larger components......which

More information

Introduction to Modern Fortran

Introduction to Modern Fortran Introduction to Modern Fortran p. 1/?? Introduction to Modern Fortran See next foil for copyright information Nick Maclaren nmm1@cam.ac.uk March 2014 Introduction to Modern Fortran p. 2/?? Acknowledgement

More information

UNIVERSITI TEKNIKAL MALAYSIA MELAKA FACULTY INFORMATION TECHNOLOGY AND COMMUNICATION (FTMK) BITE 1513 GAME PROGRAMMING I.

UNIVERSITI TEKNIKAL MALAYSIA MELAKA FACULTY INFORMATION TECHNOLOGY AND COMMUNICATION (FTMK) BITE 1513 GAME PROGRAMMING I. y UNIVERSITI TEKNIKAL MALAYSIA MELAKA FACULTY INFORMATION TECHNOLOGY AND COMMUNICATION (FTMK) BITE 1513 GAME PROGRAMMING I Lab Module 1 INTRODUCTION OF GAME PROGRAMMING WITH C++ 1.0 Amplitude Modulation

More information

LECTURE 3 ADMINISTRATION SECTION -A

LECTURE 3 ADMINISTRATION SECTION -A LECTURE 3 SYSTEM PROGRAMMING & SYSTEM ADMINISTRATION SECTION -A INTRODUCTION Interpreters Compilers Text editors Debug monitors Programming environment INTERPRETERS An interpreter may be a program that

More information

Compilation I. Hwansoo Han

Compilation I. Hwansoo Han Compilation I Hwansoo Han Language Groups Imperative von Neumann (Fortran, Pascal, Basic, C) Object-oriented (Smalltalk, Eiffel, C++) Scripting languages (Perl, Python, JavaScript, PHP) Declarative Functional

More information

Chapter 1 Introduction

Chapter 1 Introduction Chapter 1 Introduction Hi! Welcome to my beginners guide to C++. If you are starting to program for the first time, I hope that you find the chapters I have written useful. C++ is an excellent language

More information

1 Getting used to Python

1 Getting used to Python 1 Getting used to Python We assume you know how to program in some language, but are new to Python. We'll use Java as an informal running comparative example. Here are what we think are the most important

More information

CIT 590 Homework 5 HTML Resumes

CIT 590 Homework 5 HTML Resumes CIT 590 Homework 5 HTML Resumes Purposes of this assignment Reading from and writing to files Scraping information from a text file Basic HTML usage General problem specification A website is made up of

More information

Construction: High quality code for programming in the large

Construction: High quality code for programming in the large Construction: High quality code for programming in the large Paul Jackson School of Informatics University of Edinburgh What is high quality code? High quality code does what it is supposed to do......

More information

Computer Science 210: Data Structures

Computer Science 210: Data Structures Computer Science 210: Data Structures Welcome to Data Structures! Data structures are fundamental building blocks of algorithms and programs Csci 210 is a study of data structures design efficiency implementation

More information