
CHAPTER 11
ADVANCED ARITHMETIC
In Chapters 4 and 5 you learned the ADD, SUB, ADDQ, and SUBQ
instructions. These instructions, along with the condition code register,
give you the capability to perform other arithmetic operations such as
multiplication and division. For example, you can perform multiplication
by repeated addition, and division by repeated subtraction. These are not
the best methods to use, but they are simple. By using the shift instructions
shown in Chapter 10, more efficient algorithms can be implemented.
Fortunately, the 68000 has a set of powerful arithmetic instructions that
include multiplication and division as well as some other rather interesting
instructions. In this chapter we will take a look at the complete set of
arithmetic instructions and introduce some new concepts such as decimal
arithmetic. Yes, I did say “decimal” arithmetic. Up to this point we have
been dealing strictly with binary arithmetic operations.
Multiple Precision Addition and Subtraction
Before discussing the multiplication and division instructions, I want to
introduce the concept of arithmetic precision. Basically, the precision of
a calculation is proportional to the number of bits used in the calculation.
The more bits used, the greater the precision. Even though we are
confined to integer arithmetic, we can use a larger number of bits to
represent larger numbers which, in turn, can represent scaled values. For
example, we can represent time intervals in thousandths of seconds rather
than seconds. This would require the ability to represent numbers 1,000
times larger for the equivalent times in seconds. However, the precision
would be greater, since times would be stored with accuracy down to a
thousandth of a second.
The 68000 performs additions and subtractions on bytes, words, or
longwords. Therefore, there are actually three built-in precisions avail
able. But what if 32 bits is not a great enough precision for our calcu
lations? Is there anything we can do? The answer is yes, but not with a
141
Komentáře k této Příručce