5.2 Language Translators
5.2 Language Translators
5.2 Language Translators
5.2 Language
translators
Zain Merchant
2
Zain Merchant
3
Pre-reading questions
1.
A. Name two types of language translator.
B. Identify a method, other than using a translator, of executing a program written in
a high-level language.
2. 2 Most modern language translators offer an Integrated Development Environment (IDE)
for program development.
A. Which IDE are you using?
B. Describe ve features offered by the IDE you use.
C. Which feature do you nd most useful?Why is it useful to you?
Zain Merchant
fi
fi
4
Assemblers
Programs written in assembly language are translated into machine code by an
assembler program. Assemblers either store the program directly in main memory,
ready for execution, as it is translated, or they store the translated program on a
storage medium to be used later. If stored for later use, then
a loader program is also needed to load the stored translated program into main
memory before it can be executed. The stored translated program can be
executed many times without being re-translated.
Every different type of computer/chip has its own machine code and assembly
language. For example, MASM is an assembler that is used for the X86 family of
chips, while PIC and GENIE are used for microcontrollers. Assembly language
programs are machine dependent; they are not portable from one type of
computer/chip to another.
Here is a short sample PIC assembly program:
Assembly language programs are often written for tasks that need to be speedily
executed, for example, parts of an operating system, central heating system or
controlling a robot.
Zain Merchant
5
The stored translated program can be executed many times without being
retranslated. The program will only need to be retranslated when changes are
made to the source code.
With an interpreter, no translated program is generated in main memory or stored
for later use. Every line in a program is interpreted then executed each time the
program is run.
High-level language programs are machine independent, portable and can be run
on any type of computer/chip, provided there is a compiler or interpreter
available. For example, Java, Python and Visual Basic® (VB) are high-level
languages often used for teaching programming.
Zain Merchant
6
Zain Merchant
7
Zain Merchant
8
Zain Merchant
9
Zain Merchant
10
Integrated development
environment (IDE)
An integrated development environment (IDE) is used by programmers to
aid the writing and development of programs. There are many different IDEs
available; some just support one programming language, others can be used for
several different programming languages. NetBeans®, PyCharm®, Visual Studio®
and SharpDevelop are all IDEs currently in use.
Dynamic syntax checking nds possible syntax errors as the program code
is being typed in to the source code editor and alerts the programmer at the time,
before the source code is interpreted. Many errors can therefore be found and
corrected during program writing and editing before the program is run. Logic
errors can only be found when the program is run.
For larger programs that have more than one code block, some code blocks can
be collapsed to a single line in the editor allowing the programmer to just see the
code blocks that are currently being developed.
Auto-documenter
Most IDEs usually provide an auto-documenter to explain the function and
purpose of programming code.
Zain Merchant
fi
fi