home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / programming / asm_programming / ASMFILES.ZIP / BSORT.ASM < prev    next >
Assembly Source File  |  1985-06-21  |  2KB  |  43 lines

  1. ;ROUTINE TO SORT A STRING ARRAY                        00000100
  2. ;                                    00000200
  3. bsort          proc    far                        00000300
  4. ;                                    00000400
  5.           push    si      ;SAVE    REGISTERS            00000500
  6.           push    di                        00000600
  7.           push    cx                        00000700
  8.           push    ax                        00000800
  9. ;                                    00000900
  10. ;ADJUST    COUNT FOR ONE LESS THAN    THE NUMBER OF ITEMS            00001000
  11.           dec    cx      ;ADJUST THE COUNT            00001100
  12. ;                                    00001200
  13. ;OUTER LOOP - FOR SI = 1 TO N-1                        00001300
  14. bsort1:                                    00001400
  15.           push    cx      ;SAVE    THE COUNT            00001500
  16.           mov    di,si      ;DESTINATION POINTS TO SOURCE        00001600
  17. ;                                    00001700
  18. ;INNER LOOP - FOR DI = SI+1 TO N                    00001800
  19. bsort2:                                    00001900
  20.           push    cx      ;SAVE    THE COUNT            00002000
  21.           add    di,dx      ;POINT TO NEXT DESTINATION        00002100
  22.           mov    cx,dx      ;ENTRY LENGTH                00002200
  23.           call    compare      ;COMPARE THE STRINGS            00002300
  24.           jle    bsort3      ;SKIP    IF SOURCE <= DESTINATION    00002400
  25.           call    switch      ;SWITCH IF NOT            00002500
  26. ;                                    00002600
  27. bsort3:                                    00002700
  28.           pop    cx      ;RESTORE THE COUNT            00002800
  29.           loop    bsort2                        00002900
  30. ;                                    00003000
  31.           add    si,dx      ;POINT TO NEXT SOURCE            00003100
  32.           pop    cx      ;RESTORE THE COUNT            00003200
  33.           loop    bsort1                        00003300
  34. ;                                    00003400
  35. bsortexit:                                00003500
  36.           pop    ax      ;RESTORE REGISTERS            00003600
  37.           pop    cx                        00003700
  38.           pop    di                        00003800
  39.           pop    si                        00003900
  40.           ret                            00004000
  41. ;                                    00004100
  42. bsort          endp                            00004200
  43.