Motorola M68000 Betriebsanweisung Seite 148

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 256
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 147
154 Assembly Language Programming for the 68000 Family
The purpose of the arithmetic shift is to preserve the sign bit. You will
recall that the sign bit is the high-order bit when using two’s complement
representation. One use of the shift instructions is to multiply or divide
a number by a power of two. Without the arithmetic forms of the shift
instructions, incorrect values would result. The corresponding mnemonics
for the left shifts are ASL and LSL. Even though it would at first appear
that these are the same instructions, they actually differ slightly. While
it is true that the result in the destination of an ASL and an LSL will
be identical, the two instructions differ in how they affect the condition
code register. The arithmetic versions of the instructions will conditionally
set the overflow bit depending upon whether the most significant bit is
changed at any time during the shift operation. The remaining bits of the
CCR are conditionally set for both versions of the instructions.
There are three forms for the shift instructions:
<shift>[.<size>] DxfDy
<shift>[.<size>] #<data>,Dy
<shift>f.W] <ea>
<shift> = ASL, ASR, LSL, LSR
<size> = B, W, or L
<data> = 1-8
The first form specifies a shift count in register Dx and the destination in
register Dy. The second form allows an immediate shift count between
1 and 8. For counts larger than 8, two or more sequential shifts with
immediate operands can be used. Naturally, if the shift count is to be
variable, the first form is most useful. The third form shifts the contents
of a memory location by one bit only. Furthermore, the data width is
restricted to one word. If you need to manipulate a byte or longword
from memory, you will have to move it into a register first, shift it, and
then move it back to memory. Additionally, anything but a shift of a few
bits would also require moving the data to a register.
If the DO register contains 543216, the shift
LSL.W #1,D0
results in A86418 in DO. Likewise,
LSR.W #1,D0
results in 2A1916. And
MOVEQ.L #10,Dl
LSL.W Dl,DO
Seitenansicht 147
1 2 ... 143 144 145 146 147 148 149 150 151 152 153 ... 255 256

Kommentare zu diesen Handbüchern

Keine Kommentare