Vous êtes sur la page 1sur 22

CHAPTER 1:

Introduction to Computer Programming


BEE1222: COMPUTER PROGRAMMING

YAW- credit to HAA,RAK & AIH

Syllabus

1.1

Basic Computer
Architecture

1.2

Hardware, Software and


Firmware

1.3

Compiling, Linking and


Producing an Executable
Program
YAW- credit to HAA,RAK & AIH

Lesson Outcomes
1.
2.
3.

Understanding the basic concept of


computer programming
Identify the elements of a typical C program
development environment
To become familiar with fundamental data
type

YAW- credit to HAA,RAK & AIH

Brainstorming

Anything you know about C programming ?


Why you are learning C, not other
programming - Basic, fotran etc..
Why C is so important for electrical
engineering
What C can do for an electrical engineer

YAW- credit to HAA,RAK & AIH

1.1 Basic Computer Architecture


Three main elements of basic computer system:

CPU (central processing unit/microprocessor)


Memory
Input/Output

Three main buses:

Address bus
Control bus
Data bus

YAW- credit to HAA,RAK & AIH

Basic Computer Architecture

Bus System
- It is used to transfer information in the system
6

YAW- credit to HAA,RAK & AIH

Basic Computer Architecture


1)The heart of the
computer
2) does the actual
-processing
-arithmetic and decision
making
-controls the operation of
the rest of the computer

Enables a
computer
to store,
at least
temporarily,
data and
programs.

YAW- credit to HAA,RAK & AIH

- data and
instructions
enter a computer
-lets you see what
the
-computer has
-accomplished

1.2 Hardware, Software, and Firmware

Hardware:
all of the tangible equipment involved in
a computers operation. (e.g Processor,
Hard disk, Keyboard, Printer)
Software:
set of instructions that can be read into
computers memory and later execute on
demand. (e.g.: Microsoft office)
Firmware:
hardware device that is programmed
using software. (e.g. EEPROM)
YAW- credit to HAA,RAK & AIH

Programming language

YAW- credit to HAA,RAK & AIH

Machine Language
Built-in to the CPU
Binary code
Alternative codes:
Octal

Example:

Hexadecimal
bits & bytes

10

YAW- credit to HAA,RAK & AIH

00000000
00010101
00010110
00110101
01110111

Assembly Language
Symbolic/mnemonics
codes
Unstructured
Processor dependent
Assembler translate to
machine language

11

YAW- credit to HAA,RAK & AIH

Example:
CLR
MOV A,#2
ADD A,#2
MOV R0,A
END

High Level Language


Use proper syntax
Easy to understand
Machine/Processor
Independent
Compiler language

12

High Level Language


Fortran (1950s)
Basic (1960s)
Pascal (1960s)
C (1970s)
MATLAB (1970s)

YAW- credit to HAA,RAK & AIH

C Programming Language
History
1972 by Dennis Ritchie
Based on B/BCPL
OS language (UNIX)
ANSI/ISO C (1989/99)
Evolution

13

C++, C#, Ch
Borland C/C++
Visual C/C++

C advantages

Powerful, lean &


efficient language

Less rigid structure

Embedded ability

Bit-manipulation
Low high (mid) level

YAW- credit to HAA,RAK & AIH

language

1.3 Compiling, Linking and Producing an Executable Program

Libraries and
other object
code
Source
code file
(FILE.C)

Editor
(create and modify
code)

Object code
file (FILE.OBJ)

Compiler
(convert source
code into m/c code)

Memory
(RAM or ROM)

Errors and/or warnings

14

YAW- credit to HAA,RAK & AIH

Executable
file
(FILE.EXE)

Compiler & Linker


Compiler
Translate code to machine
language
Linker
Built executable program file
Most modern compiler has built-in linker
capability

15

YAW- credit to HAA,RAK & AIH

Errors in Programming

Compilation error
Syntax error
Easy to identify and
corrected

16

Logic error

Programmer error
Not easy to identify
and correct
May cause run-time
error

YAW- credit to HAA,RAK & AIH

Development Environment
What you needs?
A source code editor
A compiler and linker
An optional debugger
Integrated Development Environment - IDE
All-in-One application (programming) software

17

YAW- credit to HAA,RAK & AIH

Code::blocks Compiler
MinGW ANSI C/C++ (C99) compiler
OSS Licensed IDE for developer
Source editor
Compiler & Linker
Debugger

http://www.codeblocks.org
18

YAW- credit to HAA,RAK & AIH

DEVCpp Compiler
MinGW ANSI C/C++ (C99) compiler
OSS License IDE for developer
Source editor
Compiler & Linker
Debugger

19

YAW- credit to HAA,RAK & AIH

Borland C++ Compiler


Borland C++ (Turbo C/C++) compiler
C++ Builder: IDE for Windows applications
developer
Source Code editor
Compiler & Linker
Debugger

20

YAW- credit to HAA,RAK & AIH

Visual C++ Compiler


Built-in MS Window C++ compiler
MS Visual Studio: IDE for Windows applications
developer
Source Code editor
Compiler & Linker
Debugger

21

YAW- credit to HAA,RAK & AIH

END OF CHAPTER 1
Q& A
Outcomes

1.
2.

3.

22

Understanding the basic concept of computer


programming
Identify the elements of a typical C program
development environment
To become familiar with fundamental data type

Reflection

YAW- credit to HAA,RAK & AIH

Vous aimerez peut-être aussi