Lesson 1 - Computing Systems

advertisement
Computing Systems
The heart of any computing system is its central processing unit, or CPU. The CPU controls
the operation of the entire system, performs the arithmetic and logic operations, and stores
and retrieves instructions and data. The instructions and data are stored in a high-speed
memory unit, and the control unit fetches these instructions from memory, decodes them, and
directs the system to execute the operations indicated by the instructions. Those operations
that are arithmetical or logical in nature are carried out using special registers and circuits of
the arithmetic-logic unit (ALU) of the CPU.
The memory unit is called the internal or main or primary memory of the computer system.
It is used to store the instructions and data of the programs being executed. Most computing
systems also contain components that serve as external or auxiliary or secondary memory.
Common forms of this type of memory are magnetic disks and magnetic tapes. These
peripheral devices provide long-term storage for large collections of information.
Other peripherals are used to transmit instructions, data and computed results between the
user and the CPU. These are the input/output devices. Their function is to convert
information from an external form understandable to the user to a form that can be processed
by the computer system, and vice versa.
MEMORY ORGANIZATOION
The devices that comprise the memory unit of a computer are two state devices. If one of the
states is interpreted as 0 and the other as 1, then it is natural to use a binary scheme, using
only the two binary digits (bits) 0 and 1 to represent information in a computer. These twostate devices are organized into groups called bytes, each of which contains a fixed number
of these devices, usually eight and thus can store a fixed number of bits. Memory is
commonly measured in bytes, and a block of 210 = 1024 bytes is called 1K of memory. Thus,
a 512K memory usually refers to a memory that consists of 512 x 210
= 210 x 29 = 219 = 524,288 bytes.
A larger grouping of bits and bytes is into words. Word sizes vary with computers, but
common sizes are 16 bits = 2 bytes and 32 bits = 4 bytes. Each word or byte is identified by
an address and can be directly accessed using this address. This makes it possible to store
information in a specific memory location and then to retrieve it later.
NUMBER SYSTEMS
The number system that we are accustomed to using is a decimal or base-10 number system,
which uses the digits 0,1,2,3,4,5,6,7,8 and 9. The significance of these digits in a numeral
depends on the position that they occupy in that numeral. For example, in the numeral
485
the digit 4 is interpreted as
4 hundreds
and the digit 8 as
8 tens
and the digit 5 as
5 ones
Thus, the numeral 485 represents the number four-hundred eighty-five and can be written in
expanded form as
(4x100) + (8x10) + (5x1)
(4x102) + (8x101) + (5x100)
The digits that appear in the various positions of a decimal (base-10) numeral thus are
coefficients of powers of 10.
Similar positional number systems can be devised using numbers other than 10 as a
base. The binary number system uses 2 as the base and has only two digits, 0 and 1. For
example, the binary numeral
1012
can be written in expanded form (using decimal notation) as
(1x22) + (0x21) + (1x20)
that is, the binary numeral 101 has the decimal value
4+0+1=5
Two other nondecimal numeration systems are important in the study of computer systems:
octal and hexadecimal. The octal system is a base-8 system and uses the eight digits
0,1,2,3,4,5,6 and 7. In an octal numeral such as
17038
the digits are coefficients of powers of 8; this numeral is therefore an abbreviation for the
expanded form
(1x83) + (7x82) + (0x81) + (3x80)
and thus has the decimal value
512 + 448 + 0 + 3 = 963
A hexadecimal system uses a base of 16 and the digits 0,1,2,3,4,5,6,7,8,9,A(10), B (11),
C(12), D(13), E(14), and F(15). The hexadecimal numeral
5E416
has expanded form
(5x162) + (14x161) + (4x160)
which has the decimal value
1280 + 224 + 4 = 1508
DATA STORAGE
INTEGERS: When an integer value must be stored in the computer’s memory, the binary
representation of that value is typically stored in one memory word. Consider that the integer
value 58 is to be stored in a computer whose word size is 16 bits. A memory word is
selected, and a sequence of 16 bits formed from the binary representation 111010 of 58 is
stored there
Memory
0000000000111010
Negative integers must be stored in a binary form in which the sign of the integer is part of
the representation. There are several ways that this can be done, but one of the most common
is the two’s complement representation. In this scheme, positive integers are represented in
binary form as described, with the leftmost bit set to 0 to indicate that the value is positive.
The representation of a negative integer –n is obtained by first finding the binary
representation of n, complementing it – that is, changing each 0 to 1 and each 1 to 0 – and
then adding 1 to the result. For example, the two’s complement representation of –58 using
16 bits is obtained as follows:
1. Represent 58 by a 16-bit binary numeral:
i. 0000000000111010
2. Complement this bit string:
i. 1111111111000101
3. Add 1:
i. 1111111111000110
Note that the leftmost bit in this two’s complement representation of a negative integer is
always 1, indicating that the number is negative.
The fixed word size limits the range of the integers that can be stored. For example, the
largest positive integer that can be stored in a 16-bit word is:
01111111111111112 = 215 – 1 = 32,767
and the smallest negative integer is
10000000000000002 = -215 = -32,768
REAL NUMBERS:
Numbers that contain decimal points are called real numbers or floating-point numbers. In
the decimal representation of such numbers, each digit is the coefficient of some power of 10.
Digits to the left of the decimal point are coefficients of nonnegative powers of 10, and those
to the right are coefficients of negative powers of 10. For example, the decimal numeral
56.317 can be written in expanded form as
(5x101) + (6x100) + (3x10-1) + (1x10-2) + (7x10-3)
or equivalently, as
(5 x10) + (6x1) + (3x1/10) + (1 x 1/100) + (7 x 1/1000)
Digits in the binary representation of a real number are coefficients of powers of two. Those
to the left of the binary point are coefficients of nonnegative powers of two, and those to the
right are coefficients of negative powers of two. For example, the expanded form of 110.101
is
(1x22) + (1x21) + (0x20) + (1x2-1) + (0x2-2) + (1x2-3)
and thus has the decimal value
4 + 2 + 0 + ½ + 0 + 1/8 = 6.625
There is some variation in the schemes used for storing real numbers in computer memory,
but one common method is illustrated by the following. The binary representation
110.1012
of the real number 6.625 can also be written as
0.1101012 x 23
Typically, one part of a memory word (or words) is used to store a fixed number of bits of
the mantissa or fractional part, 0.1101012 and the other part to store the exponent, 3 = 112.
For example, if the leftmost eleven bits in a 16-bit word are used for the mantissa and the
remaining five bits for the exponent, 6.625 can be stored as
0110101000000011
Mantissa
exponent
Boolean and Character Values
Computers store and process not only numeric data but also Boolean or logical data (false or
true), character data, and other types of nonnumeric information. Consider the logical values
true and false. Since there are only two logical values, the logical value false can be
represented as the integer 0, and the logical value true can be represented as the integer 1.
Character values are represented in a similar fashion. Each character is represented by a
unique numeric code. Several standard coding schemes have been developed, such as
ASCII (American Standard Code for Information Interchange) and EBCDIC (Extended
Binary Coded Decimal Interchange Code). These binary codes are used to represent
characters internally. A byte (eight bits) can store the binary representation of one
character, so that a 16-bit word (two bytes) can store two characters. For example, the
character string HI can be stored in a single 16-bit word with the code for H in the left byte
and the code for I in the right byte. Using ASCII code, these values are stored as follows:
0
1
0
0
1
0
0
0
0
1
0
0
1
H
0
0
1
I
Instruction Processing
Program instructions for processing data must also be stored in memory. As an example,
suppose that three values, 8 = 10002 , 24 = 110002 , and 58 = 1110102, have been stored in
memory locations with addresses 4, 5, and 6 and that we want to multiply the first two
values, add the third, and store the result in memory word 7. (Remember, all locations in
memory have a unique address so that the CPU can access it for storage and retrieval!)
Address
Memory
0
1
2
3
4
value = 8
0000000000001000
5
value = 24
0000000000011000
6
value = 58
0000000000111010
7
result goes here
To perform this computation, the following instructions must be executed:
1. Fetch the contents of memory word 4 and load it into the accumulator register of the
ALU.
2. Fetch the contents of memory word 5 and compute the product of this value and the
value in the accumulator register.
3. Fetch the contents of memory word 6 and add this value to the value in the
accumulator register.
4. Store the contents of the accumulator register in memory word 7.
In order to store these instructions in computer memory, they must be represented in binary
form. The addresses of the data value present no problem, because they can easily be
converted to binary addresses:
Address 4 = 1002
Address 5 = 1012
Address 6 = 1102
Address 7 = 1112
The operations load, multiply, add, store and other basic machine instructions are represented
by numeric codes, called opcodes; for example,
LOAD
= 16 = 000100002
STORE
= 17 = 000100012
ADD
= 35 = 001000112
MULTIPLY = 36 = 001001002
Using part of a word to store the opcode and another part for the address of the operand, we
can represent our sequence of instructions in machine language as
1. 0001000000000100 LOAD the value in memory word 4 into the accumulator
2. 0010010000000101 MULTIPLY the accumulator by memory word 5
3. 0010001100000110 ADD memory word 6 to the accumulator
4. 0001000100000111 STORE the value in the accumulator into memory word 7
Opcode
Operand
Assignmet
1. Convert each of the following octal numerals to base 10:
a. 1001 b. 110010 c. 1000000 d. 1010.10101
2. Convert each of the following octal numerals to base 10:
a. 123 b. 2705 c. 7.2 d. 123.45
3. Convert each of the following hexadecimal numerals to base 10:
a. 12 b. 1AB c. 8.C d. AB.CD
4. Conversion from octal representation to binary representation is easy: We simply replace
each octal digit with its three-bit binary equivalent. For example, to convert 6178 to binary,
replace 6 with 110, 1 with 001, and 7 with 111, to obtain 1100011112. Convert the octal
numerals in (a) and (b) of Exercise 2 to binary numerals.
5. One method for finding the base-b representation of a whole number given in base-10
notation is to divide the number repeatedly by b until a quotient of zero results. The
successive remainders are the digits from right to left of the base-b representation. For
example, the binary representation of 26 is 110102, as the following computation shows:
Convert each of the following base-10 numerals to I) binary ii) octal, and iii) hexadecimal
a) 27 b) 99 c) 314 d) 5280
Download