ZiLOG Z80 User Manual page 56

Hide thumbs Also See for Z80:
Table of Contents

Advertisement

< %27
7UGT U /CPWCN

7DEOH  %XEEOH /LVWLQJ &RQWLQXHG
/RF
2EM &RGH 6WPW 6RXUFH 6WDWHPHQW
0000
222600
0003
cb84
0005
41
0006
05
0007
dd2a2600
000b
dd7e00
000e
57
goof
dd5e01
0012
93
0013
3008
0015
dd7300
0018
dd7201
001b
cbc4
0010
dd23
001f
10ea
0021
cb44
0023
20de
0025
c9
80
15
;
c
16
;
d
17
;
e
18
;
h
19
;
l
20
;
ix
21
;
iy
22
;
23
sort: ld
24
loop: res
25
ld
26
dec
27
ld
28
next: ld
29
ld
30
ld
31
sub
32
jr
33
ld
34
ld
35
set
36
noex: inc
37
djnz
38
39
bit
40
jr
41
ret
42
;
+DUGZDUH DQG 6RIWZDUH ,PSOHPHQWDWLRQ ([DPSOHV
length of data array
first element in comparison
second element in comparison
flag to indicate exchange
unused
pointer into data array
unused
(data), hl
; save data address
flag, h
; initialize exchange flag
b, c
; initialize length counter
b
; adjust for testing
ix, (data)
; initialize array pointer
a, (ix)
; first element in comparison
d, a
; temporary storage for element
e, (ix+1)
; second element in comparison
e
; comparison first to second
pc, noex-$ ; if first > second, no jump
(ix), e
; exchange array elements
(ix+i), d
flag, h
; record exchange occurred
ix
; point to next data element
next-$
; count number of comparisons
; repeat if more data pairs
flag, h
; determine if exchange occurred
nz, loop-$ ; continue if data unsorted
; otherwise, exit

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the Z80 and is the answer not in the manual?

Table of Contents