Motorola M68000 User's Guide Page 57

  • Download
  • Add to my manuals
  • Print
  • Page
    / 256
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 56
Getting Started 43
of subtle errors that are hard to debug. If you must perform a move
between two data elements of different lengths, there are techniques that
can be used. We will discuss them as we move along. The following is an
example of a MOVE instruction used to move the contents of the byte
at memory location ALPHA to the byte at memory location BETA.
HOVE.B ALPHA,BETA
A constant value can be moved into a register or into a memory
location. A constant as a source operand is specified by preceding it
with the special character #. This is known as an immediate operand.
The following instruction will move the constant 100 into register DO:
MOVE.L #100,D0
Although it makes no sense, it is possible to write a MOVE instruction
indicating that the contents of a register or a memory location are to be
stored into a constant. This is not permitted, but if you forget the order
of the source and destination operands it may come out this way.
MOVE.L DO ,#100
is not legal. Fortunately, your assembler will detect this error and let you
know.
If the byte or word form of an instruction is used with a data register
as the destination, only the lower byte or word of the register is changed.
All the high-order bits remain unchanged. This is important to remember,
since we may move a byte into a register and then subsequently use
the register as a longword. All those high-order bytes will most likely
be meaningless garbage and cause an erroneous value to be used. For
example, if register DO contains the value $12345678,
MOVE *B #$00,DO
would result in DO containing $12345600, and not $00000000. Further
along in the book I will discuss ways to handle this problem.
Quite often a programmer desires to swap the contents of two regis
ters. The 68000 provides a special instruction to perform this operation.
Before looking at this instruction, let’s see how to program a swap opera
tion using only the MOVE instruction. To swap the contents of registers
DO and Dl, a programmer may at first be tempted to write:
MOVE.L DO,D1
MOVE.L D1,D0
Page view 56
1 2 ... 52 53 54 55 56 57 58 59 60 61 62 ... 255 256

Comments to this Manuals

No comments