Machine instructions operate on data. The most important general categories of
data are
• Addresses
• Numbers
• Characters
• Logical data
We shall see, in discussing addressing modes in Chapter 13, that addresses
are, in fact, a form of data. In many cases, some calculation must be performed on
the operand reference in an instruction to determine the main or virtual memory
address. In this context, addresses can be considered to be unsigned integers.
Other common data types are numbers, characters, and logical data, and each
of these is briefly examined in this section. Beyond that, some machines define specialized data types or data structures. For example, there may be machine operations that operate directly on a list or a string of characters.
Numbers
All machine languages include numeric data types. Even in nonnumeric data processing, there is a need for numbers to act as counters, field widths, and so forth.
An important distinction between numbers used in ordinary mathematics and numbers stored in a computer is that the latter are limited. This is true in two senses.
First, there is a limit to the magnitude of numbers representable on a machine and
second, in the case of floating-point numbers, a limit to their precision. Thus, the
programmer is faced with understanding the consequences of rounding, overflow,
and underflow.
Three types of numerical data are common in computers:
• Binary integer or binary fixed point
• Binary floating point
• Decimal
We examined the first two in some detail in Chapter 10. It remains to say a few
words about decimal numbers.
Although all internal computer operations are binary in nature, the human
users of the system deal with decimal numbers. Thus, there is a necessity to convert
from decimal to binary on input and from binary to decimal on output. For applications in which there is a great deal of I/O and comparatively little, comparatively
simple computation, it is preferable to store and operate on the numbers in decimal
form. The most common representation for this purpose is packed decimal.
With packed decimal, each decimal digit is represented by a 4-bit code, in the
obvious way, with two digits stored per byte. Thus, 0 = 000, 1 = 0001, c, 8 = 1000,
and 9 = 1001. Note that this is a rather inefficient code because only 10 of 16 possible 4-bit values are used. To form numbers, 4-bit codes are strung together, usually in multiples of 8 bits. Thus, the code for 246 is 0000 0010 0100 0110. This code
is clearly less compact than a straight binary representation, but it avoids the conversion overhead. Negative numbers can be represented by including a 4-bit sign
digit at either the left or right end of a string of packed decimal digits. Standard sign
values are 1100 for positive (+) and 1101 for negative (-).
Many machines provide arithmetic instructions for performing operations
directly on packed decimal numbers. The algorithms are quite similar to those
described in Section 9.3 but must take into account the decimal carry operation.
Characters
A common form of data is text or character strings. While textual data are most
convenient for human beings, they cannot, in character form, be easily stored or
transmitted by data processing and communications systems. Such systems are
designed for binary data. Thus, a number of codes have been devised by which characters are represented by a sequence of bits. Perhaps the earliest common example
of this is the Morse code. Today, the most commonly used character code in the
International Reference Alphabet (IRA), referred to in the United States as the
American Standard Code for Information Interchange (ASCII; see Appendix F).
Each character in this code is represented by a unique 7-bit pattern; thus, 128 different characters can be represented. This is a larger number than is necessary to
represent printable characters, and some of the patterns represent control characters. Some of these control characters have to do with controlling the printing
of characters on a page. Others are concerned with communications procedures.
IRA-encoded characters are almost always stored and transmitted using 8 bits per
character. The eighth bit may be set to 0 or used as a parity bit for error detection.
In the latter case, the bit is set such that the total number of binary 1s in each octet
is always odd (odd parity) or always even (even parity).
Note in Table F.1 (Appendix F) that for the IRA bit pattern 011XXXX, the
digits 0 through 9 are represented by their binary equivalents, 0000 through 1001, in
the rightmost 4 bits. This is the same code as packed decimal. This facilitates conversion between 7-bit IRA and 4-bit packed decimal representation.
Another code used to encode characters is the Extended Binary Coded
Decimal Interchange Code (EBCDIC). EBCDIC is used on IBM mainframes. It
is an 8-bit code. As with IRA, EBCDIC is compatible with packed decimal. In
the case of EBCDIC, the codes 11110000 through 11111001 represent the digits
0 through 9.
Logical Data
Normally, each word or other addressable unit (byte, halfword, and so on) is treated
as a single unit of data. It is sometimes useful, however, to consider an n-bit unit as
consisting of n 1-bit items of data, each item having the value 0 or 1. When data are
viewed this way, they are considered to be logical data.
There are two advantages to the bit-oriented view. First, we may sometimes wish
to store an array of Boolean or binary data items, in which each item can take on only
the values 1 (true) and 0 (false). With logical data, memory can be used most efficiently
for this storage. Second, there are occasions when we wish to manipulate the bits of a
data item. For example, if floating-point operations are implemented in software, we
need to be able to shift significant bits in some operations. Another example: To convert from IRA to packed decimal, we need to extract the rightmost 4 bits of each byte.
Note that, in the preceding examples, the same data are treated sometimes as
logical and other times as numerical or text. The “type” of a unit of data is determined by the operation being performed on it. While this is not normally the case in
high-level languages, it is almost always the case with machine language
1 Komentar
Sloty Casino Resort, Las Vegas | MapYRO
BalasFind 거제 출장샵 parking costs, opening hours 경상북도 출장마사지 and a parking 정읍 출장안마 map of Sloty Casino Resort, 대전광역 출장샵 Las Vegas. 오산 출장마사지 Address: 5555 Las Vegas Blvd South, Las Vegas, NV 89109