HP 64700 series User Manual page 42

Emulators
Hide thumbs Also See for 64700 series:
Table of Contents

Advertisement

000494 226F 0008
000498 206F 0004
00049C B3C8
00049E 6F00 0054
0004A2 1410
0004A4 5289
0004A6 5288
0004A8 B410
0004AA 6F00 000A
0004AE B3C8
0004B0 6D00 0018
0004B4 60F0
0004B6 5389
0004B8 B411
0004BA 6DFA
0004BC B3C8
0004BE 6D00 000A
0004C2 1610
0004C4 1091
0004C6 1283
0004C8 60DC
3-6 Examples
103 * The QSORT subroutine is passed (on the stack)
104 * the high and low addresses of an area of bytes
105 * to be sorted.
106 **************************************************
107 QSORT
MOVE.L
108
MOVE.L
109 ;-------------------------------------------------
110 ; The following section splits the area to be sorted
111 ; into two areas.
112 ; of these smaller areas.
113 ;
114 ; If high index is less than low index, then sort
115 ; is done.
116 ;-------------------------------------------------
117 OVER
CMPA.L
118
BLE
119 ;-------------------------------------------------
120 ; D2 = dividing value (from low index).
121 ;-------------------------------------------------
122
MOVE.B
123 ;-------------------------------------------------
124 ; (Increment allows DEC_HIGH loop to work first
125 ; time through.)
126 ;-------------------------------------------------
127
ADDQ.L
128 ;-------------------------------------------------
129 ; Move low index up until it points to a value
130 ; greater than the dividing value.
131 ;-------------------------------------------------
132 INC_LOW
ADDQ.L
133
CMP.B
134
BLE
135
CMPA.L
136
BLT
137
BRA.B
138 ;-------------------------------------------------
139 ; Move high index down until it points to a value
140 ; less than or equal to the dividing value.
141 ;-------------------------------------------------
142 DEC_HIGH
SUBQ.L
143
CMP.B
144
BLT
145 ;-------------------------------------------------
146 ; If high index is less than or equal to low index,
147 ; the area is split; do not swap values.
148 ;-------------------------------------------------
149
CMPA.L
150
BLT
151 ;-------------------------------------------------
152 ; If high index is greater than low index, swap
153 ; values and move indexes again.
154 ;-------------------------------------------------
155
MOVE.B
156
MOVE.B
157
MOVE.B
158
BRA.B
Figure 3-2. Sample Program Listing (Cont'd)
8[A7],A1
; A1 = high index.
4[A7],A0
; A0 = low index.
QSORT will be called to sort each
A0,A1
DONE
[A0],D2
#1,A1
#1,A0
[A0],D2
DEC_HIGH
A0,A1
OUT
INC_LOW
#1,A1
[A1],D2
DEC_HIGH
A0,A1
OUT
[A0],D3
[A1],[A0]
D3,[A1]
INC_LOW

Advertisement

Table of Contents
loading

Table of Contents