Professional Documents
Culture Documents
Lec02 SoftwareAlgorithmCS
Lec02 SoftwareAlgorithmCS
Introduction to Programming C#
Edip ŞENYÜREK
1
Program (Software)
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
• 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
• 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
P1 P2 Pn User Programs
Edip ŞENYÜREK
Thank you!!!
10