Motorola M68000 Betriebsanweisung Seite 96

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 256
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 95
82 Assembly Language Programming for the 68000 Family
ADDA.L #RECSIZ,A0 GET NEXT RECORD
BRA LOOP BACK FOR MORE
FINI:
Notice that the age is not added directly to the sum in DO. This is because
the age is a byte value, and adding a byte to DO would only allow a sum
as large as a byte. To get around this, we clear the high-order bytes of
Dl and then move the age byte into the low-order byte of Dl. Then we
can perform a full longword addition.
We can also take advantage of this addressing mode to rewrite the
string compare previously presented.
LEA SI,AO
AO -> SI
LEA S2/A1
Al -> S2
LOOP:
CMPM.B
(A0)+, <A1) +
COMPARE BYTES
BNE
DIFF
DIFFERENT
TST.B
-1 (AO)
FINISHED?
BEQ
SAME
YES, THEY MATCH
BRA
LOOP
LOOP FOR NEXT CHAR.
DIFF:
HERE WHEN STRINGS DIFFERENT
SAME:
.
HERE WHEN STRINGS MATCH
Address Register Indirect With Index
This mode is very similar to address register indirect with displace
ment. In fact, it is address register indirect with displacement plus the
addition of a value contained in any one of the address or data registers.
The general form is d8(An,Rn.W) or d8(An,Rn.L). d8 is an 8-bit displace
ment. Its range is128 to +127. This is not as great a range as with
address register indirect with displacement mode. Rn is any one of the
address or data registers. Either the sign-extended word or the complete
longword is taken from the index register, depending on the suffix the
programmer specifies. The effective address is formed by adding the dis
placement, the contents of the address register, and the contents of the
index register. This can be expressed as <ea> = (An)+(Ri)+d, where Ri
is the appropriate value from Rn.
This addressing mode is especially useful for two-dimensional arrays.
For a simple two-dimensional array of bytes, words, or longwords, the
address of the appropriate row can be placed in the address register and
the index of the column in the index register. In this case the displacement
would be set to zero. The effective operand would then be the location
Seitenansicht 95
1 2 ... 91 92 93 94 95 96 97 98 99 100 101 ... 255 256

Kommentare zu diesen Handbüchern

Keine Kommentare