Motorola M68000 Betriebsanweisung Seite 90

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 256
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 89
76 Assembly Language Programming for the 68000 Family
The LEA instruction takes the address of COUNT, not the value at
location COUNT, and places it in register AO. The LEA instruction always
has a longword size, since it specifies an address value.
You might be wondering, why not just use absolute addressing? The
answer to this is best shown by example, but there are a couple of reasons.
Unlike in absolute addressing, the address can be modified if it is in a
register. This helps with data structures like arrays. Another real power
of the address register indirect mode is that it avoids the necessity of
knowing the symbolic name for the location of a data value in order to
reference it. This will start to have a greater meaning when subroutines
are discussed in Chapter 8.
Address register indirect can be of great help in managing data in
arrays. You are no doubt somewhat familiar with the use of arrays from
your experience in a high-level language. An array is a type of data
structure created by grouping together many similar data elements of
the same type in successive locations in memory. For example, we can
create an array of word-sized data items with the DC.W directive.
ARRAY: DC.W 345,862,10000,-26,473
This example is an array composed of arbitrary values. Suppose we wanted
to print out these five valueshow could it be done using address register
indirect addressing? First, we observe that the label ARRAY specifies the
first address in the array. If we place this address in register AO, we should
be able to access the first data element using address register indirect
addresssing. How do we then get to the next value? We merely add the
proper constant to AO. In this case it will be a 2, since word data requires two
consecutive memory bytes. The following is a program that does just this:
NEXT:
LEA
CLR.L
MOVE.W
MOVE.W
JSR
JSR
ADDQ.L
DBRA
ARRAY,A0
DO
#4 ,D1
(A0),D0
OUTDEC
NEWLINE
«2,A0
D1,NEXT
GET ADDRESS OP ARRAY
CLEARS HIGH ORDER WORD
INIT FOR LOOP
GET ARRAY ELEMENT
OUTPUT
GO TO NEXT LINE
BUMP FOR NEXT ELEMENT
BACK FOR MORE
Wouldn’t it be nice if we didnt have to increment the value of A0
by 2 each time through the loop, if it could be done automatically? The
68000 has granted our wish. The next addressing mode we will discuss,
address register indirect with postincrement, does just that.
Seitenansicht 89
1 2 ... 85 86 87 88 89 90 91 92 93 94 95 ... 255 256

Kommentare zu diesen Handbüchern

Keine Kommentare