0% found this document useful (0 votes)
193 views4 pages

1.5.4 Translator Software

This document discusses different types of system software called language translators, which convert source code into machine code. It describes three main types: assemblers, which convert assembly code into machine code in a 1:1 ratio; interpreters, which convert code line-by-line; and compilers, which convert an entire program at once. Assemblers provide fast translation but require more code. Compilers produce executable files but the source code must be correct. Interpreters are easier to debug but slower than compiled code. Java code is partially compiled then interpreted by the Java Virtual Machine.

Uploaded by

qamarmemon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
193 views4 pages

1.5.4 Translator Software

This document discusses different types of system software called language translators, which convert source code into machine code. It describes three main types: assemblers, which convert assembly code into machine code in a 1:1 ratio; interpreters, which convert code line-by-line; and compilers, which convert an entire program at once. Assemblers provide fast translation but require more code. Compilers produce executable files but the source code must be correct. Interpreters are easier to debug but slower than compiled code. Java code is partially compiled then interpreted by the Java Virtual Machine.

Uploaded by

qamarmemon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Computer Science 9608 (Notes)

Chapter: 1.5 System software

Topic: 1.5.4 Language translators


The final type of system software that you need to know is translator software. This is software that
allows new programs to be written and run on computers, by converting source code (human readable)
into machine code. There are three types that we'll cover in a lot more detail shortly:

Assembler - converts assembly code into machine code


Interpreter - converts 3rd generation languages such as JavaScript into machine code one line at a
time
Compiler - converts 3rd generation languages such as C++ into machine code all at once

Assembler
An assembler translates assembly language into machine code. Assembly language consists of
0T 0T 0T 0T

mnemonics for machine opcodes so assemblers perform a 1:1 ratio translation from mnemonic to a
direct instruction. For example:

30T LDA #4 converts to 0001001000100100


0T3 0T 0T 0T3

Conversely, one instruction in a high level language will translate to one or more instructions at machine
level.

Advantages of using an Assembler Disadvantages of using Assembler


Very fast in translating assembly language to Assembly language is written for a certain
machine code as 1 to 1 relationship instruction set and/or processor
Assembly code is often very efficient (and Assembly tends to be optimized for the
therefore fast) because it is a low level hardware it's designed for, meaning it is
language incompatible with different hardware
Assembly code is fairly easy to understand due Lots of assembly code is needed to do
to the use of English-like mnemonics relatively simple tasks, and complex programs
require lots of programming time

By: Prof.Qamar Shahzad Memon Page 1 of 4


Contact: 03336598665
Computer Science 9608 (Notes)
Chapter: 1.5 System software

Topic: 1.5.4 Language translators


Compiler
A Compiler is a computer program that translates code written in a high level language to a lower level
0T 0T 0T 0T 0T 0T 0T 0T

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


Source code is not included, therefore Object code needs to be produced
compiled code is more secure than before a final executable file, this can
interpreted code be a slow process
Tends to produce faster code than The source code must be 100% correct
interpreting source code for the executable file to be produced
Produces an executable file, and
therefore the program can be run
without need of the source code

Interpreter
35T

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

Easier to debug(check errors) than a Source code is required for the


compiler program to be executed, and this
Easier to create multi-platform code, source code can be read making it
as each different platform would have insecure
an interpreter to run the same code Interpreters are generally slower than
Useful for prototyping software and compiled programs due to the per-line
testing basic program logic translation method.

By: Prof.Qamar Shahzad Memon Page 2 of 4


Contact: 03336598665
Computer Science 9608 (Notes)
Chapter: 1.5 System software

Topic: 1.5.4 Language translators

By: Prof.Qamar Shahzad Memon Page 3 of 4


Contact: 03336598665
Computer Science 9608 (Notes)
Chapter: 1.5 System software

Topic: 1.5.4 Language translators


Few of the high-level language programs may be partially compiled and partially interpreted, such as Java. Typical
Java environment consists of two programs: Java compiler and Java Virtual Machine. Java compiler takes the source
code written in Java programming language, together with precompiled libraries, and compiles programs written in
Java programming languages into class files containing Java byte-code.

The Java Virtual Machine takes the byte code prepared by the Java compiler and executes it. The byte-code itself is
platform-independent; it is the responsibility of the Java Virtual Machine implementation to execute the program in
the byte-code form on the real computer.

So, the java code is partially compiled for optimization by the programmer. The user runs the code on a Java virtual
machine on their computers that interprets the java code for the users' computer specific architecture.

By: Prof.Qamar Shahzad Memon Page 4 of 4


Contact: 03336598665

You might also like