
Getting 5tarted 45
actually perform meaningful tasks. The general form of the add and
subtract instructions are:
[<label>] ADD[.<size>] <source>,<destination> [<coinntent>]
[<label>] SUB[.<size>] <source>,<destination> [<cowment>]
As with the MOVE instruction, <size> may be B, W, or L.
The ADD instruction forms the sum of the source and destination
operands, which may be words, bytes, or longwords, and replaces the
destination operand with this sum. Both operands may be signed or
unsigned numbers. SUB works like ADD except that the source operand
is subtracted from the destination operand. Once again, the result replaces
the destination operand. The source operand may be any register or
memory location, or a constant. The destination operand may be a data
register or memory location. For the ADD and SUB instructions, MOVE
source and destination operands cannot both be memory locations. At
least one operand must be a data register, and the destination operand
cannot be an address register.
Here, and in later chapters, we will express instructions in a more
proper manner by indicating the allowable type for the source and
destination operands. The ADD and SUB instructions have the following
forms:
ADDI.<size>] <ea>,Dn
ADD[.<size>] Dn,<ea>
SUBI.<size>] <ea>,Dn
SUB[.<size>] Dn,<ea>
<ea> is a general way of expressing an effective address. An effective
address generally includes the data registers and the contents of mem
ory locations. Each instruction has more complicated limitations on the
effective addresses of instructions. You should consult Appendix C for
these details. Dn indicates that any of the eight data registers DO through
D7 can be used.
The following are all valid ADD and SUB instructions:
ADD.L D2,D3
SUB.W #5,D0
ADD.B D6,COUNT COUNT IS A BYTE LOCATION
As mentioned in the discussion of the. MOVE instruction, the size, in
bytes, of the source and destination operands must be the same. When
a constant is used, it must be capable of being represented by the num
ber of bytes of the destination operand. If a two-byte (word) constant is
specified, it cannot be used with a MOVE.B, ADD.B, or SUB.B instruc
Kommentare zu diesen Handbüchern