Motorola M68000 Betriebsanweisung Seite 95

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 256
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 94
Addressing Modes 81
not a label used on a memory location. Although some assemblers may
allow you to assemble the following:
MOVE.L ARRAY(AO),DO
ARRAY: DS.L 100
you will most likely run into trouble. The label ARRAY can ultimately be
located anywhere in memory and therefore should be represented by a
32-bit value. The displacement must be a signed 16-bit value.
Address register indirect with displacement is extremely useful for
data structures that contain records. A record can contain almost anything.
All records must be the same size if a simple array access technique is
to be used. Let’s say that we want a simple data structure containing
the names and ages of various people. We will restrict a name to be 10
characters, plus a byte for the terminating null character. An age can be
represented by a single byte. This gives us a total record size of 12 bytes.
We can declare an array of names as follows:
NAMLST: DC.B
'TOM
',0
DC.B
43
DC.B
'ERIN
'rO
DC.B 3
DC.B
'KRISTIN
',0
DC.B 5
DC.B 0
Here a null name has been used to mark the end of the list. We can
access the name and age of a particular record by defining constants to
represent the displacements into the record for each component.
NAME: EQU 0
AGE: EQU 11
RECSIZ: EQU 12
Here is a program that will add up the ages of the names in this array:
CLR.L DO DO HAS SUM
LEA NAMLSTfAO AO -> ARRAY
LOOP: TST.B NAME(AO) FINISHED?
BEQ FINI YES
CLR.L Dl NO, CLEAR HIGH ORDER BYTES
MOVE.B AGE(A0),D1 GET AGE
ADD.L DlfDO ADD IN AGE
Seitenansicht 94
1 2 ... 90 91 92 93 94 95 96 97 98 99 100 ... 255 256

Kommentare zu diesen Handbüchern

Keine Kommentare