Slide Set - 06
Slide Set - 06
CP & CPSA
17ME & 17PG
Contents
• Computer programming (LL 02)
• Why programming? (LL 02)
• Instructions and Program (LL 02)
• Low level, High level and Middle level programming languages (LL 02)
• Source Code and Object Code (LL 02)
• Language Translators (LL 02)
• Compiler (LL 02)
• Interpreter (LL 02)
• Assembler (LL 02)
• Why language translators? (LL 02)
Contents
• Difference between compiler and interpreter (LL 04)
• Bug and Debugging (LL 02)
• If we need our computer to perform some task, we first have to teach the
computer in detail “how it will accomplish that task?”
• Once the computer is taught about a particular task, it will completely obey
it but cannot do anything that it is not taught to.
Why Programming?
• Like the humans, we can teach the computer through communicating with it
using a particular language.
DO THIS!
Instruction
• Instruction is any command given to the computer.
• For example:
1) Add two variables A and B
2) Display result
3) Read file
NOW DO THIS!
NOW DO THIS!
NOW DO THIS!
NOW DO THIS!
NOW DO THIS!
Program
• Program is a set (collection) of instruction to do a meaningful task.
• Instructions 1-6 are used to solve a single task. This collection of instruction
is known as a program.
Programming Language
Programming Language
LANGUAGE
• Here all the instructions are written as code of binary sequence. For
example:
• In order to do addition, the code is: 10010001
• In order to decrement a number by one, the code is: 11011011
• In order to move data from one place to another, the code is:
10000111
Machine Language
• For example: Instead of binary codes it uses : ADD, MOV, SUB, INC
• It is easier than the machine language but still it is very difficult to control
a larger program using assembly.
Assembly Language
MVI A, 05h
MVI B, 9Ah
ADD B
INC A
STA 8200h
HLT
High-Level Language
LANGUAGE
• Like assembly language, it also uses English like words for the
operations.
if(a > b)
cout<<“First number is greater.”;
else
cout<<“Second number is greater.”;
}
Middle-Level Language
LANGUAGE
• A language that has the features of both low level and high
level languages.
CONVERT
Source Code Translator Object Code
Language Translator
Why Language Translators?
• Computer only understands object code (machine code).
• It does not understand any source code.
• There must be a program that converts source code in to the object code
so that the computer can understand it.
CONVERT
Assembly
Assembler Object Code
Source Code
Compiler
1 2 3 4
Interpreter
Program
1
Difference between Compiler and Interpreter
Compiler Interpreter
• It converts whole code at a time. • It converts the code line by line.
• It is faster. • It is slower.
• Errors are displayed after entire program • Errors are displayed for every instruction
is checked. interpreted (if any).