Você está na página 1de 4

1.

3 Hardware and software

1.3.7 High- and low-level languages and their translators


Software is created by using a computer language to set out a set of instructions that the computer will follow.
There are many computer languages but they do share some common features. This mini-web takes you
through some of these features.

HIGH LEVEL AND LOW LEVEL LANGUAGES


A high-level language is an advanced computer programming language that isn't limited by the computer,
designed for a specific job, and is easier to understand.
Today, there are dozens of high-level languages; some examples include BASIC, C, FORTAN, Java, C++ and
Pascal. These are independent of the internal machine code of any particular computer.
High-level languages are used to solve problems and are often described as problem-oriented languages; a
low-level language is the opposite of a HighLevel Language. It is one which exposes a significant amount of
the computer's inner workings; for instance, in C Language, one deals with the concept of memory and
pointers, whereas in HaskellLanguage, there is no concept of storing data. This aspect of C Language is lowlevel. The lowest-level language is Machine Code, which hides no details of the machine; not even the bit
patterns used to form instructions are abstracted.
Low-level languages have the advantage that the programmer is able to tune the code to be smaller or more
efficient, and that more system-dependent features are sometimes available. They have the disadvantage that
they are often (usually?) harder to program in.
In computing, a low-level programming language is designed for a particular computer and reflects its
internal MachineCode; low-level languages are therefore often described as machine-oriented languages.
They cannot easily be converted to run on a computer with a different central processing unit, and they are
relatively difficult to learn because a detailed knowledge of the internal workings of the computer is required.
Since they must be translated into machine code by an assembler program, low-level languages are also
called AssemblyLanguages.
A mnemonic-based low-level language replaces binary machine-code instructions, which are very hard to
remember, write down, or correct, with short codes (mnemonics) chosen to remind the programmer of the
instructions they represent. For example, the binary-code instruction that means store the contents of the
accumulator may be represented with the mnemonic STA (Store to Accumulator).
In contrast, high-level languages are designed to solve particular problems and are therefore described as
problem-oriented languages: for example, BASIC was designed to be easily learnt by first-time programmers;
COBOL is used to write programs solving business problems; and FORTRAN is used for programs solving
scientific and mathematical problems.

WHY USE COMPILERS?


A compiler is a special program that processes statements written in a particular programming language and
turns them into machine language or "code" that a computers processor uses. Typically, a programmer writes
Page 1 of 4

1.3 Hardware and software

1.3.7 High- and low-level languages and their translators


language statements in a language such as Pascal or C one line at a time using an editor. The file that is created
contains what are called the source statements. The programmer then runs the appropriate language compiler,
specifying the name of the file that contains the source statements.
When executing (running), the compiler first parses (or analyzes) all of the language statements syntactically
one after the other and then, in one or more successive stages or "passes", builds the output code, making sure
that statements that refer to other statements are referred to correctly in the final code. Traditionally, the
output of the compilation has been called object code or sometimes an object module. (Note that the term
"object" here is not related to object-oriented programming). The object code is machine that the processor
can process or "execute" one instruction at a time.
More recently, the Java programming language, a language used in object-oriented programming , has
introduced the possibility of compiling output (called byte code ) that can run on any computer system
platform for which a Java virtual machine or byte code interpreter is provided to convert the byte code into
instructions that can be executed by the actual hardware processor. Using this virtual machine, the byte code
can optionally be recompiled at the execution platform by a just-in-time compiler .
Traditionally in some operating systems, an additional step was required after compilation - that of resolving
the relative location of instructions and data when more than one object module was to be run at the same time
and they cross-referred to each other's instruction sequences or data. This process was sometimes
called linkage editing and the output known as a load module.
A compiler works with what are sometimes called 3GL and higher-level languages. An assembler works on
programs written using a processor's assembler language.

Page 2 of 4

1.3 Hardware and software

1.3.7 High- and low-level languages and their translators


USING INTERPRETERS AS A MEANS OF TRANSLATION
An Interpreter is a program that implements or simulates a virtual machine using the base set of instructions
of a programming language as its machine language.
You can also think of an Interpreter as a program that implements a library containing the implementation of
the basic instruction set of a programming language in machine language.
An Interpreter reads the statements of a program, analyzes them and then executes them on the virtual
machine by calling the corresponding instructions of the library.
Interactive interpreter session
During an interactive interpreter session the statements are not only read, analyzed and executed but the
result of the evaluation of an expression is also printed. This is also called a READ - EVAL - PRINT loop.
ASSEMBLERS
A utility program called an assembler is used to translate assembly language statements into the target
computer's machine code. The assembler performs a more or less isomorphic translation (a one-to-one
mapping) from mnemonic statements into machine instructions and data. This is in contrast with high-level
languages, in which a single statement generally results in many machine instructions.
Many sophisticated assemblers offer additional mechanisms to facilitate program development, control the
assembly process, and aid debugging. In particular, most modern assemblers include a macro facility and are
called macro assemblers.

Page 3 of 4

1.3 Hardware and software

1.3.7 High- and low-level languages and their translators


What happens in the CPU when an Interrupt is generated during a fetch execute cycle?
We have just said that 'An interrupt is a signal for the CPU to stop what it is doing and instead carry out
the interrupt task, once the task is complete, the CPU goes back to what it was doing'.
But what is meant by 'back to what it was doing'?
To appreciate this, you need to understand a little about what goes on inside a CPU. A CPU contains a number
of 'registers'. A register is a small section of on-chip memory having a specific purpose. Registers range from
8 bits wide on an 8 bit CPU to 64 bits and beyond.
Registers in the CPU hold all of the data currently being handled. These include
The current instruction being executed (Instruction Register),
The location in primary memory of the next instruction (Program Counter)
A number of general purpose registers holding current data
The registers are updated by each tick of the system clock so at any instant in time, they hold specific
values.
When an interrupt comes along, all the register values are copied to a special data structure or memory area
called the 'stack' which is in primary memory. And they stay in the stack whilst the CPU starts executing
the interrupt service routine (ISR). Once the routine is over, the registers are loaded back with their original
values from the stack and can continue with what they were doing before the interrupt came along.
This jumping of instructions from current CPU operations to the ISR and then back again is called 'context
switching'

Page 4 of 4

Você também pode gostar