0% found this document useful (0 votes)
292 views

Machine Languages: Basic Computer Concepts Computer Languages

Machine language is a computer's internal language represented in binary. It is tedious to write and not portable. Assembly language replaces machine codes with symbols but still depends on the computer architecture. High-level languages like FORTRAN and Java are easier for humans and portable between computers since compilers translate them to machine code. Developing a computer application involves analyzing requirements, designing an algorithm, writing source code, compiling, testing for syntax and logic errors, and debugging until the program works correctly.

Uploaded by

Rajesh Paudyal
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
292 views

Machine Languages: Basic Computer Concepts Computer Languages

Machine language is a computer's internal language represented in binary. It is tedious to write and not portable. Assembly language replaces machine codes with symbols but still depends on the computer architecture. High-level languages like FORTRAN and Java are easier for humans and portable between computers since compilers translate them to machine code. Developing a computer application involves analyzing requirements, designing an algorithm, writing source code, compiling, testing for syntax and logic errors, and debugging until the program works correctly.

Uploaded by

Rajesh Paudyal
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

BASIC COMPUTER CONCEPTS COMPUTER LANGUAGES

Machine Languages
As noted below all computers have an internal machine language which they execute
directly. This language is coded in binary and is very tedious to write. Most instructions
will consist of an operation code part and an address part. The operation code indicates
which operation is to be carried out. The address part of the instruction indicates which
memory location is to be used as the operand of the instruction. For example in a
hypothetical computer successive bytes of a program might contain:
Code Address Meaning
00010101 10000001 load c(129) into accumulator
00010111 10001100 add c(140) to accumulator
00010110 10000111 store c(accumulator) in location 135
where c() means `the contents of' and the accumulator is a general purpose register.
Obviously it is very tedious and error prone to write code such as shown above. In
addition it depends upon the data and the program always occupying the same memory
locations. This is not necessarily so in modern computers since a program will be loaded
into whatever space is not occupied by other programs already existing in memory.
Another great disadvantage of machine language is that a program can only run on the
computer model for which it was written. Machine language programs are not portable.

Assembly Languages
Assembly languages replace machine language instructions on a one-to-one basis. The
operation code is replaced by an easily remembered alphabetic name, e.g. ADD and the
addresses are replaced by symbolic names. Thus the small section of hypothetical
machine language above may be replaced by an equivalent assembly language program
as follows:
Operation code address
LOAD A
ADD B
STORE C
A program called an Assembler takes the assembly language program as input data and
outputs the corresponding machine language program which can be executed. The
assembler replaces the alphabetic operation by the equivalent machine language code.
The assembler also assigns a memory address to each variable name used. These
addresses will be relative to some start address which is set when the program is loaded
into memory. Thus the program can run from any position in memory. However an
assembler language program is still machine-specific and must be re-written to run on a
different type of computer.

High-level Languages
Assembly language programming requires an intimate knowledge of the internal structure
of the computer and the final program is not portable over different computer
architectures. High level languages were designed to avoid these faults and to be much

PREPARED BY SPPANDAY Page 1 of 4


BASIC COMPUTER CONCEPTS COMPUTER LANGUAGES

closer to natural language. One of the first of these languages was Fortran II (1958). In
Fortran II the program above would be condensed to
C=A+B
which is obviously much more readable, quicker to write and less error-prone. As with
assembly languages the computer does not understand these high-level languages
directly. High level language programs are processed by a program, known as a
Compiler, which translates the high level language program into an equivalent machine
language program. Thus if a compiler was available for each machine architecture then a
program could be run on any computer without change.
There are several internationally standardised languages which are popular. They include:
Language Application Area
COBOL Business Applications
FORTRAN Engineering & Scientific Calculations
C General purpose language
Prolog Artificial Intelligence
Lisp Artificial Intelligence
C++ Object oriented version of C
Java Object oriented language widely used on Web
Most popular high-level languages have been standardised by some international body.
Thus if programs are written to conform strictly to the standard then they should execute
correctly on any architecture for which there is a standard-conforming compiler.

The Java Programming Language


Most of the high-level languages listed above are so-called Imperative Languages. That is
the program specifies exactly in order the sequence of operations the computer should
follow to solve the problem. Java developed by Sun Microsystems and since
internationally standardised, is an Object-oriented Language.
In object-oriented programming data and the operations that operate upon that data are
looked upon as a single entity, an object. Thus a clock records the current time as data
and one can carry out operations on it such as setting the time to affect that data.
Java can be used to write small programs called applets which are designed to run on
Web pages. It can also be used to write programs which independently of the Web and
other programs; these are known as applications.
Java is highly portable. This is because when Java is compiled it is not translated into the
machine language for any particular machine architecture but into Java Bytecode. Java
bytecode is designed as the machine language for a hypothetical computer, the Java
Virtual Machine. Manufacturers then write a Java Interpreter for their computer which
will read Java bytecode and interpret the code in terms of their own machine instruction
set. In this way a Java program is portable to any architecture which has a Java
interpreter.

Implementing a computer application

PREPARED BY SPPANDAY Page 2 of 4


BASIC COMPUTER CONCEPTS COMPUTER LANGUAGES

Before a program for a computer application can be produced various steps have to be
carried out. The major steps in this process are detailed below. These steps are
independent of which computer or programming language is used and requires the
existence of certain facilities upon the computer. The steps are:
 Study the requirement specification for the application. It is important that the
requirement specification is complete and consistent. For example a requirement
specification that says “write a program to solve equations” is obviously
incomplete and you would have to ask for more information on “what type of
equations?”, “how many equations?”, “to what accuracy?’ etc.
 Analyse the problem and design the structure of a program to solve the problem.
Within the structure there may be various operations to be carried out which
require the design of an algorithm.
 Translate the design produced at the previous step into a suitable high-level
language. This written form of the program is often called the source program or
source code. At this stage the program should be read to check that it is reasonable
and a desk-check can be carried out to verify its correctness on a simple set of test
data. Once satisfied that the program is reasonable it is entered into the computer
by using an Editor.
 Compile the program into machine-language. The machine language program
produced is called the object code.
 At this stage the compiler may find Syntax errors in the program. A syntax error is
a mistake in the grammar of a language, for example Java requires that each
statement should be terminated by a semi-colon. If you miss this semi-colon out
then the compiler will signal a syntax error. Before proceeding any syntax errors
must be corrected and compilation repeated until the compiler produces an
executable program free from syntax errors.
 The object code produced by the compiler will then be linked with various
function libraries that are provided by the system. This takes place in a program
called a linker and the linked object code is then loaded into memory by a
program called a loader.
 The compiled, linked and loaded program is then run with test data. This may
show up the existence of Logical errors in the program. Logical errors are errors
that are caused by errors in the method of solution, thus while the incorrect
statement is syntactically correct it is asking the computer to do something which
is incorrect in the context of the application. It may be something as simple as
subtracting two numbers instead of adding them.
 A particular form of logical error that may occur is a run-time error. A run-time
error will cause the program to halt during execution because it cannot carry out
an instruction. Typical situations which lead to run-time errors are attempting to
divide by a quantity which has the value zero or attempting to access data from a
non-existent file. The program must now be re-checked and when the error is
found it is corrected using the Editor as in (3) and steps (4) and (5) are repeated
until the results are satisfactory.
The program can now be put into general use though unless the testing is very
comprehensive it is possible that at some future date more logical errors may become

PREPARED BY SPPANDAY Page 3 of 4


BASIC COMPUTER CONCEPTS COMPUTER LANGUAGES

apparent. It is at this stage that good documentation produced while designing the
program and writing the program will be most valuable, especially if there has been a
considerable time lapse since the program was written.

Summary
 All computers have a machine language which is used to control them. This
machine language is unique to each range of computer. It is represented internally
in a binary form. Each instruction in machine language consists of a binary
operation code and an address part in which addresses are also coded in binary.
 Machine language is tedious to write and error-prone.
 Assembly language has a one-to-one correspondence with machine language. The
operation code is replaced by an easily understood alphabetic code and the binary
addresses are replaced by symbolic names.
 Before an assembly language can be executed it must be transformed by an
Assembler program into machine language.
 Assembly language is easier to write than machine language and is less error-
prone. It also takes the burden of memory allocation off the programmer.
However it is unique to each machine range and hence is not portable.
 High-level languages are written in a form more related to normal human
language and are thus easier and less error-prone to write. They are non machine-
specific and thus are highly portable.
 High-level languages must be transformed by a compiler into machine language
before they can be executed. Compilers exist for all the popular languages on all
computer ranges so that programs can be transferred from one computer range to
another for the cost of re-compiling it.
 Java is an object-oriented language which is compiled into Java bytecode which is
the machine language of the Java Virtual Machine. This Java bytecode is then
interpreted by the Java Interpreter for the actual computer on which the program
is to run. If every computer range has a Java Interpreter then Java programs will
be portable to any computer architecture.
To implement a computer application a precise list of the requirements of the application
must be drawn up. A design of a program structure to satisfy the requirements is then
produced. This structural design is expanded into modules which implement specific
operations. Algorithms are designed to implement these operations. The Source code of
the program is now produced and compiled, syntax errors corrected and the program
tested with comprehensive test data until free of logical errors. Both program and user
documentation must be produced. The program can now be put to productive use.

PREPARED BY SPPANDAY Page 4 of 4

You might also like