Sie sind auf Seite 1von 11

The binary number system

The bit, or binary digit, is the basic unit of data which can be interpreted by the digital
computer. It is easily adaptable to the binary number system because there are only two
possible conditions which can take on the values of 0 or I. The meaning of successive digits in
the binary system is based on the number 2 raised to successive powers. The first digit is 20,
the second is 21, the third is 22, and so forth.
The two numbers, 0 or 1, in successive bit positions indicate either the absence or
presence of the value. Table 2.4 shows how the binary number system can be used
to represent numbers in the more familiar decimal system.
The conversion from binary to decimal systems makes use of the following type of
computation. We will illustrate the conversion for the decimal number 5:

1 x 20 + 0 X 21 + 1 X 22 + 0 X 23 = lXl+0x2+1X4+0x8 = 5

A minimum of four digits are required in the


binary system to represent any single-digit
number in the decimal system, as indicated in
Table 2.4. By using more than four binary digits,
higher-valued decimal numbers or other high-level
data can be represented.
An alternative way to represent decimal numbers
larger than nine involves separate coding of each
digit, using four binary digits for each decimal
digit. This coding system is known as binary-coded
decimal (BCD). The binary-coded decimal system
is explained in Table 2.5 together with two other
common coding schemes.

TABLE 2.5 Common Binary Coding Schemes


Binary-Coded Decimal (BCD)
The binary-coded decimal system uses a total of 7 bits. The first 6 represent the data itself
(alphabetic, numeric, or special character). The last bit position is used as a parity check. The
first 4 bits are called numeric bits, and are assigned the values I, 2, 4, and 8. By various
combinations of these bits, the decimal numbers from zero to nine can be represented. The
fifth and sixth bits are called the zone bits. The zone bits are both zero when numeric
characters are represented.
Combinations of the zone and numeric bits can be used to code the alphabetic and special
characters.
EBCDIC
The maximum number of unique characters a computer code can represent is 2 raised to the
power equal to the number of bits. Thus BCD allows for 26 = 64 distinct characters. EBCDIC
(Extended Binary-Coded Decimal Interchange Code) uses an 8-bit code plus a parity bit 50
that it can define 256 distinct characters. These include upper- and lowercase a1phabetics,
the numerals, many special characters, and control characters for I/O devices.
ASCII
ASCII (American Standard Code for Information Interchange) was developed for
telecommunications to simplify machine-to-machine and system-to-system communications.
It is a 7-bit code, which provides 128 bit patterns for character representation.

COMPUTER PROGRAMMING LANGUAGES

The preceding section demonstrated how the binary number system could be used to
represent any decimal number, alphabetic letter, or other common symbol. Data
and instructions are communicated to the computer in the form of binary words. In
executing a program, the computer interprets the configuration of bits as an instruction
to perform electronic operations such as add, subtract, load into memory, and
so forth. The sequence of these binary-coded instructions define the set of calculations
and data manipulations by which the computer executes the program.
The binary-coded instructions that computers can understand are called
machine language. Unfortunately, binary-coded instructions and data are very difficult
for human programmers to read or write. Also, different machines use different
machine languages. To facilitate the task of computer progranuning,
higher-level languages are available which can be learned with relative ease by
human beings. In all there are three levels of computer progranuning languages:
1. Machine language
2. Assembly language
3. Procedure-oriented (high-level) languages

Machine and assembly languages


The language used by the computer is called machine language. It is written in binary, with
each instruction containing an operation code and an operand. The operand might be a
memory address, a device address, or data. In machine language programming, storage
locations are designated for the program and data, and these are used throughout the
program to refer to specific data or program steps. In addition, the programmer must be
familiar with the specific computer system since machine language instructions are different
for each computer. Programming in machine language is tedious, complicated, and time
consuming. To alleviate the difficulties in writing programs in binary ,symbolic languages
have been developed which substitute an English-like mnemonics for each binary instruction.
Mnemonics are easier to remember than binary, so they help speed up the programming
process.
A language consisting of mnemonic instructions is called an assembly language. Figures 2.5
and 2.6 illustrate the difference between machine language and assembly language.
Assembly languages are considered to be low-level languages. The programmer must be
very knowledgeable about the computer and equipment being programmed.
Low-level languages are the most efficient in terms of fast execution on
the computer, but there are obvious difficulties for the programmer in writing large
programs for various applications using different computers. We consider programming
with assembly language in Chapter 3 in our discussion of microcomputers and
microprocessors.

FIGURE 2.6

FIGURE 2.6. Portion of an assembly language program


Assembly language programs must be converted into machine
language before the computer can execute them.
The conversion is carried out by a program called an assembler.
The assembler takes the assembly language program, performs the
necessary conversions, and produces two new programs: the
machine language version and an assembly listing. The assembly
listing shows the mnemonic instructions and their associated machine
language equivalents, and any errors the original assembly language
program may have contained.

High-level language
Assembly languages are machine oriented.
High-level languages, by contrast, are procedure oriented. They are to a large extent
independent of the computer on which they are used. This means that a program written on
one computer can be run on a different computer without significant modifications to the
program.
High-level languages consist of English-like statements and traditional mathematical
symbols. Each high-level statement is equivalent to many instructions in machine
language. To illustrate, Figures 2.5 and 2.6 present two lists of instructions, written in
machine language and assembly language, respectively.
Both sets of programming instructions accomplish the same task, which is to transfer the
contents of one memory location into another memory location. This can be accomplished
in FORTRAN (a high-level language) with two lines of instruction as shown in Figure 2.7.

FIGURE 2.7 Portion of FORTRAN program.

The advantage of high-level languages is that it is not necessary for the programmer
to be familiar with machine language. The program is written as an English-like algorithm to
solve a problem. Like assembler languages, high-level languages must also be converted
into machine code. This is accomplished by a special program called a compiler. The
compiler takes high-Ievel program, and converts it into a lower-level code, such as the
machine language. If there are any statement errors in the program (e.g., misspelled
words), error messages are printed in a special program listing by the compiler.
There are many different high-level languages. Table 2.6 describes several of
the common high-level languages used for business and engineering' applications.
APT language, is a high-level language used to program automatic machine tools.

TABLE 2.6 Some Common High-Level Computer Programming Languages for Business and
Engineering Applications
FORTRAN
FORTRAN stands for FORmula TRANslation. It is one of the oldest and most popular of the
high-level languages. FORTRAN was developed in the mid-1950s for scientists, engineers,
and mathematicians, but it has also been used for some business processing applications.
FORTRAN consists principally of mathematical notation. Data items and variables are given
names, and these names are used as symbols in the program to be operated on by
mathematical and logical operators. Other instructions are also allowed in FORTRAN, for
example to form lists and tables, or to call various input/output functions, such a; printing
or accepting data from a file. FORTRAN is quite efficient for mathematical computations but
is not very efficient for applications such as file processing or document production.

COBOL
COBOL (COmmon Business-Oriented Language) was developed around 1959. It has
become a major computer language for business data processing applications. COBOL can
be used for numeric and alphabetic data processing and in data-file applications
COBOL is similar to FORTRAN in the sense that it uses English-like statements. Indeed,
COBOL statements are called sentences. A series of sentences is termed a paragraph.
COBOL's vocabulary tends to make it self-documenting. It is very easy to read a program and
understand what operations are taking place. However, the language presumes an
understanding of information processing principles. Therefore, it is not intended for the
inexperienced programmer. While COBOL is suitable for a file environment, it is not capable
of the complex mathematical calculations that can be accomplished with FORTRAN.
BASIC
BASIC (Beginners's AIl-Purpose Instruction Code) was developed in the 1960s at
Dartmouth
College to be an easy-to-learn programming language. Learning the "basics" of this
language requires only a few hours.
BASIC was developed as an interactive language, where the user appears to be interacting
directly with the computer rather than through punched cards or other off-line I/O format,
Each line of code is interpreted as it is typed, so that the programmer is informed of many
types of program errors immediately upon their entry. Programs are usually entered and
executed by means of CRT terminals in a time-sharing network. BASIC is used heavily in the
field of microcomputers, and is being used increasingly as an interactive teaching tool in
schools.

APL
APL (A Programming Language) was designed for interactive problem solving. A significant
feature is that it permits users to define complex algorithms efficiently. The primary data
structure in APL is in the form of arrays and an extensive set of array operators is
provided.
RPG
RPG (Report Program Generator) is a language designed for writing programs that
produce printed reports as output. It is widely used in business environments, where it
updates data flies, performs analysis of data, and generates documents and reports. .
RPG is relatively easy to learn and programs can often be written in a short time, making it
suitable for the needs of upper-level managers, who often desire to have immediate
access to information in a given format. It is most appropriate for simple, straightforward
problems which do not require complicated logic or use of data files. It is a common
language on minicomputers because of its relatively modest memory requirements.

PL/1
PL/1 is a general-purpose programming language designed to be a compromise between
FORTRAN and business languages, each of which has obvious strong and weak points. It
uses standard arithmetic operators, similar to FORTRAN. PL/1 is a flexible language which
meets the needs of a wide variety of programmers. Default conditions assumed by the
compiler when explicit alternative statements are omitted allow many functions to be
perfonned in fewer steps than in FORTRAN or other languages.
PASCAL
Pascal is a high-level language developed in the early 1970S and named for the famous
French mathematician Blaise Pascal. The objectives in developing the language were to
facilitate the teaching of computer programming as a systematic discipline of knowledge
and to accomplish programming implementations which are reliable and efficient on
modern computers.

Das könnte Ihnen auch gefallen