There are three language levels that can be used to write a program.1. Machine level language 2. Assembly level language 3. High level language.
Interaction Between
Assembly and Higher Level Language
• There are three language levels that
can be used to write a program.
1. Machine level language 2. Assembly
level language 3. High level language.
• A program which has simply a sequence
of the binary codes for the instructions is called machine level language
program. This binary form of the program is referred to as machine language
because it is the form required by the machine. However, to write a program in
machine language, programmer has to memorize the thousands of binary
instruction codes for a processor. This task is difficult and error prone.
• To make programming easier, usually
programmers write programs in assembly language. They translate the assembly
language program to machine language so that it can be loaded into memory and
executed. Assembly language uses two, three or four letter words to represent
each instruction types. These words are referred to as mnemonics.
• The letters in an assembly language
mnemonic are usually initials or a shortened form of the English word(s) for
the operation performed by the instruction. For example, the mnemonic for
addition is ADD, the mnemonic for logic AND
operation is AND, and the mnemonic for
the instruction for copy data from one location to another is MOV. Therefore,
the meaning expressed by mnemonics help us to remember the operation performed
by the instruction.
• Assembly language statements are
usually written in a standard form and assembly language has its own unique
syntactical structure, such as requiring upper case or lower case, or requiring
colons after label definitions. Here we discuss the common features that
assembler shares.
• The assembly text is usually divided
into fields, separated by spaces and tabs. A format for a typical line from
assembly language program can be given as
Label: Mnemonic Operand1, Operand2;
Comment
• The first field, which is optional, is
the label field, used to specify symbolic labels. A label is an identifier that
is assigned to the address of the first byte of the instruction in which it
appears. As mentioned earlier, the presence of a label is optional, but if
present, the label provides a symbolic name that can be used in branch
instructions to branch to the instruction.
• The second field is mnemonic, which is
compulsory. All instructions must contain a mnemonic. The third and following
fields are operands. The presence of the operands depends on the instruction.
Some instructions have no operands, some have one, and some have two. If there
are two operands, they are separated by a
comma.
• The last field is a comment field. It
begins with a delimiter such as the semicolon and continues to the end of the
line. The comments are for our benefits, they tell us what the program is
trying to accomplish. Fig. 6.12.1 shows a typical 8086 assembly language
instruction.
•Another way of writing a program for a
microcomputer is with a high-level language, such as Basic, Pascal, C, or C++.
The program statements used in such languages are even more English-like than
those of assembly language. Each program statement in high-level language
represents one or more than one machine code instructions. The program
statements in the high-level language are converted into machines codes with
the help of interpreter or compiler.
•Since one program statement in
high-level language has many machine code instructions, high-level language
programs are written faster than assembly or machine language programs.
However, programs written in a high-level language needs interpretation or
compilation and hence they always execute more slowly and require more memory
than the same programs written in assembly language. The Table 6.12.1 shows the
comparison between machine, assembly and high-level languages.
• The computer understands only machine
language. So, a translator is needed to translate the symbolic statements of a
high level language into computer executable machine language.
• The programs that translate high-level
programs into machine language are called interpreters and compilers.
• Compiler: A compiler is a program which
translates the source code written in a high-level language into
computer-readable machine language that can be directly loaded and executed.
• Interpreter: Unlike compiler, an
interpreter translates a high-level language statement in a source program to a
machine code and executes it immediately, before translating the next source
language statement. When an error is found, the execution of the program is
halted and an error message is displayed on the screen of the computer.
Comparison between Interpreter and
Compiler
Review Questions
1. What do you mean by machine language
program?
2. What do you mean by assembly language
program?
3. Give comparison between machine
level, assembly level and high level languages.
4. What is compiler?
5. What is interpreter ?
6. Give comparison between compiler and
interpreter.
Digital Principles and Computer Organization: Unit III: Computer Fundamentals : Tag: : Computer Fundamentals - Digital Principles and Computer Organization - Interaction Between Assembly and Higher Level Language
Digital Principles and Computer Organization
CS3351 3rd Semester CSE Dept | 2021 Regulation | 3rd Semester CSE Dept 2021 Regulation