Hardware Reference
In-Depth Information
a data item (memory or register), and there are two possible destinations for a data
item (memory or register), four different kinds of copying are possible. Some
computers have four instructions for the four cases. Others have one instruction
for all four cases. Still others use LOAD to go from memory to a register, STORE to
go from a register to memory, MOVE to go from one register to another register, and
no instruction for a memory-to-memory copy.
Data movement instructions must indicate the amount of data to be moved. In-
structions exist for some ISAs to move variable quantities of data ranging from 1
bit to the entire memory. On fixed-word-length machines, the amount to be moved
is often exactly one word. Any more or less must be performed by a software rou-
tine using shifting and merging. Some ISAs provide additional capability both for
copying less than a word (usually in increments of bytes) and for copying multiple
words. Copying multiple words is tricky, particularly if the maximum number of
words is large, because such an operation can take a long time, and may have to be
interrupted in the middle. Some variable-word-length machines have instructions
specifying only the source and destination addresses but not the amount. The
move continues until an end-of-data field mark is found in the data.
5.5.2 Dyadic Operations
Dyadic operations combine two operands to produce a result. All ISAs have
instructions to perform addition and subtraction on integers. Multiplication and di-
vision of integers are nearly standard as well. It is presumably unnecessary to ex-
plain why computers are equipped with arithmetic instructions.
Another group of dyadic operations includes the Boolean instructions. Al-
though 16 Boolean functions of two variables exist, few, if any, machines have in-
structions for all 16. Usually, AND , OR , and NOT are present; sometimes EXCLU-
SIVE OR , NOR , and NAND are there as well.
An important use of AND is for extracting bits from words. Consider, for ex-
ample, a 32-bit-word-length machine in which four 8-bit characters are stored per
word. Suppose that it is necessary to separate the second character from the other
three in order to print it; that is, it is necessary to create a word which contains that
character in the rightmost 8 bits, referred to as right justified , with zeros in the
leftmost 24 bits.
To extract the character, the word containing the character is AND ed with a
constant, called a mask . The result of this operation is that the unwanted bits are
all changed into zeros—that is, masked out—as shown below.
10110111 10111100 11011011 10001011 A
00000000 11111111 00000000 00000000 B (mask)
00000000 10111100 00000000 00000000 A AND B
The result would then be shifted 16 bits to the right to isolate the character to be
extracted at the right end of the word.
 
 
Search WWH ::




Custom Search