20
UNIT 2

UNIT 2

Embed Size (px)

Citation preview

Page 1: UNIT 2

UNIT 2

Page 2: UNIT 2

A program is a set of logically related instructions that are arranged in a sequence that guide the computer to solve a particular problem. The process of writing such programs for an analyzed problem is called programming or coding, if a system is not correctly programmed it will produce incorrect result

Page 3: UNIT 2

`

A language is a system of communication. In order to communicate with each other, human beings need languages like, English ,French, Hindi etc. in the same way for communication with computer we need computer languages ,the computer language is also known as programming languages .” A programming language is a set of written symbols, characters and usage rules that instruct the computer hardware to perform a specific task,

Page 4: UNIT 2

use of these symbols is governed by set of rules called syntax

Fundamental difference between a natural language and computer language is that in case of natural language people can use incorrect vocabulary ,grammar and style and make themselves understand

However in computer languages correct syntax is must ,i.e. even a single ,small syntax error make the program error prone.

Page 5: UNIT 2

so computer languages are very much sensitive to their syntaxes ,incorrect words punctuation marks and spelling etc, which make program syntactically incorrect

Page 6: UNIT 2

Computer languages are classified in following four categories

• Declarative languages• Machine language• Assembly language• High level language

Page 7: UNIT 2

• Declarative language -: Declarative language -: these are just like English in their expressive power and functionality ,that’s why these are kept at the highest level ,basically command languages dominated by statement which express what to do rather than how to do

Page 8: UNIT 2

• Machine language -: Machine language -: directly understood by computer without any translation, in the form of binary strings 1 and 0

• Entire circuitry of a computer is designed in such a way that it understands the machine language instructions and converts them into electrical signals required to run the computer

Page 9: UNIT 2

• Instructions written in any machine language has two parts

operation code operand location or addressOperation code-: indicate the name of command or

operation to be performed by the computer ,in other words it direct the computer that what function has to be performed

Page 10: UNIT 2

• Operand address/location -: it tell the computer where to find or store the data or instruction that are to be operated ,in this manner each instruction tell the control unit of the computer ,what to do? And the address of the data to be operated upon

• Machine level languages are low level language, difficult to write, learn, understand

Page 11: UNIT 2

Disadvantage-: Disadvantage-: • machine dependent• Difficult to write program• Error prone• Difficult to modify

Page 12: UNIT 2

Assembly languageAssembly language

• Low level language ,knowledge of hardware specification is must

• Use of mnemonics in place of machine code, this made the programming easy and efficient ,by using mnemonics the programmer need not to remember operation codes and storage locations

Mnemonics-: Mnemonics-: lLDA – LoadingMUL- multiplyingSUB- subtracting

Page 13: UNIT 2

Example-: CLA XADD YSTA ZTYP ZHLT

Computer cannot execute an assembly language program directly because computer can understand only binary codes ,translator translates assembly language program into machine code is known as assembler

Page 14: UNIT 2

• Program that is written in language other than machine language is called source program, the translated program into machine code is called object code

Execution process-: 1 when computer is switched on ,the loader program is

automatically loaded in the main memory2) Now loader stores the assembler in the main memory3) Assembler reads each instruction of an assembly

language program one by one and converts it into machine code and stores in main memory

Page 15: UNIT 2

• After full conversion into machine code, each instruction of machine code is executed

Advantages Advantages • Easier to memorize • Easy to write input data• Easy to detect and correct error• Easy print out• Good library facility

Page 16: UNIT 2

• DisadDisadvantagesTime consumingMachine dependentKnowledge of hard ware required

Page 17: UNIT 2

High level languageHigh level language

• Problem oriented and machine independent, instructions or commands are generally written using English words and mathematical symbols, it does not use mnemonic code

Features Features Problem orientedMachine independentSymbolic languageSimple in nature

Page 18: UNIT 2

• Easy to write and understand the program• Arithmetic rules are well defined

Types of HLLTypes of HLLCommercial languages - COBOLScientific languages -: APL, FORTAN 77Special purpose languages -: GPSSCommand languagesMultipurpose languages

Page 19: UNIT 2

advantagesadvantages

• Readability• Machine independent• Fewer error and easy debugging• Lower program preparation cost• Better documentation• Easier to maintain• Easy to understand

Page 20: UNIT 2

disadvantagesdisadvantages

• Speed• Memory