home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Phoenix CD 2.0
/
Phoenix_CD.cdr
/
11a
/
cover20.zip
/
COSORT.ASM
< prev
next >
Wrap
Assembly Source File
|
1991-01-21
|
2KB
|
69 lines
PAGE ,132
TITLE COSORT - Diskette contents list - Sort Entry Stack
COMMENT * Version 1.0 - June 1983
(PER Dr. Dobbs Journal, January, 1984, #87)
(Dan Daetwyler "Sorted Diskette Directory for
the IBM PC")
Version 2.0 Bruce F. Cameron
Cincinnati OH
February 25, 1985
Counts hidden files
Grouped sort (i.e. all COM files first etc.)
Includes Volume Label and Directory (if not root)
Lists Subdirectory names
Free space up to 100M (hard disk) *
;
;
PAGE 82
;
CODE SEGMENT PARA PUBLIC 'CODE'
ASSUME CS:CODE, DS:CODE
;
EXTRN PNTR:WORD
PUBLIC STKCNT
STKCNT DW 0 ; Count of entries in stack
;
PUBLIC SORT
SORT PROC NEAR
MOV STKCNT,CX ; Save entry count
CMP CX,1
JLE SHORT SKIP ; No sort for zero or one entry
DEC CX
MOV SI,OFFSET PNTR ; First stack entry pointer
OUTER: MOV DI,SI
ADD DI,2 ; Set to 'next' pointer
MOV DX,CX
INNER: CALL COMPAR ; Compare stack entries
JBE LEAVE ; Ascending sequence, no change
MOV AX,WORD PTR [SI]
XCHG AX,WORD PTR [DI]
MOV WORD PTR [SI],AX ; Exchange pointers
LEAVE: ADD DI,2
DEC DL
JNZ INNER ; Bubble through inner loop
ADD SI,2
LOOP OUTER ; Bubble through outer loop
SKIP: RET
SORT ENDP
;
COMPAR PROC NEAR ; This compare always forces short
PUSH SI ; strings low, since strings are
PUSH DI ; terminated with a nul
PUSH CX
MOV CX,12 ; Max characters to compare
MOV SI,WORD PTR [SI]
MOV DI,WORD PTR [DI]
REP CMPSB ; Compare strings
POP CX
POP DI
POP SI
RET
COMPAR ENDP
;
CODE ENDS
;
END
M