Zilog Z08470 Uživatelský manuál Strana 41

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 326
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 40
UM008007-0715 Programming Task Examples
Z80 CPU
User Manual
29
SBC A, (HL) ;SUBTRACT (HL) FROM ACC
DAA ;ADJUST RESULT TO DECIMAL CODED VALUE
LD (HL), A ;STORE RESULT
INC HL ;ADVANCE MEMORY POINTERS
INC DE
DJNZ SUBDEC–$ ;DECREMENT B AND GO TO SUBDEC
;IF B
;NOT ZERO, OTHERWISE FALL
;THROUGH
Seventeen bytes are required for this operation.
Programming Task Examples
As indicated in Table 2, this example program sorts an array of numbers to ascending
order, using a standard exchange sorting algorithm. These numbers range from 0 to 255.
Table 2. Bubble Listing
Location
Object
Code Statement Source Statement
1 ; standard exchange (bubble) sort routine
2;
3 ; at entry: hl contains address of data
c contains number of elements to be sorted
(1 < c < 256)
4
5
6;
7 ; at exit data sorted in ascending order
8;
9 ; use of
registers
10 ;
11 ; register contents
12 ;
13 ; a temporary storage for calculations
14 ; b counter for data array
15 ; c length of data array
16 ; d first element in comparison
17 ; e second element in comparison
18 ; h flag to indicate exchange
Zobrazit stránku 40
1 2 ... 36 37 38 39 40 41 42 43 44 45 46 ... 325 326

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

Žádné komentáře