VALUE
6HYHQWHHQ E\WHV DUH UHTXLUHG IRU WKLV RSHUDWLRQ
([DPSOHV RI 3URJUDPPLQJ 7DVNV
$V GHSLFWHG LQ 7DEOH WKLV H[DPSOH SURJUDP VRUWV DQ DUUD\ RI QXPEHUV WR
DVFHQGLQJ RUGHU XVLQJ D VWDQGDUG H[FKDQJH VRUWLQJ DOJRULWKP 7KHVH
QXPEHUV UDQJH IURP WR
7DEOH %XEEOH /LVWLQJ
/RF
2EM &RGH 6WPW 6RXUFH 6WDWHPHQW
80
DAA
LD
(HL), A
INC
HL
INC
DE
DJNZ SUBDEC - $;DECREMENT B AND GO TO "SUBDEC"
1
;
standard exchange (bubble) sort routine
2
;
3
;
at entry:
4
5
6
;
7
;
at exit
8
;
9
;
use of registers
10
;
11
;
register
12
;
13
;
a
14
;
b
+DUGZDUH DQG 6RIWZDUH ,PSOHPHQWDWLRQ ([DPSOHV
;ADJUST RESULT TO DECIMAL CODED
;STORE RESULT
;ADVANCE MEMORY POINTERS
;IF B
;NOT ZERO, OTHERWISE FALL
;THROUGH
hl contains address of data
c contains number of elements to be sorted
(1 < c < 256)
data sorted in ascending order
contents
temporary storage for calculations
counter for data array
< %27
7UGT U /CPWCN
Need help?
Do you have a question about the Z80 and is the answer not in the manual?