Computer Science SS1 Second Term
Week 4:
Topic: Translators
Introduction
Translators are highly developed programs capable of converting high level language to machine language, low level language to machine language. A translator is a computer program that performs the translation of a program written in a given programming language into a functionally equivalent program in a different computer language, without losing the functional or logical structure of the original code (the “essence” of each program).
Types of Translators
- Assembler
- Compiler
- Interpreter
-
- If the translator translates a high level language into another high level language, it’s called a translator or source-to-source compiler. Examples include Haxe, FORTRAN-to-Ada translators, CHILL-to-C++ translators, PASCAL-to-C translators, COBOL (DialectA)-to-COBOL(DialectB) translators.
- If the translator translates a high level language into a lower level language it is called a compiler. Notice that every language can be either translated into a (Turing-complete) high level or assembly language.
- If the translator translates a high level language into an intermediate code which will be immediately executed it is called an interpreter.
- If the translator translates target/machine code to source language it is called a decompiler. Example: DCC, Boomerang Decompilers and Reverse Engineering Compiler(REC).
- If the translator translates assembly language to machine code it is called an assembler. Examples include MASM, TASM and NASM.
- If the translator translates machine code into assembly language it is called a disassembler. Examples include gdb, IDA Pro and OllyDbg.
- Translators that translate from a human-readable design specified in terms of rules and high level functions, into the equivalent logic gates and chip layout needed to achieve its manufacture, belong to electronic design automation and hardware description language categories.
1. Assembler: This is a translator that is capable of converting low level language to machine language directly. An assembler translates assembly language into machine code. Assembly language consists of mnemonics for machine opcodes so assemblers perform a 1:1 translation from mnemonic to a direct instruction.
For example: LDA #4
converts to 0001001000100100
Advantages of using an Assembler:
Disadvantages of using Assembler:
2. Compiler: This is a translator that is capable of converting high level language to machine language directly. A Compiler is a computer program that translates code written in a high level language to a lower level language, object/machine code. The most common reason for translating source code is to create an executable program (converting from a high level language into machine language).
Advantages of using a compiler
Disadvantages of using a compiler
3. Interpreter: An interpreter program executes other programs directly, running through program code and executing it line-by-line. As it analyses every line, an interpreter is slower than running compiled code but it can take less time to interpret program code than to compile and then run it — this is very useful when prototyping and testing code. Interpreters are written for multiple platforms, this means code written once can be run immediately on different systems without having to recompile for each. Examples of this include flash based web programs that will run on your PC, MAC, games console and Mobile phone.
Advantages of using an Interpreter
Disadvantages of using an Interpreter
Stages of Programming
There are six stages in developing a good program.
- Program analysis
- Program design
- Program coding
- Program verification
- Program documentation
- Program maintenance
Flow chart: This is the pictorial or graphical representation of steps in writing a program.
[fusion_builder_container hundred_percent=”yes” overflow=”visible”][fusion_builder_row][fusion_builder_column type=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none”]
A logarithm is the step by step procedure in solving a problem or task
Basic Programming Language
The programming language must have the following basics
- Language syntax: This involves codes which are understood by computer compiler of the computer language. Example “20” is a Hausa syntax. Compiler has its own syntax and it includes
- REM
- Input
- Output
- Tab
- Variable: Also known as identifier, which contains some known or unknown quantity of information referred to as a value.
- Constant: These are data items which do not change during program execution.
Examples include:
1, 2, 3 ……..
A, B, C, .…..
- Operator: This can be arithmetic, relational or logic.
Examples:
Arithmetic operators include (arithmetic language)
+ = addition
– = subtraction
x = multiplication
/ = division
؈ or ** = Exponent
Relational operators include
= for equality
> = greater than
< = less than
≤ = less than or equal to
≥ = greater than or equal to
Logical operations
True or false
Yes or no
OR or AND
Every program must have
- Beginning
- End
- Body
For more notes, visit: http://passnownow.com/classwork-support/
[/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]