Motorola Axiom CMD11E1 Uživatelská příručka Strana 20

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 101
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 19
20 CHAPTER 2. INTRODUCTION TO LOOPING
SWI
Verify that CALL C100 and CALL C200 produces the same output. Explain
why this is so, and how and why the loop terminates.
2.4.2 One, two! One, two! And through and through ...
Marching through memory
Often loops are combined with marching through memory and operating on con-
secutive memory location. In this case, the X (and/or Y) register is initialized
to a starting memory address. Inside the loop, memory is accessed using IND,X
addressing mode. This operates on memory whose address is computed using the
value in X register. At the bottom of the loop, X is incremented, so that next
time around the loop, the operation is performed on the next memory location
3
.
The following program shows prints using OUTA the values stored in 9 consecu-
tive locations starting from location $D000. Note we are using FCB which is the
assembly language equivalent of memory modify.
ORG $C300
LDAB #$09
LDX #$D000 *Don’t forget the #
VORPAL TSTB
BEQ SWORD
LDAA 0,X
JSR OUTA
INX
DECB
BRA VORPAL
SWORD SWI
; FOLLOWING SAME AS MM D000 FOLLOWED BY: 55 6F 66 4D 2D 44 62 72 6E
3
In some cases the memory has to be accessed in the reverse order. In this case, X starts at
the end, and at the bottom of the loop, X is decremented.
Zobrazit stránku 19
1 2 ... 15 16 17 18 19 20 21 22 23 24 25 ... 100 101

Komentáře k této Příručce

Žádné komentáře