Sort Routines -- Introduction SSB Initializer SORT :Sort Routines -- Introduction Twï  routineó arå provideä whicè givå thå SYSLI  programmeò � accesó  tï á verù flexiblå sortinç system®  Thå maiî routinå  ió � calleä  SORT¬  anä iô provideó á utilitù whicè doeó aî  in-memorù � sorô  oæ  á seô oæ fixed-lengtè records®  Thå sortinç  techniquå � useä ió á Shelì Sort¬  adapteä froí thå booë "Softwarå Tools¢  bù � Kernigaî  anä Plaugher¬  publisheä bù Addison-Wesly¬  1976¬  pagå � 106® Thió sorô ió verù fast¬ mucè morå sï thaî thå simplå bubblå � sort. Thió  Shelì Sorô caî bå donå iî twï waysº  witè oò  withouô � usinç  pointers®  Sortinç  withouô usinç pointeró  ió  typicallù � sloweò thaî sortinç witè pointers¬  anä thå onlù advantagå tï noô � usinç  pointeró ió thå savingó oæ spacå whicè ió takeî uð bù  thå � pointeró (2*numbeò oæ entrieó bytes)®  Iæ pointeró arå useä  foò � thå  sort¬  theî wheneveò aî exchangå ió done¬  thå pointeró  arå � simplù exchanged¬  ratheò thaî thå fulì records¬ anä thió greatlù � decreases the sort time in most casts. Thå SORÔ routinå ió controlleä bù passinç tï iô á pointeò tï � á Sorô Specificatioî Blocë (SSB© iî DE®  Thió Sorô Specificatioî � Blocë  ió  á serieó oæ 2-bytå wordó whicè contaiî  thå  followinç � information: Bytes 0&1: Starting Address of 1st Record Bytes 2&3: Number of Records to Sort Bytes 4&5: Size of Each Record (in Bytes) Bytes 6&7: Address of Compare Routine Provided by User Thió  routinå compareó twï records¬  onå �                      pointeä tï bù HÌ anä thå otheò pointeä tï bù �                      DE®  Iæ thå recorä pointeä tï bù DÅ ió lesó �                      iî sortinç ordeò thaî thaô pointeä tï bù HL¬ �                      thió Comparå Routinå ió tï returî witè Carrù �                      Seô  (C)®  Iæ  thå  recordó  arå  equaì  iî �                      sortinç  order¬  thió Comparå Routinå ió  tï �                      returî witè Zerï Seô (Z)®  Onlù thå PS×  ió �                      to be affected by the Compare Routine. Bytes 8&9: Address of Pointer Table Bytå 10º Flag» ° meanó tï uså pointers¬ 0FFÈ meanó not Byte 11: Unused Aó mentioneä previously¬  twï routineó arå availablå iî thió � sorô module®  Thå firsô routine¬ SSBINIT¬ lookó aô thå beginninç � oæ  á  scratcè  areá  anä  thå initiaì contentó  oæ  aî  SS  anä � allocateó spacå foò thå pointeò table®  Iô alsï checkó tï seå iæ � thå  buffeò  requireä wilì overflo÷ thå  TPÁ  (Transienô  Prograí � Area). Thå seconä routine¬  SORT¬ performó thå sort¬ anä controlleä � by the SSB pointer passed to it in DE. :SSB Initializer Routine Name: SSBINIT Functionº Thió  routinå loadó byteó 0&± (addresó oæ firsô record© � anä  8&¹ (addresó oæ pointeò table© oæ aî SSB¬  checkinç foò  TPÁ � overflow®  Iô ió passeä thå starô addresó oæ á scratcè area¬ anä � setó  thå pointeò tablå tï starô here¬  lookó aô thå recorä  sizå � anä recorä counô entrieó oæ aî SSB¬  anä addó thió producô tï thå � addresó oæ thå pointeò table®  Thå resultanô addresó ió returneä � as the address of the first record. Thió  routinå  maù  bå useä aó describeä  abovå  beforå  anù � recordó  arå loadeä intï memorù foò thå sort¬  oò iô maù bå  useä � afteò thå recordó havå alreadù beeî loaded®  Iî thå latteò case¬ � thå  useò shoulä savå thå starô addresó oæ thå firsô  recorä  anä � calì  SSBINIÔ  witè thå addresó oæ thå firsô bytå afteò thå  lasô � record®  Oncå  SSBINIÔ  haó loadeä thå bufferó iî  thå  SS  anä � checkeä  foò  á  TPÁ  overflo÷ (notå thaô thió ió  donå  foò  thå � pointeró only)¬  iô wilì returî tï thå caller¬  aô whicè timå thå � calleò  shoulä  restorå thå firsô twï byteó oæ thå SS  tï  theiò � proper values, the actual start address of the first record. SSBINIT, Con't Inputs: HL pts to start of scratch area, DE pts to SSB Outputs: Z Flag is Set (Z) if TPA overflow; NZ if OK Registers Affected: PSW SYSLIB Routines Called: MOVEB Speciaì  Erroò Conditionsº None :SORT Routine Name: SORT Functionº SORÔ sortó thå seô oæ fixeä lengtè recordó accordinç tï � thå  controì  informatioî iî thå Sorô Specificatioî  Blocë  (SSB© � pointed to by DE. Inputs: DE pts to SSB Outputs: None (Records are Sorted) Registers Affected: None SYSLIB Routines Called: MOVEB, PRINT Speciaì  Erroò Conditionsº Thå Erroò Messagå "SORÔ Pointeò Error¢ maù bå  printed¬ � buô ió highlù unlikely® Thió indicateó á fla÷ haó developeä witè � thå SORÔ routinå foò thió particulaò case¬  anä iô coulä noô SORÔ � thå  seô  oæ recordó aó desired®  Thió erroò ió fataì  anä  wilì � abort to CP/M.