Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Музычук Сб.тех.текстов для чтен. для студ. 2 ку...doc
Скачиваний:
9
Добавлен:
11.11.2019
Размер:
92.16 Кб
Скачать

Information, machine words, instructions, addresses and reasonable operations

1. Information is a set of marks or signs that have meaning. These consist of letters or numbers, digits or characters, typewriter signs, other kinds of signs, and so on. A computer reacts differently to different digits or characters, and reacts to them as units that have meaning. For example, information for an analog computer has to be in the form of distances, or rotations, or voltages, or other physical variables. And for a digital computer information has to be in the form of digits or numbers.

2. Any information may be represented by the binary system including two digits: one (1) and zero (0). Each 1 and. 0 is a separate binary digit called a bit. A bit is the smallest part of information. Bits are typically grouped in units that are called bytes. A byte is the basic unit of information used in modern computers and consists of eight bits.

3. The bytes are handled usually in standard groups called machine words or just words. There are two basic types of information or words that can be put into a memory cell or location: words that are numerical quantities and words that are computer instructions. Regularly, an instruction to the machine is expressed as a word; and so the same set of characters may have meaning sometimes as a number, sometimes as an instruction. A speed of 96,000 characters per second is the same as a speed of 8,000 words per second. Most human beings could not take even 12-digit number per second.

4. Physically the set of bits is a set of arrangements of some physical equipment. One of the ways of storing information in a computer is storing by using a set of small magnetically polarized spots (пятна) on a magnetic surface.

5. The computer is told what operations to perform by means of instructions. An instruction is a command to the computer. It consists of a verb (an operational code) and a noun (an operand). For example, if the computer is instructed "Add 365 the number of times (раз) stated in the register R", and if the register R stores the code for number 3, then the computer will perform that operation three times. An instruction word looks like a number, and there is no way to tell from the word itself whether it is a quantity or an instruction. The computer must be told exactly (точно) which address contains an instruction and which contains a quantity.

6. An address is the name of particular memory location or cell. Each memory location (word or byte) has its own unique address or number just like a post office box.» For example, if the computer contains 100 memory cells, their respective addresses might be the numbers from 1 to 100 (or 0 through 99). And instead of saying "A word is in a memory cell", the computer personnel say, "The contents (содержимое) of an address is a word."

7. Reasonable operations are mathematical and logical. - Mathematical operations include arithmetic and algebraic operations. Arithmetic operations are addition, subtraction, multiplication, division, taking a square root, etc.; and algebraic operations are called raising to a power as well as differentiating and integrating. . 8. Logical operations include comparing, selecting, sorting, matching, etc. These are operations which may be performed either on numbers, or on expressions consisted of letters such as ordinary words. A very important logical operation performed by a computer is determining, i.e., which of two operations is to be performed next.

TEXT 4

Read the following text and answer the questions to it.

MEETING A FRIEND

A: Hallo, В.! Where are you going?

B: Hallo, A.! Haven't seen you for ages! I am going to the Institute.

A: Oh! You are a student now! What Institute have you entered?

B: I've entered the Polytechnic Institute.

A: Good for you! And what department do you study at?

B: I study at the Electrical Engineering Department. My speciality is Electronic Computers (Automated Manage­ment Systems, Applied Mathematics ).

A: You liked mathematics at school, didn't you? They say one should know that subject well to study your speciality.

B: You're right. Mathematics was my favourite subject at school.

A: And you know already what a computer is, don't you?

B: Yes, I do. A computer is a machine which performs a sequence of reasonable operations on information. I also know what simple and complex computers are. A: It's very interesting! Tell me, please. B: With pleasure, listen to: a simple computer is an ordinary business adding machine, and a complex computer is a modern electronic digital computer which performs more than 100 mln. operations a second.

A: Can you say, please, what kinds of operations a modern electronic computer performs?

B: Yes, I can. It performs addition, subtraction, multiplication, and division. These operations are called arithmetical operations. But modern computers perform logical operations too.

A: Well, what are they?

B: Logical operations which I know are comparing and selecting.

A: In what capacity will you work after graduating from

the Institute?

B: I shall work as a system-engineer (an engineer-mathematician). But I am sorry. I must hurry to the Institute, I'm afraid to be late for the lectures. So long!

A: Wish you luck in your studying. So long!

TEXT 5

Read the following text and answer the questions to it.

PROGRAMMING LANGUAGES

Programming in the computer's own machine code requires that the instructions and data are given to it in binary. Writing down and keying in a series of is and Os is time-consuming and prone to error. An alternative way of expressing the instructions is to use mnemonic codes. For example, the command to load a number from memory cells could be written as MOV AX,5 instead of the binary equivalent. Also the memory cells could be given symbolic names instead of referring to them by their actual numeric (binary) addresses.

This type of programming language is used when it is necessary to have close control over the functions of the computer. Languages which use such mnemonic codes are known as assembly languages. Each assembly language instruction usually corresponds to an equivalent machine code instruction. The translation of the assembly language program into machine code is carried out by a machine code program called an assembler.

High-level languages have been devised which allow several machine code instructions to be expressed in one statement. BASIC is such a programming language, as shown in the example below:

LET С = A + В

is a BASIC statement which causes the two numbers, held in memory cells A and B, to be added together and the sum stored in memory cell С This is the same problem which previously required several machine code or assembly language instructions.

However, neither assembly language nor3 BASIC programs can be understood directly by the computer. BASIC programs need to be translated into machine code using a compiler or interpreter. The basic difference between these two is the stage at which the translation from BASIC into machine code is performed.

TEXT 6

Read the following text and answer the questions to it.

Syntactic elements

Object Pascal uses the ASCII character set, including the letters A through Z and a through z, the digits 0 through 9, and other standard characters. It is not case-sensitive. The space character (ASCII 32) and the control characters (ASCII 0 through 31—including ASCII 13, the return or end-of-line character) are called blanks.

Fundamental syntactic elements, called tokens, combine to form expressions, declarations, and statements. A statement describes an algorithmic action that can be executed within a program. An expression is a syntactic unit that occurs within a statement and denotes a value. A declaration defines an identifier (such as the name of a function or variable) that can be used in expressions and statements, and, where appropriate, allocates memory for the identifier.

Fundamental syntactic elements

On the simplest level, a program is a sequence of tokens delimited by separators. A token is the smallest meaningful unit of text in a program. A separator is either a blank or a comment. Strictly speaking, it is not always necessary to place a separator between two tokens; for example, the code fragment

Size:=20;Price:=10;

is perfectly legal. Convention and readability, however, dictate that we write this as

Size := 20;

Price := 10;

Tokens are categorized as special symbols, identifiers, reserved words, directives, numerals, labels, and character strings. A separator can be part of a token only if the token is a character string. Adjacent identifiers, reserved words, numerals, and labels must have one or more separators between them.

TEXT 7

Read the following text and answer the questions to it.

Data types and variables

A type is essentially a name for a kind of data. When you declare a variable you must specify its type, which determines the set of values the variable can hold and the operations that can be performed on it. Every expression returns data of a particular type, as does every function. Most functions and procedures require parameters of specific types.

Object Pascal is a "strongly typed" language, which means that it distinguishes a variety of data types and does not always allow you to substitute one type for another. This is usually beneficial because it lets the compiler treat data intelligently and validate your code more thoroughly, preventing hard-to-diagnose runtime errors. When you need greater flexibility, however, there are mechanisms to circumvent strong typing. These «include typecasting, pointers, variants, variant parts in records, and absolute addressing of variables.

About types

There are several ways to categorize Object Pascal data types:

Some types are predefined (or built-in); the compiler recognizes these automatically, without the need for a declaration. Almost all of the types documented in this language reference are predefined. Other types are created by declaration; these include user-defined types and the types defined in Delphi's libraries.

Types can be classified as either fundamental or generic. The range and format of a fundamental type is the same in all implementations of Object Pascal, regardless of the underlying, CPU and operating system. The range and format of a generic type is platform-specific and could vary across different implementations. Most predefined types are fundamental, but a handful of integer, character, string, and pointer types are generic. It's a good idea to use generic types when possible, since they provide optimal performance and portability. However, changes in storage format from one implementation of a generic type to the next could cause compatibility problems—for example, if you are streaming data to a file.

Types can be classified as simple, string, structured, pointer, procedural, or variant. In addition, type identifiers themselves can be regarded as belonging to a special "type" because they can be passed as parameters to certain functions (such as High, Low, and SizeOf).

TEXT 8

Read the following text and answer the questions to it.

Procedures and functions

Procedures and functions—referred to collectively as routines—are self-contained statement blocks that can be called from different locations in a program. A function is a routine that returns a value when it executes. A procedure is a routine that does not return a value.

Function calls, because they return a value, can be used as expressions in assignments and operations. For example,

I := SomeFunction(X);

calls SomeFunction and assigns the result to I. Function calls cannot appear on the left side of an assignment statement. Both function and procedure calls can be used as complete statements. For example,

DoSomething;

calls the DoSomething routine; if DoSomething is a function, its return value is discarded. Procedures and functions can call themselves recursively.

Declaring procedures and functions

When you declare a procedure or function, you specify its name, the number and type of parameters it takes, and, in the case of a function, the type of its return value; this part of the declaration is sometimes called the prototype, heading, or header. Then you write a block of code that executes whenever the procedure or function is called; this part is sometimes called the routine's body or block. The standard procedure Exit can occur within the body of any procedure or function. Exit halts execution of the routine where it occurs and immediately passes program control back to the point from which the routine was called.

Parameters

Most procedure and function headers include a parameter list. For example, in the header

function Power(X: Real; Y: Integer): Real;

the parameter list is (X: Real; Y: Integer).

A parameter list is a sequence of parameter declarations separated by semicolons and enclosed in parentheses. Each declaration is a comma-delimited series of parameter names, followed in most cases by a colon and a type identifier, and in some cases by the - symbol and a default value. Parameter names must be valid identifiers. Any declaration can be preceded by one of the reserved words var, const, and out (see Parameter semantics). Examples:

(X, Y: Real)

(var S: string; X: Integer)

(HWnd: Integer; Text, Caption: PChar; Flags: Integer)

(const P; I: Integer)

The parameter list specifies the number, order, and type of parameters that must be passed to the routine when it is called. If a routine does not take any parameters, omit the identifier list and the parentheses in its declaration:

procedure UpdateRecords;

begin

end;

Within the procedure or function body, the parameter names (X and Y in the first example above) can be used as local variables. Do not redeclare the parameter names in the local declarations section of the procedure or function body.

TEXT 9

Read the following text and answer the questions to it.

What is an object?

An object, or class, is a data type that encapsulates data and operations on data in a single unit. Before object-oriented programming, data and operations (functions) were treated as separate elements.

You can begin to understand objects if you understand Object Pascal records. Records (analogous to structures in C) are made of up fields that contain data, where each field has its own type. Records make it easy to refer to a collection of varied data elements.

Objects are also collections of data elements. But objects—unlike records—contain procedures and functions that operate" on their data. These procedures and functions are called methods.

An object's data elements are accessed through properties. The properties of Delphi objects have values that you can change at design time without writing code. If you want a property value to change at runtime, you need to write only a small amount of code. The combination of data and functionality in a single unit is called encapsulation. In addition to encapsulation, object-oriented programming is characterized by inheritance and polymorphism. Inheritance means that objects derive functionality from other objects (called ancestors); objects can modify their inherited behavior. Polymorphism means that different objects derived from the same ancestor support the same method and property interfaces, which often can be called interchangeably.