Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

Technical Foundations of Computer Science III

System Programming (C)


Seyyed Kamran Hosseini Lecture 1
Introduction
Herat University
Computers: Hardware and Software

• A computer is a device that can perform computations


and make logical decisions billions of times faster than
human beings can
 many of today’s personal computers can perform several
billion additions per second
• Computers process data under the control of sets of
instructions called computer programs.
• These programs guide the computer through orderly sets
of actions specified by people called computer
programmers.
• The computer programs that run on a computer are
referred to as software.
Computer Organization

• Input unit
• Output unit
• Memory unit
• Arithmetic and logic unit (ALU)
• Central processing unit (CPU)
• Secondary storage unit
Programming Languages

• Programmers write instructions in various programming


languages, some directly understandable by computers
and others requiring intermediate translation steps.
• These may be divided into three general types:
1. Machine languages
2. Assembly languages
3. High-level languages
Machine Language

• Any computer can directly understand only its own


machine language.
 Machine language is the “natural language” of a computer
and as such is defined by its hardware design.

• Machine languages generally consist of strings of


numbers (ultimately reduced to 1s and 0s) that instruct
computers to perform their most elementary operations
one at a time.
• Machine languages are machine dependent.
Assembly Language
• Machine-language programming was simply too slow,
tedious and error prone for most programmers.
• Instead of using the strings of numbers, programmers
began using English-like abbreviations to represent
elementary operations.
 These abbreviations formed the basis of assembly
languages.
• Translator programs called assemblers were
developed to convert early assembly-language programs
to machine language at computer speeds.
• Example:
 load basepay
 add overpay
 store grosspay
High-level languages

• To speed the programming process, high-level


languages were developed in which single statements
could be written to accomplish substantial tasks.
• Translator programs called compilers convert high-level
language programs into machine language.
• High-level languages allow programmers to write
instructions that look almost like everyday English and
contain commonly used mathematical notations.
• Example:
 grossPay = basePay + overTimePay;
High-level Programming Languages

• C
• C++
• Microsoft’s .NET languages
• Java
• Python
• …
Compiler and Interpreter

• Compilers convert high-level language programs into


machine language.
• Interpreter programs were developed to execute high-
level language programs directly (without the delay of
compilation), although slower than compiled programs
run.
C Language

• Currently, the most commonly-used language for


embedded systems
• Very portable: compilers exist for virtually every
processor
• Easy-to-understand compilation
• Produces efficient code
• Fairly concise
History of C

• Developed between 1969 and 1973 along with Unix


• Due mostly to Dennis Ritchie
• Designed for systems programming
 Operating systems
 Utility programs
 Compilers
 ...
• C Language Evolved from B, which evolved from BCPL
C – Built for Performance

• Operating Systems
 Unix, Linux, Android, portions of Windows, OS-X built
on Objective C
• Embedded Systems
 GPS, Intelligent Traffic Alert, Robots
• Real-time Systems
 Air traffic control, Industrial automation
• Communication Systems
• C-based programming languages
 Objective C, Java, Visual C#
Typical C development Environment

• C programs typically go through six phases to be


executed.
• These are:
 Edit
 Preprocess
 Compile
 Link
 Load
 Execute
Phase 1: Creating a Program
Phases 2 and 3: Preprocessing
and Compiling a C Program
Phase 4: Linking
Phase 5: Loading
Phase 6: Execution
Note
• Please read the book from page 3 to 14.

You might also like