home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / ZCPR33 / S-Z / SLB36HLP.LBR / SYSLIBB.HZP / SYSLIBB.HLP
Text File  |  2000-06-30  |  5KB  |  127 lines

  1. Introduction to the Sort Routines
  2. SSBINIT -- SSB Initializer
  3. SORT    -- Main Sort Routine
  4. :Introduction to the Sort Routines
  5.  
  6.      Tw∩áá routine≤á arσá provideΣá whicΦá givσá thσá SYSLI┬ ì
  7. programme≥á acces≤ t∩ ß ver∙ flexiblσ sortinτá system«á  Thσ ì
  8. maiε routinσ i≤ calleΣ SORT¼ anΣ i⌠ provide≤ ß utilit∙ whicΦ ì
  9. doe≤á aεá in-memor∙ sor⌠ oµ ß se⌠ oµá fixed-lengtΦá records«  ì
  10. Thσ sortinτ techniquσ useΣ i≤ ß Shel∞ Sort¼ adapteΣ froφ thσ ì
  11. booδ "Softwarσ Toolsó b∙ Kernigaε anΣ Plaugher¼ publisheΣ b∙ ì
  12. Addison-Wesly¼ 1976¼ pagσ 106«  Thi≤ sor⌠ i≤ ver∙ fast¼ mucΦ ì
  13. morσ s∩ thaε thσ simplσ bubblσ sort.
  14.  
  15.      Thi≤á Shel∞á Sor⌠ caε bσ donσ iεá tw∩á ways║á  witΦá o≥ ì
  16. withou⌠á usinτ pointers«á  Sortinτ withou⌠ usinτ pointer≤ i≤ ì
  17. typicall∙á slowe≥ thaε sortinτ witΦ pointers¼á anΣ thσá onl∙ ì
  18. advantagσá t∩á no⌠ usinτ pointer≤ i≤ thσá saving≤á oµá spacσ ì
  19. whicΦá i≤á takeεá u≡ b∙ thσ pointer≤á (2*numbe≥á oµá entrie≤ ì
  20. bytes)«  Iµ pointer≤ arσ useΣ fo≥ thσ sort¼ theε wheneve≥ aε ì
  21. exchangσ i≤ done¼á thσ pointer≤ arσ simpl∙ exchanged¼ rathe≥ ì
  22. thaεá thσ ful∞ records¼á anΣ thi≤ greatl∙ decrease≤ thσ sor⌠ ì
  23. timσ iε mos⌠ casts.
  24.  
  25.      Thσá SOR╘á routinσá i≤ controlleΣ b∙ passinτá t∩á i⌠á ß ì
  26. pointe≥á t∩ ß Sor⌠ Specificatioε Blocδ (SSB⌐á iεá DE«á  Thi≤ ì
  27. Sor⌠á Specificatioε Blocδ i≤ ß serie≤ oµ 2-bytσ word≤á whicΦ ì
  28. contaiε thσ followinτ information:
  29.           Bytes 0&1: Starting Address of 1st Record
  30.           Bytes 2&3: Number of Records to Sort
  31.           Bytes 4&5: Size of Each Record (in Bytes)
  32.           Bytes 6&7: Address of Compare Routine Provided by User
  33.                  Thi≤á routinσá compare≤á tw∩á records¼á onσ ì
  34. áááááááááááápointeΣ t∩ b∙ H╠ anΣ thσ othe≥ pointeΣ t∩ b∙ DE«  ì
  35. ááááááááááááIµá thσá recorΣá pointeΣ t∩ b∙á D┼á i≤á les≤á iε ì
  36. áááááááááááásortinτá orde≥ thaε tha⌠ pointeΣ t∩ b∙ HL¼á thi≤ ì
  37. ááááááááááááComparσ Routinσ i≤ t∩ returε witΦ Carr∙ Se⌠ (C)«  ì
  38. ááááááááááááIµ thσ record≤ arσ equa∞ iε sortinτ order¼á thi≤ ì
  39. ááááááááááááComparσ Routinσ i≤ t∩ returε witΦ Zer∩ Se⌠á (Z)«  ì
  40. ááááááááááááOnl∙á thσá PS╫ i≤ t∩ bσ affecteΣ b∙ thσá Comparσ ì
  41. ááááááááááááRoutine.
  42.           Bytes 8&9: Address of Pointer Table
  43.           Bytσ 10║  Flag╗ ░FFH mean≤ t∩ usσ pointers¼ 0 mean≤ not
  44.           Byte 11:  Unused
  45.  
  46.      A≤ mentioneΣ previously¼á tw∩ routine≤ arσ availablσ iε ì
  47. thi≤ sor⌠ module«á  Thσ firs⌠ routine¼ SSBINIT¼ look≤ a⌠ thσ ì
  48. beginninτá oµ ß scratcΦ areß anΣ thσ initia∞ content≤ oµá aε ì
  49. SS┬á anΣá allocate≤ spacσ fo≥ thσ pointe≥á table«á  I⌠á als∩ ì
  50. check≤á t∩ seσ iµ thσ buffe≥ requireΣ wil∞ overflo≈ thσá TP┴ ì
  51. (Transien⌠ Prograφ Area).
  52.  
  53.      Thσá seconΣá routine¼á SORT¼á perform≤á thσá sort¼á anΣ ì
  54. controlleΣ b∙ thσ SS┬ pointe≥ passeΣ t∩ i⌠ iε DE.
  55.  
  56. :SSB Initializer
  57.      Routine:  SSBINIT
  58.  
  59.      Function:
  60.  
  61.           Thi≤á routinσá load≤ byte≤ 0&▒ (addres≤á oµá firs⌠ ì
  62. record⌐á anΣá 8&╣á (addres≤ oµ pointe≥á table⌐á oµá aεá SSB¼ ì
  63. checkinτá fo≥ TP┴ overflow«á  I⌠ i≤ passeΣ thσ star⌠ addres≤ ì
  64. oµ ß scratcΦ area¼ anΣ set≤ thσ pointe≥ tablσ t∩ star⌠ here¼ ì
  65. look≤ a⌠ thσ recorΣ sizσ anΣ recorΣ coun⌠ entrie≤ oµ aε SSB¼ ì
  66. anΣá add≤ thi≤ produc⌠ t∩ thσ addres≤ oµ thσ pointe≥á table«  ì
  67. Thσá resultan⌠á addres≤ i≤ returneΣ a≤ thσá addres≤á oµá thσ ì
  68. firs⌠ record.
  69.  
  70.  
  71. SSBINIT, Con't
  72.  
  73.      Thi≤á routinσ ma∙ bσ useΣ a≤ describeΣ abovσ beforσ an∙ ì
  74. record≤á arσ loadeΣ int∩ memor∙ fo≥ thσ sort¼á o≥ i⌠ ma∙á bσ ì
  75. useΣá afte≥ thσ record≤ havσ alread∙ beeεá loaded«á  Iεá thσ ì
  76. latte≥á case¼á thσ use≥ shoulΣ savσ thσ star⌠ addres≤ oµ thσ ì
  77. firs⌠ recorΣ anΣ cal∞ SSBINI╘ witΦ thσ addres≤ oµ thσá firs⌠ ì
  78. bytσá afte≥á thσ las⌠ record«á  Oncσ SSBINI╘ ha≤ loadeΣá thσ ì
  79. buffer≤ iε thσ SS┬ anΣ checkeΣ fo≥ ß TP┴ overflo≈ (notσ tha⌠ ì
  80. thi≤ i≤ donσ fo≥ thσ pointer≤ only)¼á i⌠ wil∞ returε t∩á thσ ì
  81. caller¼á a⌠á whicΦ timσ thσ calle≥ shoulΣ restorσ thσá firs⌠ ì
  82. tw∩á byte≤á oµ thσ SS┬ t∩ thei≥ prope≥á values¼á thσá actua∞ ì
  83. star⌠ addres≤ oµ thσ firs⌠ record.
  84.  
  85. SSBINIT, Con't
  86.  
  87.      Inputs:  HL pts to start of scratch area, DE pts to SSB
  88.  
  89.      Outputs:  Z Flag is Set (Z) if TPA overflow; NZ if OK
  90.  
  91.      Registers Affected:  PSW
  92.  
  93.      SYSLIB Routines Called:  MOVEB
  94.  
  95.      Special Error Conditions:  None
  96.  
  97.  
  98. :SORT
  99.      Routine:  SORT
  100.  
  101.      Function:
  102.  
  103.      SOR╘ sort≤ thσ se⌠ oµ fixeΣ lengtΦ record≤ accordinτ t∩ ì
  104. thσá contro∞á informatioεá iε thσ Sor⌠á Specificatioεá Blocδ ì
  105. (SSB⌐ pointeΣ t∩ b∙ DE.
  106.  
  107.      Inputs:  DE pts to SSB
  108.  
  109.      Outputs:  None (Records are Sorted)
  110.  
  111.      Registers Affected:  None
  112.  
  113.      SYSLIB Routines Called:  MOVEB, PRINT
  114.  
  115.  
  116. SORT, Con't
  117.  
  118.      Special Error Conditions:
  119.  
  120.           Thσá Erro≥á Messagσ "SOR╘ Pointe≥á Erroróá ma∙á bσ ì
  121. printed¼á bu⌠ i≤ highl∙ unlikely«  Thi≤ indicate≤ ß fla≈ ha≤ ì
  122. developeΣá witΦá thσ SOR╘ routinσ fo≥ thi≤ particula≥á case¼ ì
  123. anΣ i⌠ coulΣ no⌠ SOR╘ thσ se⌠ oµ record≤ a≤á desired«á  Thi≤ ì
  124. erro≥ i≤ fata∞ anΣ wil∞ abor⌠ t∩ CP/M.
  125.  
  126.  
  127.