HP 64700 series User Manual page 71

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

Advertisement

**************************************************
* The QSORT subroutine is passed (on the stack)
* the high and low addresses of an area of bytes
* to be sorted.
**************************************************
QSORT
MOVE.L
MOVE.L
;-------------------------------------------------
; The following section splits the area to be sorted
; into two areas.
QSORT will be called to sort each
; of these smaller areas.
;
; If high index is less than low index, then sort
; is done.
;-------------------------------------------------
OVER
CMPA.L
BLE
;-------------------------------------------------
; D2 = dividing value (from low index).
;-------------------------------------------------
MOVE.B
;-------------------------------------------------
; (Increment allows DEC_HIGH loop to work first
; time through.)
;-------------------------------------------------
;#### The following instruction is deleted. ######
;
ADDQ.L
;#################################################
;-------------------------------------------------
; Move low index up until it points to a value
; greater than the dividing value.
;-------------------------------------------------
INC_LOW
ADDQ.L
CMP.B
;#### The following instruction is changed. ######
;
BLE
;#################################################
BLE
CMPA.L
BLT
BRA.B
;#### The following instruction is new. ##########
NEXT
ADDQ.L
;#################################################
;-------------------------------------------------
; Move high index down until it points to a value
; less than or equal to the dividing value.
;-------------------------------------------------
DEC_HIGH
SUBQ.L
CMP.B
BLT
;-------------------------------------------------
; If high index is less than or equal to low index,
; the area is split; do not swap values.
;-------------------------------------------------
CMPA.L
BLT
INC_LOW loop. Changing the program in the following manner will
fix the problem (notice the instructions surrounded by the "#"
character).
8[A7],A1
; A1 = high index.
4[A7],A0
; A0 = low index.
A0,A1
DONE
[A0],D2
#1,A1
#1,A0
[A0],D2
DEC_HIGH
NEXT
A0,A1
OUT
INC_LOW
#1,A1
#1,A1
[A1],D2
DEC_HIGH
A0,A1
OUT
Examples 3-35

Advertisement

Table of Contents
loading

Table of Contents