2.1 Arithmetic and logical foundations of computers

2.1.1 Presentation of data in a computer

To assess the amount of information and streamline the process of its processing, structural units of information are used.

One bit is taken as a unit of information.

The bit determines the amount of information by which one of two alternative states is allocated. In one bit, the digits 0 and 1 can represent one binary digit of a number or one logical variable that takes the values ​​“false” or “true”, respectively.

A sequence of bits that has a specific meaning is called a field.

An 8-bit field is called a byte.

A byte, as a rule, is the minimum (indivisible) unit of information that a computer operates with. All other units of information are its derivatives (Fig. 2.1).

Rice. 2.1. Structural units of information

The main structural unit of information processed by a computer is the machine word.

In modern computers, the length of a machine word is usually two bytes. As a rule, one machine word can represent either one number or one command. To ensure the required accuracy of calculations and save memory, most computers can also operate with double words.

A sequence of fields, bytes or words that have the same meaning form an array.

A group of arrays can be combined into a segment. The amount of information in large arrays is estimated using derived units that are multiples of the number of bytes to the power of two (1KB = 1024 bytes = 2 10 bytes; 1 MB = 1,048,576 bytes = 2 20 bytes).

A computer operates with two types of information: control information and numerical data.

To represent numerical data in a computer, natural and normal forms of writing numbers are used.

In computing, it is customary to separate an integer part from a fractional part by a point. Since in this case the position of the point between the integer and fractional parts is clearly defined, this representation of numbers is called a fixed-point representation (Fig. 2.2).

Rice. 2.2. Fixed-point representation of numbers

The disadvantage of representing fixed-point numbers is their small range. Therefore, as a rule, only integer numbers are written in this form. In this case, there is no need to allocate a field for the fractional part of the number.

The maximum absolute value of an integer that can be represented in natural form will be the number determined by the formula (2 m – 1) (Fig. 2.3).

The normal form of writing a number is N = m × q p, where m is the mantissa of the number (m<1); p - порядок; q - основание системы счисления.

Order indicates the location in a number of the point separating the integer part of the number from the fractional part.

Rice. 2.3. Integer representation

This form of representing numbers is called floating point form. In this case, the machine word is divided into two main fields. In one field the mantissa of the number is written, in the second the order of the number is indicated, taking into account the order sign (characteristic of the number). One digit is allocated to represent the sign of the number. The distribution of bits in a four-byte word for the floating point case is shown in Figure 2.4.

The range of representation of floating point numbers is much larger than the range of representation of fixed point numbers. However, computer performance when processing floating-point numbers is much lower than when processing fixed-point numbers. This is because when working with floating point, each operation requires time to determine the location of the point.

Rice. 2.4. Floating point representation

Modern computers use both forms of number representation.

2.1.1.1 Representation of commands in a computer

The machine operating program, which determines the process of information processing in a computer, consists of a sequence of commands.

A computer command is understood as information that ensures the generation of control signals for the machine to perform a certain action.

The command field consists of two parts: operational and address. The operating part specifies the operation code (OPC), which specifies the action (arithmetic or logical) that the machine must perform. The address part of the command contains the addresses of the operands (values) involved in the operation. Address “A” refers to the number (digital code) of a machine word (or other computer memory field), where the information necessary to execute the command is written. The number of addresses specified in a command may vary. According to the number of addresses, the following command formats are determined: unicast, two-address, three-address and four-address (Fig. 2.5).

Rice. 2.5. Computer command formats

A three-address instruction that performs an addition operation, for example, must contain an addition opcode and three addresses. The actions performed by such a command are determined approximately by the following sequence:

1) take the number stored at the first address;

2) take the number stored at the second address and add it to the first number;

3) write the result of the addition to the third address.

In the case of a two-address command, there is no third address, and the result can be written either to the second address (with the loss of information that was written there) or left in the adder where the addition operation was performed. Then, to free the adder, an additional command is required to rewrite the number at the required address. When adding two numbers stored at addresses A1 and A2 and writing the result, for example, to A1 using a two-address instruction, four instructions are required:

1) call to the adder the number stored at address A1;

2) calling the number stored at address A2 and adding it to the first number;

3) erase the number at address A1;

4) recording the result at address A1.

Thus, the smaller the addressability of computer commands, the greater the number of commands required to compile the same machine program.

By increasing the addressability of a computer, it is necessary to increase the length of the machine word in order to allocate the necessary fields for the address part of the commands. As the amount of computer memory increases, the length of the field required for one address increases. At the same time, not all commands make full use of address fields. For example, the command to write a number to a given address requires only one address field.

2.1.2 Number systems

The method of representing numbers using numerical signs (digits) is called a number system. The rules for writing and operating numbers in number systems used in digital computing determine the arithmetic foundations of digital computers.

Number system components:

1. The base of a number system is the number of different digits (symbols) used to represent a number.

2. Number system alphabet - symbols and numbers used to write all digits of a number.

3. Rules for writing and reading numbers.

There are two main types of number systems: non-positional and positional.

Non-positional number systems.

Non-positional number systems are characterized by the fact that the value of a number, expressed by a set of digits, is determined only by the configuration of digital symbols and does not depend on their location. A classic example of a non-positional system is the Roman number system. For example: ХIX; XXIII.

Positional number systems.

The most widespread are positional number systems, in which the value of any digit is determined not only by the configuration of its symbol, but also by the location (position) it occupies in the number.

Among positional systems, a distinction is made between homogeneous and mixed (heterogeneous) number systems.

In homogeneous systems, the number of valid digits for all positions (digits) of a number is the same. A homogeneous positional system is the generally accepted decimal number system (q = 10), which uses ten digits from 0 to 9 to write numbers.

An example of a mixed number system is the time counting system, where 60 gradations are used in the digits of seconds and minutes, and 24 gradations in the digits of hours, etc.

Any number A, written in a homogeneous positional system, can be represented as a sum of a power series:

(2.1.)

where q is the base of the number system; a i - numbers of the number system with base q; i - number (weight) of the position (digit) of the number.

An infinite number of different number systems can be implemented. Digital computers mainly use homogeneous positional systems. In addition to the decimal number system, systems with base q, which are powers of 2, are widely used in computers, namely: binary, octal, hexadecimal number systems.

When different number systems are used together, after writing the number, the base of the system can be indicated, for example: 347.42 10; 1101 2 ; 235 8, etc.


All modern computers have a fairly developed command system, including tens and hundreds of machine operations. However, the execution of any operation is based on the use of simple microoperations such as addition and shift. This allows you to have a single arithmetic-logical device to perform any operations related to information processing. The rules for adding binary digits of two numbers A and B are presented in table. 2.2.

Table 2.2 Rules for adding binary digits

Here are shown the rules for adding binary digits a i, b i, digits of the same name, taking into account possible transfers from the previous digit p i -1.

Similar tables could be built for any other arithmetic or logical operation (subtraction, multiplication, etc.), but it is the data from this table that forms the basis for performing any computer operation. A special sign digit is allocated for the sign of numbers. The “+” sign is coded as a binary zero, and the “-” sign as a one. Actions on direct codes of binary numbers when performing operations create great difficulties associated with the need to take into account the values ​​of the sign bits:

First, you should treat significant digits and sign digits separately;

Secondly, the value of the sign bit affects the algorithm for performing the operation (addition can be replaced by subtraction and vice versa). In all computers without exception, all operations are performed on numbers represented by special machine codes. Their use allows you to treat the signed digits of numbers in the same way as the significant digits, and also replace the subtraction operation with the addition operation.

There are direct code (P), reverse code (OK) and complementary code (DC) of binary numbers.

Machine codes

Direct code of a binary number is formed from the absolute value of this number and the sign code (zero or one) before its most significant numeric digit.

Example 2.5.

The dotted vertical line here marks the conventional boundary separating the sign digit from the significant digit.

Return code binary number is formed according to the following rule. The reverse code of positive numbers is the same as their forward code. The reverse code of a negative number contains one in the sign digit of the number, and the significant digits of the number are replaced with inverse ones, i.e. zeros are replaced by ones, and ones are replaced by zeros.

Example 2.6.

The reverse number code got its name because the digit codes of a negative number are replaced with inverse ones. Let us indicate the most important properties of the reverse code of numbers:

The addition of a positive number C with its negative value in reverse code gives the so-called machine unit MEok = 1¦ 11...111, consisting of units in the sign and significant digits of the number;

The zero in the reverse code has a double meaning. It can be either a positive number - 0¦ 00...0, or a negative number - 1 ¦ 11...11. The value of negative zero coincides with MEok. The dual representation of zero is the reason that in modern computers all numbers are represented not by their inverse, but by their complementary code.

Additional code positive numbers coincides with their direct code. The complement code of a negative number is the result of summing the reverse code of the number with the least significant unit (2 0 - for integers, 2 - k - for fractional ones).

Example 2.7.

Let us indicate the main properties of the additional code:

Adding the complementary codes of a positive number C with its negative value gives the so-called complementary code machine unit:

MEdk=MEok+2 0 =10¦ 00...00,

those. the number 10 (two) in the sign digits of the number;

The complementary code received this name because the representation of negative numbers is the addition of the direct code of numbers to the machine unit MEdk.

Modified inverse and additional codes binary numbers differ from reciprocal and complementary codes, respectively, by doubling the values ​​of the sign bits. The “+” sign in these codes is encoded with two zero sign digits, and the “-” sign with two unit digits.

Example 2.8.

The purpose of introducing modified codes is to fix and detect cases of obtaining an incorrect result when the result value exceeds the maximum possible result in the allocated bit grid of the machine. In this case, the carry from the significant bit may distort the value of the least significant sign bit. The value of the sign bits “01” indicates a positive overflow of the bit grid, and “10” indicates a negative overflow. Currently, in almost all computer models, the role of doubled bits for fixing overflow of the bit grid is played by transfers going to and from the sign bit.

arithmetic --logical device

arithmetic--logical device (ALU) - the central part of the processor that performs arithmetic and logical operations.

The ALU implements an important part of the data processing process. It consists of performing a set of simple operations. ALU operations fall into three main categories: arithmetic, logical, and bit operations. An arithmetic operation is a data processing procedure whose arguments and results are numbers (addition, subtraction, multiplication, division,...). A logical operation is a procedure that constructs a complex statement (operations AND, OR, NOT,...). Operations on bits usually involve shifts.

The ALU consists of registers, an adder with corresponding logic circuits, and a control element for the process being executed. The device operates in accordance with the names (codes) of operations communicated to it, which, when sending data, must be performed on variables placed in registers.

An arithmetic-logical device can be functionally divided into two parts: a) a microprogram device (control device) that specifies a sequence of microinstructions (commands); b) an operating unit (ALU), in which a given sequence of microinstructions (commands) is implemented.

The law of information processing is set by the microprogram, which is written as a sequence of microcommands A1,A2, ..., An-1,An. In this case, two types of microinstructions are distinguished: external, that is, microinstructions that enter the ALU from external sources and cause certain transformations of information in it (in Fig. 1 microinstructions A1, A2,..., An), and internal, which are generated in the ALU and affect the firmware device, changing the natural order of microinstructions. For example, an ALU can generate signs depending on the result of calculations: an overflow sign, a negative number sign, a sign that all bits of a number are equal to 0, etc. In Fig. 1, these microcommands are designated p1, p2,..., pm.

The results of calculations from the ALU are transmitted via write code buses y1, y2, ..., ys, to RAM. Functions of the registers included in the ALU: Pr1 - adder (or adders) - the main register of the ALU, in which the result of calculations is generated; Рг2, РгЗ - registers of terms, factors, dividend or divisor (depending on the operation being performed); Pr4 - address register (or address registers), designed for storing (sometimes generating) the addresses of the operands and the result; Rgb - k index registers, the contents of which are used to form addresses; Pr7 - i auxiliary registers, which, at the request of the programmer, can be accumulators, index registers, or used to store intermediate results.

Some operational registers are program-accessible, that is, they can be addressed in a command to perform operations on their contents. These include: adder, index registers, some auxiliary registers.

The remaining registers are software-inaccessible, since they cannot be addressed in the program. Operating devices can be classified according to the type of information processed, the method of processing information and the logical structure.

The ALU can operate with four types of information objects: Boolean (1 bit), digital (4 bits), byte (8 bits) and address (16 bits). The ALU performs 51 different operations to transfer or transform this data. Since there are 11 addressing modes (7 for data and 4 for addresses), by combining operation/addressing mode the base number of 111 instructions is expanded to 255 out of 256 possible with a single-byte opcode.

  • Administrative and legal basis for the activities of SSES centers
  • Acmeological foundations of personal self-improvement
  • The analysis of the FSP is based mainly on relative indicators, since absolute balance indicators in conditions of inflation are difficult to bring into a comparable form.
  • ABSTRACT to the electronic textbook “Fundamentals of System Analysis”
  • Lecture 1. Introduction Arithmetic and logical foundations of computers. Arithmetic fundamentals of computers. Logical foundations of computers. Basic principles of the algebra of logic. Logical elements. Laws and identities of the algebra of logic.

    Electronic computers perform arithmetic and logical operations using two classes of variables: numbers and logical variables. Numbers carry information about the quantitative characteristics of the system; arithmetic operations are performed on them. Boolean variables determine the state of the system or whether it belongs to a certain class of states (channel switching, control of computer operation according to a program, etc.). Logical variables can take only two values: true And lie. In digital information processing devices, these two variable values ​​are associated with two voltage levels: high - ( logical "1")andlow- (logical0"). However, these values ​​do not convey the meaning of quantity. Elements that perform simple operations on such binary signals are called logical. Based on logical elements, devices are developed that perform both arithmetic and logical operations.

    Currently, logic elements (LE) are implemented using various technologies that determine the numerical values ​​of the main parameters of the LE and, as a consequence, the quality indicators of digital information processing devices developed on their basis. Therefore, in this manual, due attention is paid to the circuit design and parameters of LE of various technologies.

    Arithmetic basics of computers

    Currently, in everyday life, to encode numerical information, a decimal number system with base 10 is used, which uses 10 designation elements: numbers 0, 1, 2, ... 8, 9. The first (minor) digit indicates the number of units, the second - tens, in the third - hundreds, etc.; in other words, in each subsequent digit the weight of the digit coefficient increases by 10 times.

    Digital information processing devices use a binary number system with base 2, which uses two designation elements: 0 and 1. The weights of the bits from left to right from the least significant to the most significant ones increase by 2 times, that is, they have the following sequence: 8421. In general, this the sequence looks like:

    …2 5 2 4 2 3 2 2 2 1 2 0 ,2 -1 2 -2 2 -3 …

    and is used to convert a binary number to a decimal number. For example, the binary number 101011 is equivalent to the decimal number 43:

    2 5 ·1+2 4 ·0+2 3 ·1+2 2 ·0+2 1 ·1+2 0 ·1=43

    In digital devices, special terms are used to denote units of information of various sizes: bit, byte, kilobyte, megabyte, etc.

    Bit or binary digit determines the value of one character in a binary number. For example, the binary number 101 has three bits or three digits. The rightmost digit, with the least weight, is called younger, and the one on the far left, with the greatest weight, is senior.

    Byte defines 8-bit unit of information, 1 byte = 23 bits, for example, 10110011 or 01010111, etc., 1 kbyte = 2 10 bytes, 1 MB = 2 10 kbytes = 2 20 bytes.

    To represent multi-digit numbers in the binary number system, a large number of binary digits are required. Recording is easier if you use the hexadecimal number system.

    The basis hexadecimal system number is the number 16 = 2 4, which uses 16 notation elements: numbers from 0 to 9 and the letters A, B, C, D, E, F. To convert a binary number to hexadecimal, it is enough to divide the binary number into four-bit groups: the integer part from right to left, fractional - from left to right of the decimal point. Outer groups may be incomplete.

    Each binary group is represented by a corresponding hexadecimal character (Table 1). For example, the binary number 0101110000111001 in hexadecimal is expressed as 5C39.

    The decimal number system is most convenient for the user. Therefore, many digital devices, working with binary numbers, receive and issue decimal numbers to the user. In this case, binary decimal code is used.

    BCD code is formed by replacing each decimal digit of a number with a four-bit binary representation of this digit in binary code (See Table 1). For example, the number 15 is represented as 00010101 BCD (BinaryCodedDecimal). In this case, each byte contains two decimal digits. Note that the BCD code in this conversion is not a binary number equivalent to a decimal number.

    Electronic computers perform arithmetic and logical operations using two classes of variables: numbers and logical variables.

      Numbers carry information about the quantitative characteristics of the system; Arithmetic operations are performed on them.

    Boolean variables determine the state of the system or whether it belongs to a certain class of states (channel switching, control of computer operation according to a program, etc.).

    Boolean variables can only take two values: true And lie. In digital information processing devices, these two variable values ​​are associated with two voltage levels: high -- (logical "1") and low -- (logical 0"). However, these values ​​do not convey the meaning of quantity.

    Elements that perform simple operations on such binary signals are called logical. Based on logical elements, devices are developed that perform both arithmetic and logical operations.

    Currently, logic elements (LE) are implemented using various technologies that determine the numerical values ​​of the main parameters of the LE and, as a consequence, the quality indicators of digital information processing devices developed on their basis. Therefore, in this manual, due attention is paid to the circuit design and parameters of LE of various technologies.

    1 Arithmetic and logical foundations of computers

    1.1 Arithmetic basics of computers

    Currently, in everyday life, to encode numerical information, a decimal number system with a base of 10 is used, which uses 10 notation elements: numbers 0,1,2,...8,9. The first (minor) digit indicates the number of units, the second – tens, the third – hundreds, etc.; in other words, in each subsequent digit the weight of the digit coefficient increases by 10 times.

    Digital information processing devices use a binary number system with base 2, which uses two designation elements: 0 and 1. The weights of the bits from left to right from the least significant to the most significant ones increase by 2 times, that is, they have the following sequence: 8421. In general, this the sequence looks like:

    and is used to convert a binary number to a decimal number. For example, the binary number 101011 is equivalent to the decimal number 43:

    In digital devices, special terms are used to denote units of information of various sizes: bit, byte, kilobyte, megabyte, etc.

    Bit or binary digit determines the value of one character in a binary number. For example, the binary number 101 has three bits or three digits. The rightmost digit, with the least weight, is called younger, and the one on the far left, with the greatest weight, is senior.

    Byte defines 8-bit unit of information, 1 byte = 2 3 bits, for example, 10110011 or 01010111, etc.,
    ,

    To represent multi-digit numbers in the binary number system, a large number of binary digits are required. Recording is easier if you use the hexadecimal number system.

    The basis hexadecimal system number is the number 16= , which uses 16 designation elements: numbers from 0 to 9 and the letters A, B, C, D, E, F. To convert a binary number to hexadecimal, it is enough to divide the binary number into four bit groups: the integer part from right to left, the fractional part from left to right of the decimal point. Outer groups may be incomplete.

    Each binary group is represented by a corresponding hexadecimal character (Table 1). For example, the binary number 0101110000111001 in hexadecimal is expressed as 5C39.

    The decimal number system is most convenient for the user. Therefore, many digital devices, working with binary numbers, receive and issue decimal numbers to the user. In this case, binary-decimal code is used.

    Binary - decimal code is formed by replacing each decimal digit of a number with a four-bit binary representation of this digit in binary code (See Table 1). For example, the number 15 is represented as 00010101 BCD (Binary Coded Decimal). In this case, each byte contains two decimal digits. Note that the BCD code in this conversion is not a binary number equivalent to a decimal number.