Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 10

CII1SE15CI-Z17

Introduction to Programming C#

Edip ŞENYÜREK

1
Program (Software)

• Conceptually a program is a step-by-step solution to a problem


• Also named an algorithm
• A well-defined computational procedure that takes some values (data) as
input and produces some results as output

Input (DATA) Output (Results)


ALGORITHM

2
3
Example Program: Compute the sum,
product and avg of 2 numbers, a & b
DATA
ALGORITHM
IP a  10
IP 10
? a
b  40
IP b
sum  a+b ?
40
IP product  a*b
IP avg  sum/2 ?
50 sum
IP print sum
IP ?
400 product
print product
IP print avg 25
? avg

SCREEN
50
400
25 4
Basic Operation of the Computer

• loop:
• Fetch the next instruction from memory
• Decode the instruction
• Interpret what the instruction means

• Fetch the operands (if necessary)


• Fetch the operands from memory to CPU registers

• Execute the instruction


• Perform what the instruction is telling us to do (add, subtract, multiply,
divide, …)

• Store the result back to memory (if necessary)

• repeat
5
Example Program Execution
MEMORY
IP S1: a  10
IP
S2: b  40

Instructions
IP S3: sum  a + b
IP
IP S4: product  a*b
CPU S5: avg  sum/2
IP
S6: print sum
IP S7: print product
Registers IP S8: print avg
IP 50
10 SCREEN
S4
S2
S6
S7
S8
S5
S3
S1 40
25 10
? a
ALU/
400
50 40
? b 50
Control FPU
DATA

Unit 50
? sum 400
400
? product 25
25
? avg

6
From Algorithm to 0s and 1s

• Although we showed the instructions stored in memory in


pseudo-code (human readable form), what is really stored is 0s
and 1s
• Remember a computer only understands 0s and 1s

• This means that we need tools that would help us convert the
program from human-readable form to the machine-readable
form called the machine language
• These tools are called system software tools

7
System Software Components
• We have several system software components to make
programming the computer easy
• High-level Programming Languages (C, C++, Java, C#, ..)
• Compiler
• Converts your programs implemented in high-level language to assembly
language, which are mnemonic codes that correspond one-to-one with
machine language

• Assembler
• Converts programs implemented in assembly language to machine
language, which are binary number codes understood by a specific CPU

• Linker
• Combines several object files together into an executable

• Loader + Operating System


• Loads your program into memory for execution 8
Operating System
• Is a layer of software that exports an easy-to-use interface to
program the hardware

P1 P2 Pn User Programs

System call API


Operating System (Windows, Linux, Solaris, …)
Hardware API
Hardware

• User programs make use of the hardware


through the services provided by the OS
– Thus OS makes life easier for user programs
9
CII1SE15CI-Z17
Introduction to Programming C#

Edip ŞENYÜREK
Thank you!!!

10

You might also like