home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol089 / syslibb.hlp < prev    next >
Text File  |  1985-02-09  |  5KB  |  104 lines

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