Motorola Axiom CMD11E1 Podręcznik Użytkownika Strona 18

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 101
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 17
18 CHAPTER 2. INTRODUCTION TO LOOPING
Exercise:
1. Using the HC11 reference book, identify 5 instructions that do not affect
the C flag, but affects some other flag.
2. Using the HC11 reference book, can you identify any instruction that does
not affect the V flag, but affects some other flag?
3. Using the HC11 reference book, identify 5 instructions that always clears
the C flag.
4. Using the HC11 reference book, identify an instruction that always sets the
C flag.
2.4 Looping
2.4.1 Counting loops
This is by far the simplest and most used loop structure. In a counting loop, we
perform a specific operation a given number of times. A counter controls how
many times the loop is executed. The counter could be stored in memory or kept
in a register. If it is kept in a register, it is your responsibility to make sure that
the register is not inadvertently changed either by your code or by some third
party function that you call. If you decide to use a register, your best bet is to
use either the B register or Y register. The structure of the loop is as follows:
1: Initialize the counter to the number of times the loop is to be performed
2: Perform any other initializations
3: Test if the counter is zero. If so quit the loop
4: Perform the desired task
5: Perform any re-initializations
6: Decrement the counter
7: Go back to 3
8: Come here when you quit the loop
Note that there are two places where the code jumps to. One to (3) and the other
to (8). When writing the code in assembly language, we would need two labels.
In the code that follows, I have used the labels FOO and BAR.
Przeglądanie stron 17
1 2 ... 13 14 15 16 17 18 19 20 21 22 23 ... 100 101

Komentarze do niniejszej Instrukcji

Brak uwag