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 / JSAGE / ZSUS / PROGPACK / V42-DOCS.LBR / SYSLIB42.DZC / SYSLIB42.DOC
Text File  |  1990-06-08  |  208KB  |  4,176 lines

  1. .hm1
  2. .fm1
  3. .sr0
  4. .he                                          ZCPR3: THE LIBRARIES 4.2
  5. .fo                                                            Page #
  6. .pn 1
  7.  
  8.                              Preface
  9.  
  10.  
  11. Thσ áLibraries¼ Versioε 4¼ ha≤ takeε ove≥ tw∩ year≤ t∩ arrivσ áa⌠ ì
  12. thi≤ ápoin⌠ áiε árelease«  Durinτ tha⌠ time¼ áwσ áhavσ áwitnesseΣ ì
  13. change≤ áiε thσ maiε supplie≥ fo≥ ┌-Tool≤ froφ Echeloε át∩ áAlphß ì
  14. System≤ anΣ others¼ witΦ aε addeΣ glitcΦ oµ ownershi≡ anΣ ájustiì
  15. ficatioε áfo≥ upgradinτ thσ Libraries«  Thank≤ t∩ Joσ áWrigh⌠ áoµ ì
  16. Alphß áSystem≤ fo≥ authorizinτ thi≤ effort¼ anΣ iε áallowinτ áthσ ì
  17. downloadinτ áanΣ otherwisσ freσ distributioε oµ thσ RE╠ anΣ áHEL╨ ì
  18. files« á Sourcσ codσ i≤ availablσ froφ Alphß Systems¼ áCorp¼ á71▒ ì
  19. ChatswortΦ Place¼ Saε Jose¼ C┴ 95128.
  20.  
  21. ╔ woulΣ likσ t∩ thanδ Keε Taschne≥ anΣ Brucσ Morgeε fo≥ instigatì
  22. inτ áthi≤ effor⌠ anΣ fo≥ thei≥ hel≡ durinτ thσ firs⌠ year« á Speì
  23. cia∞ thank≤ g∩ t∩ Ja∙ Sagσ fo≥ allowinτ hi≤ Z33LI┬ module≤ t∩ ábσ ì
  24. integrateΣ áint∩ áZ3LI┬ fo≥ ß completσ package¼ áanΣ át∩ áBridge≥ ì
  25. Mitchel∞ áfo≥ áallowinτ mσ t∩ usσ somσ oµ hi≤ codσ iε áDSLI┬ áfo≥ ì
  26. DateStamper interfaces.
  27.  
  28. Thank≤ als∩ t∩ somσ oµ thσ bes⌠ tester≤ iε thσ busines≤ wh∩ átooδ ì
  29. thσ áLibrarie≤ througΦ thei≥ pace≤ anΣ kep⌠ mσ u≡ latσ áa⌠ ánigh⌠ ì
  30. exterminatinτ thσ pesk∙ bugs«  The∙ are║  Cameroε Cotrill¼ HowarΣ ì
  31. Goldstein¼ áMalcoφ Kemp¼ Brucσ Morgen¼ anΣ Carsoε Wilson« á Iµ á╔ ì
  32. havσ forgotteε anyone¼ i⌠ wa≤ inadvertant¼ anΣ m∙ thank≤ a≤ well.
  33.  
  34. Iε thσ lega∞ department¼ man∙ trademark≤ arσ referenceΣ iε áthesσ ì
  35. files« á The∙ áare║  DateStamper¼ DosDisk¼ áBackGrounde≥ áii¼ áoµ ì
  36. Plu*Perfec⌠ áSystems╗ CP/M¼ CP/═ Plus¼ oµ Digita∞ Research╗ áZAS¼ ì
  37. ZDH¼ ZDM¼ ZRDOS¼ oµ Echelon¼ Inc╗ Macr∩-8░ Linδ-80¼ oµ MicroSoft╗ ì
  38. ZSDOS¼ áZDDOS¼ oµ Cameroε Cotrill¼ HarolΣ Bower¼ áCarsoε áWilson«  ì
  39. "Thσ áLibraries¼ áVersioε 4ó i≤ Copyrigh⌠ 198╣ b∙ áAlphß áSystem≤ ì
  40. Corporation¼ subjec⌠ t∩ thσ releasσ previousl∙ stateΣ fo≥ RE╠ anΣ ì
  41. HEL╨ files.
  42.  
  43.                                    11 Apr 89
  44.                                    Harold F. Bower
  45.                                    P.O. Box 313
  46.                                    Ft. Meade, MD  20755
  47. .paè
  48.             Introduction to the Libraries, Version 4
  49.  
  50.  
  51. Versioε á┤ oµ thσ Librarie≤ i≤ thσ culminatioε oµ ove≥ tw∩ áyear≤ ì
  52. oµ work«  Beginninτ witΦ thσ Versioε 3.╢ libraries¼ eacΦ ároutinσ ì
  53. wa≤ optimizeΣ fo≥ performancσ oε Z8░ compatiblσ ámicroprocessors¼ ì
  54. anΣ ámucΦ árestructurinτ wa≤ performeΣ t∩ reducσ ácodσ ásizσ áanΣ ì
  55. increasσ áfunctionalit∙ áfo≥ program≤ usinτ thesσ áne≈ ároutines«  ì
  56. Somσ oµ thσ grounΣ rule≤ fo≥ thi≤ effor⌠ were:
  57.  
  58.    o Conver⌠ sourcσ codσ t∩ Ziloτ mnemonic≤ anΣ optimizσ routine≤ ì
  59. áááááfo≥ executioε oε Z8░ anΣ HD6418░ Processors
  60.  
  61.    o Isolatσ áunitializeΣ ádatß int∩ thσ DSE╟ wherσ ápossiblσ át∩ ì
  62. ááááápermi⌠ ROMminτ oµ program≤ anΣ fo≥ futurσ growtΦ t∩ thσ Z28░ ì
  63. áááááprocessor
  64.  
  65.    o Extract common code in routines to reduce redundancy
  66.  
  67.    o AdΣ routine≤ anΣ ß ne≈ librar∙ t∩ takσ advantagσ oµ developì
  68. áááááment≤ iε commanΣ processor≤ anΣ operatinτ system≤ fo≥ áCP/═-ì
  69. ááááácompatiblσ computers
  70.  
  71. Thσ ánewe≥ famil∙ oµ ╕-bi⌠ processors¼ sucΦ a≤ thσ Z80¼ áNS├-800¼ ì
  72. 64180¼ anΣ Z18░ arσ capablσ oµ mucΦ morσ thaε thσ olde≥ 808░ áanΣ ì
  73. 808╡ áchips«  Unti∞ now¼ the∙ havσ beeε saddleΣ witΦ thσ áineffiì
  74. cien⌠ ároutine≤ áiε thσ olde≥ Versioε 3.╢ libraries« á Sincσ áthσ ì
  75. majorit∙ oµ system≤ havσ migrateΣ t∩ thσ ZCPR│ commanΣ áprocesso≥ ì
  76. replacemen⌠ whicΦ canno⌠ operatσ oε thσ olde≥ processors¼ ásacriì
  77. ficinτ backwarΣ compatibilit∙ witΦ thσ 808░ wa≤ no⌠ considereΣ áß ì
  78. significan⌠ shortcoming«  Iε ß likσ vein¼ CP/═ 1.┤ remnant≤ áhavσ ì
  79. beeε deleted¼ requirinτ CP/═ 2.▓ o≥ late≥ "typeó system≤ t∩ operì
  80. atσ correctly.
  81.  
  82. Thσ áorigina∞ routine≤ placeΣ datß a≤ wel∞ a≤ executablσ codσ áiε ì
  83. thσ ácodσ ásegment¼ o≥ CSEG«  Iε somσ routines¼ ásevera∞ áhundreΣ ì
  84. byte≤ áoµ uninitializeΣ datß wa≤ includeΣ iε prograφ ácodσ áwhicΦ ì
  85. serveΣ áonl∙ t∩ increasσ thσ sizσ oµ thσ prograφ image« á Anothe≥ ì
  86. undesireablσ featurσ oµ thi≤ approacΦ i≤ tha⌠ thi≤ practicσ áwil∞ ì
  87. no⌠ bσ permitteΣ iε newe≥ processor≤ usinτ thσ s∩-calleΣ protectì
  88. eΣ modσ oµ execution«  Movinτ datß storagσ t∩ ß separatσ ásegmen⌠ ì
  89. witΦ thσ DSE╟ assemble≥ directivσ wil∞ makσ program≤ portablσ át∩ ì
  90. thesσ ánewe≥ ásystems¼ anΣ allo≈ theφ t∩ bσ placeΣ iε áreaΣ áonl∙ ì
  91. memor∙ á(ROM)« á Becausσ oµ initializatioε requirement≤ áiε ásomσ ì
  92. modules¼ thi≤ goa∞ coulΣ no⌠ bσ totall∙ achieved.
  93.  
  94. Man∙ case≤ oµ duplicatσ codσ werσ identifieΣ withiε librar∙ árouì
  95. tines«  SucΦ case≤ werσ simplifieΣ b∙ extractinτ thσ commoε fragì
  96. ments¼ áanΣ linkinτ theφ onl∙ once«  Thi≤ featurσ i≤ átransparen⌠ ì
  97. anΣ handleΣ automaticall∙ b∙ you≥ linker«  Onl∙ onσ precautioε i≤ ì
  98. necessar∙ witΦ thi≤ scheme«  Thesσ extracteΣ routinσ name≤ generì
  99. all∙ begiε witΦ aε "ató sigε (@)¼ and¼ witΦ ß fe≈ exceptions¼ arσ ì
  100. undocumented« á Iµ áyo⌡ linδ you≥ owε librar∙ routine≤ áwitΦ áthσ ì
  101. Versioε á┤ Libraries¼ insurσ tha⌠ n∩ duplicatioε oµ name≤ áoccur≤ ìèo≥ strangσ thing≤ wil∞ happen.
  102.  
  103. Correctioε áoµ deficiencie≤ anΣ difference≤ betweeε librar∙ árouì
  104. tine≤ anΣ thσ documentatioε wa≤ als∩ ß higΦ priorit∙ durinτ áthi≤ ì
  105. effort«  Thesσ hel≡ file≤ shoulΣ exactl∙ reflec⌠ routinσ áparameì
  106. ter≤ anΣ functioning«  Wherσ difference≤ exis⌠ betweeε thσ printì
  107. eΣ manua∞ anΣ thesσ hel≡ files¼ thσ hel≡ file≤ shoulΣ bσ áconsidì
  108. ereΣ thσ morσ accurate.
  109.  
  110. Thσ áonl∙ deviatioε froφ thσ documentatioε i≤ iε ároutine≤ áwherσ ì
  111. thσ ┴ registe≥ return≤ ß valuσ oµ ░ witΦ thσ zer∩ flaτ se⌠ (Z⌐ oε ì
  112. onσ ácondition¼ anΣ thσ zer∩ flaτ rese⌠ (NZ⌐ oε thσ othe≥ ácondiì
  113. tion« á Fo≥ mos⌠ routines¼ thσ noε-zer∩ valuσ i≤ deriveΣ áfroφ áß ì
  114. 0FFΦ valuσ iε thσ ┴ registe≥ a≤ specifieΣ iε thσ printeΣ documenì
  115. tation« á Thi≤ shoulΣ no⌠ bσ considereΣ a≤ aε absolute¼ áhowever¼ ì
  116. anΣ iε ne≈ development¼ yo⌡ shoulΣ conside≥ an∙ noε-zer∩ valuσ a≤ ì
  117. valid¼ áno⌠ ájus⌠ 0FFh«  Thi≤ changσ i≤ reflecteΣ iε áthesσ áhel≡ ì
  118. files.
  119.  
  120. Thσ áareß oµ robustnes≤ wa≤ als∩ tackled¼ primaril∙ fo≥ VLI┬ áanΣ ì
  121. Z3LIB¼ áiε aε effor⌠ t∩ minimizσ thσ adversσ effect≤ áoµ árunninτ ì
  122. program≤ usinτ thosσ routine≤ oε system≤ no⌠ equippeΣ witΦ ZCPR3«  ì
  123. Whilσ no⌠ al∞ area≤ coulΣ bσ madσ "bulletproof"¼ the∙ arσ considì
  124. erabl∙ morσ toleran⌠ thaε previou≤ libraries.
  125.  
  126. Ja∙ áSage¼ autho≥ oµ ZCP╥ 3.│ anΣ 3.4¼ ha≤ contributeΣ man∙ árouì
  127. tine≤ t∩ Z3LI┬ t∩ usσ thσ additiona∞ feature≤ oµ thσ lates⌠ ácomì
  128. manΣ áprocesso≥ áreplacements«  Hi≤ ácontribution≤ áals∩ ácorrec⌠ ì
  129. deficiencie≤ áiε existinτ modules«  Thσ ne≈ Z3LI┬ ha≤ áals∩ ábeeε ì
  130. updateΣ át∩ usσ thσ extendeΣ environmen⌠ descriptioε needeΣ áwitΦ ì
  131. NZCO═ anΣ ZCP╥ 3.4«  A≤ such¼ somσ oµ thσ definition≤ anΣ parameì
  132. ter≤ havσ changed«  Seσ specifiπ Z3LI┬ Hel≡ fo≥ morσ details.
  133.  
  134. VLI┬ ha≤ beeε significantl∙ modifieΣ witΦ additiona∞ feature≤ anΣ ì
  135. mucΦ faste≥ operation«  Busines≤ graphic≤ anΣ pul∞-dowε menu≤ arσ ì
  136. amonτ áthσ addeΣ capabilities«  Detail≤ oε thσ ne≈ Z3TCA╨ áneedeΣ ì
  137. t∩ takσ advantagσ oµ thesσ routine≤ arσ iε thσ VLI┬ hel≡ section.
  138.  
  139. Severa∞ áenhancement≤ havσ beeε madσ t∩ SYSLI┬ ároutines« á Amonτ ì
  140. thσ morσ significan⌠ are:
  141.  
  142.    - DFREE now additionally returns CP/M Plus free space.
  143.    - xFN1 filename print routines mask most significant bits.
  144.    - DIRQ/DIRQ╙ ároutine≤ cal∞ DBUFFE╥ t∩ reducσ programminτ áreì
  145. áááááquirement≤ fo≥ additiona∞ suppor⌠ functions
  146.    - DIRF/DIRQ/DIRQS routines now ignore CP/M Plus date stamps.
  147.    - Ne≈ ároutine≤ havσ beeε addeΣ fo≥ filenamσ comparisons¼ áhe° ì
  148. áááááconversions¼ anΣ consolσ outpu⌠ maskinτ thσ MSB«  Thesσ áarσ ì
  149. ááááádocumenteΣ iε thσ SYSLI┬ hel≡ file.
  150.  
  151. ┴ ne≈ library¼ DSLIB¼ ha≤ beeε createΣ t∩ providσ tool≤ fo≥ worδì
  152. inτ witΦ clock≤ anΣ filσ timσ anΣ datσ stampinτ feature≤ provideΣ ì
  153. b∙ áZSDOS/ZDDOS¼ áDateStamper¼ anΣ Digita∞ Research'≤ áCP/═ áPlu≤ ì
  154. (als∩ knowε a≤ CP/═ 3.x)«  Utilit∙ routine≤ arσ als∩ featureΣ fo≥ ì
  155. conversion≤ betweeε ß variet∙ oµ differen⌠ datσ anΣ timσ formats«  ìèFo≥ use≥ programs¼ however¼ ß standardizeΣ forma⌠ patterneΣ afte≥ ì
  156. Plu*Perfec⌠ áSystemsº áDateStampe≥ i≤ used« á Director∙ ároutine≤ ì
  157. patterneΣ áafte≥ áthosσ iε SYSLI┬ wil∞ returε áfilσ ádatσ ástamp≤ ì
  158. alonτ witΦ basiπ filσ information.
  159. .paè.he                                ZCPR3: THE LIBRARIES 4.2 -- SYSLIB
  160.  
  161.                  I«  SYSLI┬ -¡ Genera∞ Routines
  162.  
  163.      Introductioε « « « « « « « « « « « « « « « « « « « « « «  10
  164.           Comment≤ oε Softwarσ Engineerinτ  « « « « « « « « «  10
  165.           Definition≤ anΣ Term≤ « « « « « « « « « « « « « « «  11
  166.           Parameter-Passinτ Convention≤ « « « « « « « « « « «  12
  167.           Overvie≈ oµ Routine≤  « « « « « « « « « « « « « « «  13
  168.      Director∙ Manipulatioε « « « « « « « « « « « « « « « « «  15
  169.           Director∙ Buffe≥ Structurσ  « « « « « « « « « « « «  16
  170.           Ho≈ T∩ Usσ Thesσ Routine≤ « « « « « « « « « « « « «  16
  171.           Buffe≥ Allocatioε « « « « « « « « « « « « « « « « «  18
  172.                DBUFFER
  173.           Disδ Freσ Spacσ « . « « « « « « « « « « « « « « « «  18
  174.                DFREE
  175.           Director∙ Alphabetizatioε « « « « « « « « « « « « «  18
  176.                DIRALPHA
  177.           GeneralizeΣ Di≥ectory Routine≤  « « « « « « « « « «  19
  178.                DIRF¼ DIRFS
  179.           Director∙ LoaΣ Routine≤ « « « « . « « « « « « « « «  20
  180.                DIRLOAD¼ DIRSLOAD
  181.           Director∙ Pacδ Routine≤ « « « « « « « « « « « « « «  21
  182.                DIRPACK¼ DIRNPACK
  183.           Optima∞ Director∙ Routine≤  « « « « « « « « « « « «  21
  184.                DIRQ¼ DIRQS
  185.           Director∙ Entr∙ Selectioε Routinσ « « « « « « « « «  22
  186.                DIRSEL
  187.           Disk Paramete≥ Informatioε  « « « « « « « « « « « «  23
  188.                DPARAMS¼ BLKSH╞ (global)¼ BLKMS╦ (global),
  189.                EXTEN╘ (global)¼ BLKMA╪ (global)¼ DIRMA╪ (global)
  190.           Filσ Sizσ Computatioε « « « . « « « « « « « « « « «  23
  191.                FSIZE
  192.      Byte-OrienteΣ Filσ Input/Outpu⌠ Routine≤ « « « « « « « «  24
  193.           Byte-OrienteΣ I/╧ Filσ Opeε « « « « « « « « « « « «  25
  194.                FI0$OPEN¼ FI1$OPEN¼ FI2$OPEN¼ FI3$OPEN,
  195.                FO0$OPEN¼ FO1$OPEN¼ FO2$OPEN¼ FO3$OPEN
  196.           Byte-OrienteΣ I/╧ Filσ Closσ  « « « « « « « « « « «  25
  197.                FI0$CLOSE¼ FI1$CLOSE¼ FI2$CLOSE¼ FI3$CLOSE,
  198.                FO0$CLOSE¼ FO1$CLOSE¼ FO2$CLOSE¼ FO3$CLOSE
  199.           Byte-OrienteΣ Input/Outpu⌠  « « « « « « « « « « « «  26
  200.                F0$GET¼ F1$GET¼ F2$GET¼ F3$GET,
  201.                F0$PUT¼ F1$PUT¼ F2$PUT¼ F3$PUT
  202.           Erro≥ Returε Code≤  « « « « « « « « « « « « « « « «  27
  203.      Byte-OrienteΣ Filσ I/╧ witΦ Variablσ Buffer≤ « « « « « «  28
  204.           Inpu⌠ anΣ Outpu⌠ Filσ Opeε  « « « « « « « « « « « «  30
  205.                FXI$OPEN¼ FXO$OPEN
  206.           Inpu⌠ anΣ Outpu⌠ Filσ Closσ « « « « « « « « « « « «  30
  207.                FXI$CLOSE¼ FXO$CLOSE
  208.           Inpu⌠ anΣ Outpu⌠  « « « « « « « « « « « « « « « « «  30
  209.                FX$GET¼ FX$PUT
  210.      Byte-OrienteΣ Filσ I/╧ witΦ Variablσ Buffer≤ anΣ UNGE╘ «  31
  211.           Inpu⌠ anΣ Outpu⌠ Filσ Opeε  « « « « « « « « « « « «  33
  212.                FYI$OPEN¼ FYO$OPEN
  213.           Inpu⌠ anΣ Outpu⌠ Filσ Closσ « « « « « « « « « « « «  33
  214.                FYI$CLOSE¼ FYO$CLOSEè          Input¼ Unget¼ anΣ Outpu⌠  « « « « « « « « « « « « «  33
  215.                FY$GET¼ FY$UNGET¼ FY$PUT
  216.      General-Purposσ CP/═ Filσ Manipulatioε Routine≤  « « « «  34
  217.           Closσ ß Filσ  « « « « « « « « « « « « « « « « « « «  34
  218.                F$CLOSE
  219.           Deletσ ß Filσ « « « « « « « « « « « « « « « « « « «  34
  220.                F$DELETE
  221.           Tes⌠ Filσ Existencσ « « « « « « « « « « « « « « « «  35
  222.                F$EXIST
  223.           Create ß Filσ « « « « « « « « « « « « « « « « « « «  35
  224.                F$MAKE
  225.           Opeε ß Filσ « « « « « « « « « « « « « « « « « « « «  35
  226.                F$OPEN¼ F$MOPEN
  227.           AppenΣ t∩ ß Filσ  « « « « « « « « « « « « « « « « «  35
  228.                F$APPEND¼ F$APPL
  229.           ReaΣ Blocδ froφ Filσ  « « « « « « « « « « « « « « «  36
  230.                F$READ
  231.           Renamσ ß Filσ « « « « « « « « « « « « « « « « « « «  37
  232.                F$RENAME
  233.           Computσ Filσ Size « « « « « « « « « « « « « « « « «  37
  234.                F$SIZE
  235.           Writσ ß Blocδ t∩ ß Filσ « « « « « « « « « « « « « «  37
  236.                F$WRITE
  237.           Returε Randoφ RecorΣ Nuφbe≥ « « « « « « « « « « « «  37
  238.                GETRR¼ GETRR1
  239.           Returε Filσ Sizσ  « « « « « « « « « « « « « « « « «  38
  240.                GETFS¼ GETFS1
  241.           Ge⌠ Filσ Attribute≤ « « « « « « « « « « « « « « « «  38
  242.                GFA
  243.           ReaΣ Filσ Blocδ Randoφ  « « « « « « « « « « « « « «  38
  244.                R$READ
  245.           Writσ Filσ Blocδ Randoφ « « « « « « « « « « « « « «  39
  246.                R$WRITE
  247.           Se⌠ o≥ Clea≥ Filσ Attribute≤  « « « « « « « « « « «  39
  248.                SCFA¼ SFA
  249.      Librar∙ Filσ Manipulatioε  « « « « « « « « « « « « « « «  40
  250.           Initializσ Librar∙  « « « « « « « « « « « « « « « «  40
  251.                LUINIT
  252.           Returε Library Director∙  « « « « « « « « « « « « «  40
  253.                LUDIR
  254.           Opeε ß Librar∙ Filσ « « « « « « « « « « « « « « « «  41
  255.                LUOPEN
  256.           Closσ ß Librar∙ Filσ  « « « « « « « « « « « « « « «  41
  257.                LUCLOSE
  258.           ReaΣ ß Librar∙ Filσ « « « « « « « « « « « « « « « «  41
  259.                LUREAD
  260.      Filσnamσ Strinτ Parse≥ « « « « « « « « « « « « « « « « «  41
  261.                FNAME
  262.      Filσ Contro∞ ┬lock Initializatioε  « « « « « « « « « « «  42
  263.                INITFCB
  264.      Disk/User Manipulatioε « « « « « « « « « « « « « « « « «  42
  265.           Ge⌠ and Se⌠ Curren⌠ Use≥ Areß « « « « « « « « « « «  43
  266.                GUA¼ SUA
  267.           Returε thσ Curren⌠ Disδ anΣ Use≥  « « « « « « « « «  43
  268.                RETUDè          Loτ int∩ ß SpecifieΣ Disδ anΣ Use≥  « « « « « « « «  43
  269.                LOGUD
  270.           Savσ anΣ Restorσ Curren⌠ Disδ anΣ Use≥  « « « « « «  44
  271.                PUTUD¼ GETUD
  272.           Se⌠ DM┴ Transfe≥ Addres≤  « « « « « « « « « « « « «  44
  273.                SETDMA
  274.      Numeriπ Strinτ Evaluatioε  « « « « « « « « « « « « « « «  44
  275.           Genera∞ ╨urpose Numeriπ Strinτ Evaluatioε « « « « «  44
  276.                EVAL
  277.           Hexadecima∞ Strinτ Evaluatioε « « « « « « « « « « «  45
  278.                EVAL16
  279.           Decima∞ Strinτ Evaluatioε « « « . « « « « « « « « «  45
  280.                EVAL10
  281.           Octa∞ Strinτ Evaluatioε « « « « « « « « « « « « « «  45
  282.                EVAL8
  283.           Binar∙ Strinτ Evaluatioε  « « « « « « « « « « « « «  46
  284.                EVAL2
  285.      The L¼ M¼ P¼ anΣ ╙ Numeriπ Outpu⌠ Routine≤ « « « « « « «  46
  286.           Samplσ Numeriπ Output≤  « « « « « « « « « « « « « «  47
  287.           ▓ Hexadecima∞ Characters  « « « « « « « « « « « « «  47
  288.                LA2HC¼ PA2HC¼ SA2HC¼ MA2HC
  289.           │ Decimal Character≤  « « « « « « « « « « « « « « «  47
  290.                LA3DC¼ PA3DC¼ SA3DC¼ MA3DC
  291.           ▒ t∩ │ Decimal Characters witΦ Leadinτ Space≤ « « «  48
  292.                LADC¼ PADC¼ SADC¼ MADC
  293.           ▒ t∩ │ Decima∞ Character≤ « « « « « « « « « « « « «  48
  294.                LAFDC¼ PAFDC¼ SAFDC¼ MAFDC
  295.           ┤ Hexadecima∞ Characters  « « « « « « « « « « « « «  48
  296.                LHL4HC¼ PHL4HC¼ SHL4HC¼ MHL4HC
  297.           ╡ Decima∞ Character≤  « « « « « « « « « « « « « « «  49
  298.                LHL5DC¼ PHL5DC¼ SHL5DC¼ MHL5DC
  299.           ▒ t∩ ╡ Decimal Characters witΦ Leadinτ Space≤ « « «  49
  300.                LHLDC¼ PHLDC¼ SHLD├¼ MHLDC
  301.           ▒ t∩ ╡ Decima∞ Character≤ « « « « « « « « « « « « .  49
  302.                LHLFDC¼ PHLFDC¼ SHLFDC¼ MHLFDC
  303.      Inpu⌠ Linσ Editor≤ « « « « « « « « « « « « « « « « « « «  50
  304.           BDOS-BaseΣ Inpu⌠ Linσ Editor≤ « « « « « « « « « « «  50
  305.                BBLINE¼ BLINE
  306.           Independen⌠ Inpu⌠ Linσ Edito≥ « « « « « « « « « « «  51
  307.                INLINE
  308.      Strinτ anΣ SwitcheΣ Outpu⌠ « « « « « « « « « « « « « « «  52
  309.           Prin⌠ Strinτ froφ Stacδ « « « « « « « « « « « « « «  53
  310.                PRINT¼ EPRINT¼ LPRINT¼ SPRINT
  311.           Prin⌠ Strinτ froφ H╠  « « « « « « « « « « « « « « «  53
  312.                PSTR¼ EPSTR¼ LPSTR¼ SPSTR
  313.      Filσnamσ Outpu⌠  « « « « « « « « « « « « « « « « « « « «  53
  314.           Prin⌠ Filσnamσ  « « « « « « « « « « « « « « « « « «  54
  315.                LFNn¼ PFNn¼ SFNn
  316.           Storσ Filσnamσ iε Memor∙  « « « « « « « « « « « « «  54
  317.                MFNn
  318.      Character-OrienteΣ Input/Outpu⌠  « « « « « « « « « « « «  55
  319.           Cha≥acter Inpu⌠ Viß BDO╙  « « « « « « « « « « « « «  56
  320.                BIN
  321.           Cha≥acter Inpu⌠ Statu≤ Viß BDO╙ « « « « « « « « « «  56
  322.                BISTè          Cha≥acter Outpu⌠ Viß BDO╙ « « « « « « « « « « « « «  56
  323.                BOUT
  324.           Cha≥acter Inpu⌠ and Capitalization witΦ Ech∩  « « «  56
  325.                CAPIN¼ CAPINE
  326.           Cha≥acter Inpu⌠ « « « « « « . « « « « « « « « « « «  56
  327.                CIN¼ RIN
  328.           Characte≥ Outpu⌠  « « « « « « « « « « « « « « « « «  57
  329.                COUT¼ COUT7,áLOUT¼ POUT¼ SOUT
  330.           Cha≥acter Outpu⌠ witΦ Contro∞ Character≤  « « « « «  57
  331.                CCOUT¼ CLOUT¼ CPOUT¼ CSOUT
  332.           Conditiona∞ Inpu⌠ « « « « « « « « « « « « « « « « «  57
  333.                CONDIN
  334.           Ne≈ Linσ Outpu⌠ « « « « « « « « « « « « « « « « « «  58
  335.                CRLF¼ LCRLF¼ SCRLF
  336.           Consolσ Statu≤  « « « « « « « « « « « « « « « « « «  58
  337.                CST
  338.      Branchinτ  « « « « « « « « « « « « « « « « « « « « « « «  58
  339.           Casσ viß ┴ Registe≥ « « « « « « « « « « « « « « « «  59
  340.                ACASE1¼ ACASE2¼ ACASE3
  341.           Casσ viß H╠ Reτister Pai≥ « « « « « « « « « « « « «  61
  342.                HCASE1¼ HCASE2¼ HCASE3
  343.           ComputeΣ GOT╧ viß ┴ « « « « « « « « « « « « « « « «  62
  344.                AGOTO1¼ AGOTO2¼ BGOTO1¼ BGOTO2
  345.           ComputeΣ GOT╧ viß H╠  « « « « « « « « « « « « « « «  63
  346.                HGOTO1¼ HGOTO2¼ DGOTO1¼ DGOTO2
  347.           Arithmetiπ I╞ viß ┴ « « « « « « « « « « « « « « « «  65
  348.                AIF1¼ AIF2
  349.           Arithmetiπ I╞ viß H╠  « « « « « « « « « « « « « « «  66
  350.                HIF1¼ HIF2
  351.      Parsinτ Aid≤ « « « « « « « « « « « « « « « « « « « « « «  67
  352.           UNIX-Stylσ ARGC/ARG╓ Strinτ Parsinτ « « « « « « « «  67
  353.                ARGV
  354.           Capitalizatioε  « « « « « « « « « « « « « « « « « «  68
  355.                CAPS¼ CAPSTR
  356.           Characte≥ Tes⌠ Routine≤ « « « « « « « « « « « « « «  68
  357.                ISALNUM¼ ISALPHA¼ ISCTRL¼ ISDIGIT¼ ISGRAPH¼
  358.                ISPRINT¼ ISPUN¼ ISSP
  359.           Characte≥ Ski≡ Routine≤ « « « « « « « « « « « « « «  69
  360.                SKNPUN¼ SKNSP¼ SKPUN¼ SKSP
  361.      General-Purposσ Arithmetiπ « « « « « « « « « « « « « « «  69
  362.           Arithmetiπ -¡ Add¼ Subtract¼ Multiply¼ Dividσ « « «  69
  363.                ADDHD¼ SUBHD¼ MULHD¼ DIVHD
  364.           Complemen⌠ -¡ Negatσ (2'≤) anΣ Complemen⌠ (1's⌐ « «  70
  365.                NEGH¼ CMPH
  366.           Logica∞ -¡ And, Or¼ Xo≥ « « « « « « « « « « « « « «  71
  367.                ANDHD¼ ORHD¼ XORHD
  368.           Rotatσ and Shif⌠ -¡ Lef⌠ anΣ Righ⌠  « « « « « « « «  71
  369.                ROTLH¼ ROTRH¼ SHFTLH¼ SHFTRH
  370.      CR├ Calculatioε  « « « « « « « « « « « « « « « « « « « «  72
  371.           Initialization  « « « « « « « « « « « « « « « « « «  72
  372.                CRCCLR¼ CRC1CLR¼ CRC2CLR¼ CRC3CLR¼ CRC3INIT
  373.           CR├ Updatinτ  « « « « « « « « « « « « « « « « « « «  73
  374.                CRCUPD¼ CRC1UPD¼ CRC2UPD¼ CRC3UPD
  375.           CR├ Completioε  « « « « « « « « « « « « « « « « « «  73
  376.                CRCDONE¼ CRC1DONE¼ CRC2DONE¼ CRC3DONEè     Randoφ Numbe≥ Generatioε « « « « « « « « « « « « « « « «  73
  377.           Initializσ Randoφ Numbe≥ Generato≥ SeeΣ « « « « « «  73
  378.                RNDINI╘
  379.           Se⌠ Knowε SeeΣ Valuσ  « « « « « « « « « « « « « « «  73
  380.                RNDSEE─
  381.           Returε 8-bi⌠ Pseudo-Randoφ Numbe≥ « « « « « « « « «  74
  382.                RN─
  383.      Strinτ anΣ Valuσ Comparisoε  « « « « « « « « « « « « « «  74
  384.           Comparσ Vector≤ « « « « . « « « « « « « « « « « « «  74
  385.                COMPB¼ COMPBC
  386.           Comparσ Filename≤ « « « « « « « « « « « « « « « « «  74
  387.                @FNCMP¼ @AFNCMP
  388.           Comparσ H╠ t∩ D┼  « « « « « « « « « « « « « « « « «  75
  389.                COMPHD
  390.           Substrinτ SearcΦ  « « « « « « « « « « « « « « « « «  75
  391.                INSTR
  392.           Vecto≥ SearcΦ « . « « « « « « « « « « « « « « « « «  76
  393.                SCANNER
  394.      Memor∙ Allocatioε  « « « « « « « « « « « « « « « « « « «  76
  395.           Allocatσ ß Blocδ oµ Memor∙  « « « « « « « « « « « «  77
  396.                ALLOC
  397.           Initializσ Memor∙ Allocatioε Systeφ « « « « « « « «  78
  398.                IALLOC
  399.           Checδ fo≥ To≡ oµ Availablσ Memor∙ « « « « « « « « «  78
  400.                GMEMTOP
  401.      Sor⌠ Routine≤  « « « « « « « « « « « « « « « « « « « « «  78
  402.           Sor⌠ Specification Blocδ Initialize≥  « « « « « « «  79
  403.                SSBINIT
  404.           Maiε Sor⌠ Routinσ « « « « « « « « « « « « « « « « «  80
  405.                SORT
  406.      Miscellaneou≤ Routine≤ « « « « « « « « « « « « « « « « «  80
  407.           BDO╙ anΣ BIO╙ Routine≤  « « « « « « « « « « « « « «  80
  408.                BDOS¼ BIOS
  409.           Characte≥ anΣ Nybblσ Conversion≤  « « « « « « « « «  81
  410.                CATH¼ @B2HH¼ @B2HL
  411.           CommanΣ Linσ Tai∞ Extractioε  « « « « « « « « « « «  82
  412.                CLINE
  413.           EnΣ oµ Codσ « « « « « « « « . « « « « « « « « « « «  82
  414.                CODEND¼ $MEMR┘ (global)
  415.           Exchangσ Nybble≤  « « « « « « « « « « « « « « « « «  83
  416.                EN
  417.           Memor∙ Fil∞ Routine≤  « « « « « « « « « « « « « « «  83
  418.                FILLB¼ FILLBC¼ HFILB¼ HFILBC
  419.           Memor∙ Movσ Routine≤  « « « « « « « « « « « « « « «  83
  420.                MOVEB¼ MOVEBC, HMOVB¼ HMOVBC
  421.           Dela∙ Routinσ « « « « « « « « « « « « « « « « « « «  84
  422.                PAUSE
  423.           Versioε Numbe≥ oµ SYSLI┬  « « « « « « « « « « « « «  84
  424.                VERSION
  425. .paè
  426.                    SYSLI┬ -¡ Genera∞ Routines
  427.  
  428.  
  429. INTRODUCTION:é á SYSLI┬ ┤ i≤ aε integrateΣ too∞ se⌠ whicΦ ái≤ ádeì
  430. signeΣ t∩ assis⌠ you¼ thσ assembl∙ languagσ programmer¼ iε áwritì
  431. inτ áprograms«  I⌠ i≤ intendeΣ t∩ placσ yo⌡ a⌠ ß highe≥ leve∞ áoµ ì
  432. abstractioε áanΣ allo≈ yo⌡ t∩ concentratσ oε thσ probleφ a⌠ áhanΣ ì
  433. withou⌠ havinτ t∩ concerε yourselµ witΦ thσ lo≈-leve∞ implementaì
  434. tioε ádetail≤ áoµ thσ operatinτ systeφ áinterface¼ áinput/output¼ ì
  435. tex⌠ parsinτ anΣ evaluation¼ math¼ anΣ sorting.
  436.  
  437. T∩ áillustratσ thi≤ point¼ conside≥ aε assembl∙ languagσ áprograφ ì
  438. whicΦ áneed≤ át∩ acces≤ ß disδ directory¼ theε displa∙ áß ásorteΣ ì
  439. lis⌠ áoµ áfilenames«  Withou⌠ SYSLI┬ ┤ o≥ ásimila≥ álibrary¼ áyo⌡ ì
  440. woulΣ áhavσ t∩ writσ ß relativel∙ sophisticateΣ bod∙ t∩ ácodσ át∩ ì
  441. acces≤ thσ directory¼ loaΣ i⌠ iε memory¼ sort¼ anΣ displa∙ it.
  442.  
  443. SYSLI┬ á4¼ however¼ provide≤ yo⌡ witΦ ß "toolboxó oµ routine≤ át∩ ì
  444. cal∞ áoε t∩ perforφ somσ oµ thσ morσ tediou≤ functions« á Onσ áoµ ì
  445. thesσ átools¼ DIRF¼ load≤ thσ element≤ oµ ß disδ director∙ áwhicΦ ì
  446. matcΦ ß filσ specificatioε int∩ ß memor∙ buffe≥ fo≥ you.
  447.  
  448. But¼ ámorσ thaε jus⌠ providinτ ß se⌠ oµ tools¼ SYSLI┬ ┤ áwa≤ ádeì
  449. signeΣ áwitΦ structureΣ programminτ anΣ softwarσ áengineerinτ áiε ì
  450. mind« á Thσ ábasiπ goa∞ iε softwarσ desigε i≤ tha⌠ áthσ áprogram≤ ì
  451. mee⌠ thσ stateΣ requirements«  Iε applyinτ softwarσ áengineering¼ ì
  452. wσ áwan⌠ ámorσ thaε jus⌠ this«  Amonτ othe≥ things¼ wσ áwan⌠ áthσ ì
  453. prograφ t∩ be:
  454.    o Modifiable
  455.    o Efficient
  456.    o Reliable
  457.    o Understandable
  458. SYSLI┬ ┤ offer≤ ß significan⌠ se⌠ oµ facilitie≤ whicΦ caε hel≡ t∩ ì
  459. achievσ thesσ goals.
  460.  
  461. COMMENT╙ O╬ SOFTWAR┼ ENGINEERING:é  Wσ arσ experiencinτ ß softwarσ ì
  462. crisi≤ today¼ thσ basi≤ oµ whicΦ i≤ simpl∙ tha⌠ i⌠ i≤ morσ diffΘì
  463. cul⌠ át∩ builΣ reliablσ softwarσ system≤ tha⌠ wσ thinδ i⌠ áshoulΣ ì
  464. be«  Al∞ to∩ often¼ thσ symptom≤ oµ thσ softwarσ crisi≤ arσ seen:
  465.    o Cost -- unpredictable and judged excessive
  466.    o Efficienc∙ ¡¡ timσ anΣ spacσ utilitizatioε arσ no⌠ efficient
  467.    o Modifiability -- software is difficult to change
  468.    o Reliability -- software often fails
  469.    o Responsiveness -- user needs are not met
  470.    o Timeliness -- software is not delivered on time
  471.    o Transportabilit∙ á¡¡ softwarσ useΣ oε onσ systeφ ma∙ no⌠ ábσ ì
  472. áááááuseΣ oε another
  473.  
  474. Thσ ábottoφ linσ iε thσ desigε oµ ß softwarσ systeφ i≤ átha⌠ áthσ ì
  475. softwarσ áshoulΣ mee⌠ it≤ stateΣ requirements«  T∩ áachievσ áthi≤ ì
  476. end¼ thσ fielΣ oµ softwarσ engineerinτ ha≤ arisen«  Thσ goal≤ áoµ ì
  477. softwarσ engineerinτ are:
  478.  
  479.      1.Modifiabilit∙ ¡¡ Softwarσ shoulΣ bσ eas∙ t∩ change¼ áanΣ ìèááááásoftwarσ shoulΣ bσ designeΣ witΦ late≥ changσ iε mind.
  480.  
  481.      2.Efficienc∙ á¡¡ Thσ softwarσ systeφ shoulΣ usσ áavailablσ ì
  482. áááááresource≤ iε aε optima∞ manner.
  483.  
  484.      3.Reliabilit∙ ¡¡ Thσ softwarσ shoulΣ perforφ accordinτ át∩ ì
  485. áááááspecificatioε anΣ recove≥ safel∙ froφ failurσ durinτ use.
  486.  
  487.      4.Understandabilit∙ ¡¡ Softwarσ shoulΣ bσ eas∙ t∩ reaΣ anΣ ì
  488. áááááfollow« á Understandabilit∙ i≤ thσ too∞ useΣ t∩ pas≤ froφ áß ì
  489. áááááparticula≥ probleφ spacσ t∩ ß solution.
  490.  
  491. SYSLI┬ ┤ attempt≤ t∩ hel≡ yo⌡ achievσ thσ goal≤ oµ softwarσ engiì
  492. neerinτ b∙ applyinτ thesσ principles:
  493.  
  494.      1.Abstractioε anΣ Informatioε Hidinτ ¡¡ Unnecessar∙ detai∞ ì
  495. ááááái≤ hiddeε froφ you«  Fo≥ example¼ thσ DIR╞ routinσ load≤ thσ ì
  496. ááááácontent≤ oµ ß disδ director∙ int∩ ß memor∙ buffer«  Ho≈ thi≤ ì
  497. áááááloaΣ ái≤ ádonσ i≤ hidden╗ al∞ yo⌡ neeΣ t∩ kno≈ i≤ átha⌠ áthσ ì
  498. áááááloaΣ wa≤ donσ anΣ yo⌡ havσ ß vecto≥ oµ director∙ entries.
  499.  
  500.      2.Modularit∙ ¡¡ SYSLI┬ ┤ i≤ ver∙ modula≥ iε design« á EacΦ ì
  501. ááááároutinσ áiε thσ librar∙ perform≤ onσ anΣ onl∙ onσ áfunction¼ ì
  502. áááááanΣ áthσ documentatioε provide≤ completσ detai∞ a≤ át∩ áwha⌠ ì
  503. ááááátha⌠ áfunctioε is¼ wha⌠ it≤ inpu⌠ parameter≤ are¼ áwha⌠ áit≤ ì
  504. áááááoutpu⌠ parameter≤ are¼ wha⌠ it≤ sidσ effect≤ are¼ anΣ áothe≥ ì
  505. ááááádata.
  506.  
  507.      3.Localizatioε anΣ Loosσ Couplinτ ¡¡ SYSLI┬ ┤ module≤ áarσ ì
  508. áááááloosel∙ coupled╗ eacΦ modulσ ma∙ bσ treateΣ independentl∙ oµ ì
  509. áááááthσ áothers«  Additionally¼ thσ module≤ arσ ástrongl∙ ácoheì
  510. ááááásive╗ áthσ component≤ oµ eacΦ modulσ arσ intimatel∙ árelateΣ ì
  511. ááááát∩ eacΦ othe≥ bu⌠ no⌠ t∩ component≤ oµ othe≥ modules.
  512.  
  513.      4.Uniformit∙ ¡¡ Thσ callinτ convention≤ betweeε thσ ávariì
  514. áááááou≤ SYSLI┬ ┤ module≤ arσ consisten⌠ witΦ eacΦ other¼ anΣ ái⌠ ì
  515. ááááái≤ áfrequentl∙ thσ casσ tha⌠ thσ outpu⌠ parameter≤ froφ áonσ ì
  516. ááááámodulσ ma∙ bσ directl∙ useΣ a≤ inpu⌠ parameter≤ t∩ another.
  517.  
  518.      5.Completenes≤ ¡¡ EacΦ modulσ o≥ grou≡ oµ relateΣ ámodule≤ ì
  519. áááááarσ áfunctionall∙ ácomplete«  N∩ áadditiona∞ áfunction≤ áarσ ì
  520. áááááneeded.
  521.  
  522.      6.Confirmabilit∙ ¡¡ ┴ prograφ writteε usinτ SYSLI┬ ┤ ámodì
  523. áááááule≤ caε bσ readil∙ decomposeΣ fo≥ incrementa∞ testing.
  524.  
  525. DEFINITION╙ áAN─ áTERMS:é  Somσ term≤ arσ useΣ frequentl∙ áiε áthσ ì
  526. SYSLI┬ ┤ documentation«  Thesσ term≤ arσ defineΣ below.
  527.  
  528.      1.Bufferé á¡¡ ┴ contiguou≤ vecto≥ oµ byte≤ iε memory« á Thσ ì
  529. ááááábuffe≥ i≤ knowε b∙ it≤ startinτ addres≤ anΣ sizσ as:
  530.           BUFFER║   DEF╙      4░        ; 40-byte buffer
  531.  
  532.      2.Character á¡¡ ┴ onσ-bytσ (╕-bit⌐ value«  ┴ ávaluσ árangσ ì
  533. áááááwithiε áthσ ASCI╔ characte≥ se⌠ (ß ╖-bi⌠ value⌐ ái≤ áimplieΣ ìèááááábu⌠ no⌠ required¼ s∩ ß characte≥ coulΣ havσ ß valuσ oµ 81h.
  534.  
  535.      3.Directory á¡¡ Aε inde° t∩ file≤ oε ß disk«  ┴ ádirector∙ ì
  536. áááááentr∙ ácontain≤ thσ namσ oµ ß file¼ thσ use≥ numbe≥ ái⌠ áreì
  537. áááááside≤ áin¼ thσ filσ size¼ anΣ wherσ thσ filσ i≤ álocateΣ áoε ì
  538. áááááthσ ádisk«  Thσ informatioε loadeΣ b∙ SYSLI┬ director∙ árouì
  539. ááááátine≤ ádoe≤ no⌠ includσ filσ locatioε information¼ bu⌠ ádoe≤ ì
  540. áááááincludσ everythinτ else«  Iε anothe≥ sense¼ thσ terφ ádirecì
  541. ááááátor∙ ái≤ áuseΣ t∩ refe≥ t∩ ß particula≥ disδ anΣ áuse≥ áareß ì
  542. ááááá(sucΦ a≤ A┤ o≥ B31).
  543.  
  544.      4.FC┬ (File Control Block⌐ ¡¡ ┴ 3╢-bytσ buffe≥ ásatisfyinτ ì
  545. áááááthσ ful∞ definitioε oµ ß CP/═ Filσ Contro∞ Block«  SYSLI┬ á┤ ì
  546. áááááFCB'≤ áarσ alway≤ 3╢ byte≤ long«  Iε man∙ cases¼ áwheε árouì
  547. ááááátine≤ áneeΣ ß use≥-supplieΣ FCB¼ yo⌡ neeΣ onl∙ fil∞ áiε áthσ ì
  548. áááááfilenamσ áanΣ typσ field≤ (byte≤ ▒-11⌐ anΣ neeΣ no⌠ áconcerε ì
  549. áááááyourselµ áwitΦ thσ res⌠ oµ thσ fields«  Thσ INITFC┬ ároutinσ ì
  550. ááááástore≤ zer∩ iε al∞ byte≤ excep⌠ byte≤ ▒-1▒ oµ thσ FCB.
  551.  
  552.      5.File ¡¡ An∙ CP/═ file¼ eithe≥ tex⌠ o≥ binary«  SYSLI┬ á┤ ì
  553. ááááámake≤ n∩ distinctioε betweeε thesσ tw∩ type≤ oµ files.
  554.  
  555.      6.String ¡¡ An∙ sequencσ oµ ASCI╔ character≤ terminateΣ b∙ ì
  556. áááááß <NUL╛ character¼ whicΦ i≤ ß bytσ oµ valuσ 0«  Example≤ áoµ ì
  557. ááááástring≤ are:
  558.                DEF┬      'This is a string',0
  559.                DEF┬      1,2,3,'This is also',0
  560.  
  561. PARAMETE╥-PASSIN╟ áCONVENTIONS:é  SYSLI┬ ┤ i≤ ver∙ áconsisten⌠ áiε ì
  562. it≤ paramete≥-passinτ conventions«  Iε al∞ cases¼ parameter≤ áarσ ì
  563. passeΣ t∩ anΣ froφ SYSLI┬ ┤ routine≤ iε registers«  Iµ morσ ávalì
  564. ue≤ arσ requireΣ thaε therσ arσ availablσ registers¼ thσ registe≥ ì
  565. value≤ áarσ ápointer≤ t∩ specificatioε block≤ whicΦ ácontaiε áthσ ì
  566. desireΣ parameter≤ (seσ thσ FXn$xxxxxÖ anΣ thσ SOR╘ routines)«  Iε ì
  567. nearl∙ al∞ cases¼ thσ followinτ registe≥ usagσ rule≤ apply:
  568.  
  569. The HL register pair is used:
  570.  
  571.      1.a≤ áß buffe≥ pointer╗ fo≥ example¼ H╠ contain≤ áthσ áadì
  572. ááááádres≤ oµ thσ buffe≥ useΣ b∙ DIRF
  573.  
  574.      2.a≤ ß strinτ pointer╗ fo≥ example¼ H╠ point≤ t∩ thσ firs⌠ ì
  575. ááááábytσ oµ ß strinτ fo≥ thσ EVA╠ routine
  576.  
  577.      3.t∩ áholΣ thσ firs⌠ operanΣ fo≥ matΦ routines╗ fo≥ áexamì
  578. áááááple¼ DIVH─ divide≤ H╠ b∙ DE
  579.  
  580. The DE register pair is used:
  581.  
  582.      1.t∩ poin⌠ t∩ aε FCB╗ fo≥ example¼ D┼ contain≤ thσ addres≤ ì
  583. áááááoµ thσ FC┬ useΣ b∙ DIRF
  584.  
  585.      2.t∩ ácontaiε áthσ seconΣ operanΣ fo≥ matΦ ároutines╗ áfo≥ ì
  586. áááááexample¼ SUBH─ subtract≤ D┼ froφ HL
  587. è     3.t∩ ápoin⌠ t∩ specia∞ block≤ (buffers⌐ useΣ b∙ áSYSLI┬ á┤ ì
  588. ááááároutines╗ áfo≥ example¼ D┼ point≤ t∩ thσ sor⌠ áspecificatioε ì
  589. áááááblocδ fo≥ thσ SOR╘ routine
  590.  
  591. The BC register pair is used:
  592.  
  593.      1.t∩ contaiε ß D╒ form¼ wherσ ┬ hold≤ ß disδ numbe≥ á(A=0⌐ ì
  594. áááááanΣ ├ hold≤ ß use≥ number
  595.  
  596. The A register is used:
  597.  
  598.      1.t∩ ácontaiε aε inpu⌠ flag╗ fo≥ example¼ ┴ ácontain≤ áthσ ì
  599. áááááselectioε flaτ useΣ b∙ DIRF
  600.  
  601.      2.t∩ ácontaiε aε erro≥ returε code╗ iµ thσ valuσ áoµ áthi≤ ì
  602. ááááácodσ ái≤ 0¼ thσ zer∩ flaτ (Z⌐ i≤ als∩ set¼ áanΣ ávicσ-versa╗ ì
  603. áááááfo≥ áexample¼ ┴ contain≤ ß TP┴ overflo≈ erro≥ flaτ áreturneΣ ì
  604. áááááb∙ thσ DIR╞ routine
  605.  
  606.      3.t∩ contaiε ß characte≥ inpu⌠ o≥ outpu⌠ froφ ß ß SYSLI┬ ┤ ì
  607. ááááároutine╗ fo≥ example¼ CI╬ return≤ ß characte≥ iε ┴ anΣ áCOU╘ ì
  608. áááááoutput≤ ß characte≥ iε A
  609.  
  610. OVERVIE╫ áO╞ ROUTINES:é  SYSLI┬ ┤ contain≤ man∙ ároutine≤ ágroupeΣ ì
  611. int∩ thσ followinτ functiona∞ areas:
  612.  
  613.      1.Director∙ áManipulatioε Routinesé ¡¡ Thesσ routine≤ ádea∞ ì
  614. áááááwitΦ director∙ access«  Thσ entrie≤ oµ ß disδ director∙ ácaε ì
  615. ááááábσ áloadeΣ áint∩ ß memor∙ buffer¼ selecteΣ agains⌠ áaε áFCB¼ ì
  616. ááááásorted¼ anΣ manipulated.
  617.  
  618.      2.Numeriπ áStrinτ áEvaluatioε Routinesé ¡¡ áThesσ ároutine≤ ì
  619. áááááconver⌠ áácharacte≥ ástring≤ áint∩ á1╢-bi⌠ ábinar∙ áávalues«  ì
  620. áááááString≤ likσ thosσ belo≈ arσ processed:
  621.                DEF┬      '123',░        ; value is 123 decimal
  622.                DEF┬      '5AH',░        ; value is 5A hexadecimal
  623.                DEF┬      '110B',░       ; value is 110 binary
  624.                DEF┬      '77Q',░        ; value is 77 octal
  625.  
  626.      3.Bytσ-OrienteΣ áFilσ Input/Outpu⌠ Routinesé ¡¡ Thesσ áro⌡ì
  627. ááááátine≤ ásuppor⌠ áinpu⌠ anΣ outpu⌠ t∩ anΣ froφ áfile≤ áoε áthσ ì
  628. ááááábasi≤ oµ ß bytσ a⌠ ß time«  FX$GET¼ fo≥ example¼ return≤ thσ ì
  629. ááááánex⌠ bytσ froφ thσ curren⌠ filσ iε A.
  630.  
  631.      4.CP/═ áFilσ Input/Outpu⌠ Routinesé ¡¡ Thesσ routine≤ ásu≡ì
  632. ááááápor⌠ áinpu⌠ anΣ outpu⌠ t∩ anΣ froφ file≤ oε thσ basi≤ áoµ áß ì
  633. ááááá12╕-bytσ áblocδ a⌠ ß time«  Provision≤ fo≥ ádeletinτ áfiles¼ ì
  634. ááááárenaminτ files¼ anΣ computinτ filσ size≤ als∩ exist.
  635.  
  636.      5.User/Disδ Manipulatioε Routinesé ¡¡ Thesσ routine≤ áallo≈ ì
  637. áááááthσ prograφ t∩ finΣ ou⌠ wha⌠ disδ anΣ use≥ areß i⌠ i≤ iε anΣ ì
  638. ááááát∩ movσ betweeε directories.
  639.  
  640.      6.Filenamσ áStrinτ Parseré ¡¡ Thi≤ routinσ i≤ useΣ t∩ ácoεì
  641. áááááver⌠ áß áfilenamσ tex⌠ strinτ int∩ aε áacceptablσ áforφ áanΣ ìèáááááplacσ i⌠ int∩ aε FCB«  Fo≥ example¼ thσ followinτ conversioε ì
  642. ááááácaε bσ done:
  643.                DEF┬      'MYFILE.TXT',░      ; string
  644.  
  645.                DEF┬      ░                   ; ..converted to
  646.                DEF┬      'MYFILE  '
  647.                DEF┬      'TXT'
  648.                DEF╙      24
  649.  
  650.      7.Inpu⌠ áLinσ Editorsé ¡¡ Thesσ routine≤ accep⌠ use≥ áinpu⌠ ì
  651. áááááwitΦ editinτ anΣ returε ß pointe≥ t∩ thσ firs⌠ bytσ oµ áuse≥ ì
  652. áááááinpu⌠ iε strinτ forφ (terminateΣ b∙ ß binar∙ 0).
  653.  
  654.      8.Strinτ Outpu⌠ Routinesé ¡¡ Thesσ routine≤ senΣ string≤ t∩ ì
  655. ááááávariou≤ ádevices«  Routine≤ arσ provideΣ t∩ senΣ string≤ áoµ ì
  656. ááááácharacter≤ át∩ thσ consolσ o≥ printe≥ witΦ o≥ áwithou⌠ ácoεì
  657. ááááátro∞-characte≥ processing.
  658.  
  659.      9.Numeriπ Outpu⌠ Routinesé ¡¡ Thesσ routine≤ conver⌠ binar∙ ì
  660. ááááávalue≤ át∩ ácharacte≥ sequence≤ anΣ outpu⌠ theφ át∩ ávariou≤ ì
  661. ááááádevices«  Outpu⌠ t∩ thσ consolσ anΣ printe≥ i≤ provided¼ anΣ ì
  662. áááááthσ áoutpu⌠ i≤ eithe≥ iε thσ forφ oµ decima∞ o≥ áhexadecima∞ ì
  663. ááááánumbers.
  664.  
  665.      10.Strinτ anΣ Valuσ Comparisoε Routinesé ¡¡ Thesσ ároutine≤ ì
  666. áááááprovidσ ávariou≤ comparisoε function≤ fo≥ botΦ ástring≤ áanΣ ì
  667. ááááánumbers«  Onσ strinτ ma∙ bσ compareΣ agains⌠ anothe≥ ástrinτ ì
  668. áááááo≥ ß substrinτ oµ anothe≥ string«  Tw∩ 1╢-bi⌠ number≤ caε bσ ì
  669. ááááácompared.
  670.  
  671.      11.Characte≥-OrienteΣ Input/Outpu⌠ Routinesé ¡¡ Thesσ áro⌡ì
  672. ááááátine≤ providσ inpu⌠ anΣ outpu⌠ service≤ oε ß ácharacte≥-fo≥-ì
  673. ááááácharacte≥ ábasi≤ át∩ ß variet∙ oµ devices« á Outpu⌠ át∩ áthσ ì
  674. áááááconsolσ áanΣ thσ printe≥ i≤ provided«  Also¼ devicσ ástatus¼ ì
  675. ááááásucΦ a≤ consolσ inpu⌠ status¼ routine≤ arσ available.
  676.  
  677.      12.MatΦ áRoutinesé ¡¡ Thesσ routine≤ áperforφ ámathematica∞ ì
  678. ááááácalculation≤ oε 1╢-bi⌠ quantities«  Add¼ subtract¼ multiply¼ ì
  679. ááááádivide¼ rotate¼ shift¼ logica∞ AND¼ logica∞ OR¼ anΣ álogica∞ ì
  680. áááááXO╥ arσ somσ oµ thσ function≤ provided.
  681.  
  682.      13.CR├ áRoutinesé ¡¡ Thesσ routine≤ suppor⌠ computatioε áoµ ì
  683. áááááCycliπ áRedundanc∙ Checδ value≤ fo≥ bytσ streams«  ┴ ánumbe≥ ì
  684. áááááoµ ádifferen⌠ áCR├ calculatioε routine≤ áarσ áavailablσ áfo≥ ì
  685. ááááádifferen⌠ CR├ polynomials.
  686.  
  687.      14.Randoφ áNumbe≥ áGenerato≥ Routinesé á¡¡ áThesσ ároutine≤ ì
  688. áááááimplemen⌠ ß pseud∩-randoφ numbe≥ generato≥ whicΦ return≤ áaε ì
  689. ááááá╕-bi⌠ valuσ wheε called«  Thσ seeΣ valuσ fo≥ thi≤ ágenerato≥ ì
  690. áááááma∙ ábσ feΣ t∩ it¼ thereb∙ generatinτ thσ samσ sequencσ áfo≥ ì
  691. áááááeacΦ giveε seed¼ o≥ i⌠ ma∙ bσ selecteΣ randomly.
  692.  
  693.      15.Sort áRoutines ¡¡ Thesσ routine≤ providσ ß áfast¼ ágenì
  694. áááááera∞-purposσ iε-memor∙ sor⌠ capability«  Thσ sor⌠ áalgorithφ ì
  695. ááááái≤ ver∙ efficien⌠ (ß shel∞ sort)¼ anΣ ma∙ bσ performeΣ usinτ ìèáááááelemen⌠ ápointer≤ o≥ no⌠ usinτ pointer≤ (pointer≤ cos⌠ ámorσ ì
  696. ááááámemor∙ bu⌠ speeΣ u≡ thσ sor⌠ eveε further).
  697.  
  698.      16.Capitalizatioε áanΣ áCharacte≥ áTest/Ski≡ áRoutine≤ á¡¡ ì
  699. áááááThesσ ároutine≤ arσ usefu∞ fo≥ tex⌠ parsing«  ┴ ávariet∙ áoµ ì
  700. áááááevaluatioε ároutine≤ arσ provideΣ t∩ determinσ thσ átypσ áoµ ì
  701. ááááácharacte≥ ábeinτ ádeal⌠ witΦ (sucΦ a≤ áalphabetic¼ ánumeric¼ ì
  702. áááááhexadecimal¼ áspace¼ ápunctuation¼ etc.)«  BotΦ ástrinτ áanΣ ì
  703. áááááindividua∞ ácharacte≥ capitalizatioε capabilitie≤ áarσ áals∩ ì
  704. áááááprovided.
  705.  
  706.      17.Memory Allocation Routines ¡¡ Thesσ routine≤ providσ áß ì
  707. ááááádynamiπ ámemor∙ allocatioε mechanisφ tha⌠ constantl∙ ácheck≤ ì
  708. áááááfo≥ áTP┴ áoverflow«  Afte≥ defininτ thσ bound≤ oµ áß ámemor∙ ì
  709. ááááábuffer¼ request≤ fo≥ spacσ froφ thi≤ areß ma∙ bσ issueΣ oε ß ì
  710. ááááábytσ-fo≥-bytσ basis.
  711.  
  712. DIRECTOR┘ áMANIPULATIO╬ áROUTINES:é  Thi≤ se⌠ oµ áSYSLI┬ ároutine≤ ì
  713. concern≤ itselµ witΦ thσ loadinτ oµ anΣ acces≤ oµ ß disδ direct∩ì
  714. r∙ fo≥ thσ genera∞ purpose≤ oµ thσ user«  IncludeΣ iε thi≤ se⌠ oµ ì
  715. routine≤ arσ thσ function≤ of:
  716.    - Pre-allocation of buffer space for the routines
  717.    - Loadinτ áoµ al∞ undeleteΣ director∙ entrie≤ int∩ áß ábuffer¼ ì
  718. áááááconstantl∙ checkinτ fo≥ memor∙ overflow
  719.    - Determining the amount of free space on the disk
  720.    - Computing the size of a file in Kilobytes (K)
  721.    - Sortinτ ß loadeΣ director∙ b∙ filσ namσ anΣ typσ o≥ b∙ áfilσ ì
  722. ááááátypσ anΣ name
  723.    - Selectinτ á(b∙ ámarking⌐ ß se⌠ oµ ádirector∙ áentrie≤ áwhicΦ ì
  724. ááááámatcΦ ß giveε ambiguou≤ filσ spec
  725.    - Packinτ áthσ loadeΣ directory¼ leavinτ iε i⌠ onl∙ thosσ áenì
  726. ááááátrie≤ markeΣ b∙ thσ selec⌠ routine
  727.  
  728. Thσ majorit∙ oµ thesσ routine≤ i≤ intendeΣ t∩ bσ useΣ t∩ áprovidσ ì
  729. ß áflexiblσ director∙ acces≤ systeφ whicΦ caε bσ tailoreΣ b∙ áthσ ì
  730. use≥ t∩ hi≤ specifiπ needs«  Fo≥ instance¼ witΦ thσ DIRLOA─ árouì
  731. tinσ áseparateΣ áfroφ thσ rest¼ severa∞ differen⌠ áload≤ áoµ áthσ ì
  732. director∙ á(from¼ fo≥ instance¼ differen⌠ ambiguou≤ áfilσ áspecs⌐ ì
  733. caε bσ performed¼ anΣ theε onσ selectioε anΣ onσ sor⌠ oε al∞ filσ ì
  734. spec≤ loadeΣ caε bσ done.
  735.  
  736. Thσ DIRQ/DIRQ╙ pai≥ arσ intendeΣ fo≥ thosσ application≤ whicΦ ád∩ ì
  737. no⌠ neeΣ thi≤ kinΣ oµ flexibility«  DIR╤ (quick⌐ anΣ DIRQ╙ (quicδ ì
  738. witΦ ásizinτ information⌐ perforφ ß load¼ select¼ anΣ sor⌠ ábaseΣ ì
  739. oε áonl∙ áonσ filσ specification«  Usinτ áDIRQ/DIRQ╙ áinsteaΣ áoµ ì
  740. DIRF/DIRF╙ áresult≤ iε les≤ codσ beinτ generateΣ anΣ á(generally⌐ ì
  741. faste≥ execution.
  742. .paèDIRECTOR┘ áBUFFE╥ áSTRUCTURE:é  DIRLOA─ anΣ DIRSLOA─ arσ áuseΣ át∩ ì
  743. loaΣ áß director∙ froφ disδ int∩ memory«  Thσ entrie≤ loadeΣ áarσ ì
  744. al∞ ánoε-deleteΣ entrie≤ iε eithe≥ ß particula≥ use≥ areß o≥ áal∞ ì
  745. use≥ area≤ oε thσ disδ whicΦ i≤ currentl∙ loggeΣ in.
  746.  
  747. Each file entry is 16 bytes long, structured as:
  748. 
  749.      byte                                   1  1  1  1  1  1
  750.      offset   0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
  751.              00  T  E  S  T              C  O  M 01 00 00 79
  752.               | \______________________/\_______/ |  |  |  |
  753.          user-+        filename           typσ    |  |  |  |
  754.                                   *extent number--+ S2 DM  |
  755.                                             record number--+
  756.  
  757.      *exten⌠ ái≤ áthσ filσ extent╗ fo≥ DIRLOAD¼ i⌠ i≤ áthσ áfirs⌠ ì
  758. áááááexten⌠ ánumbe≥ áoµ thσ file╗ fo≥ DIRSLOAD¼ i⌠ ái≤ áthσ álas⌠ ì
  759. áááááexten⌠ numbe≥ oµ thσ file
  760. 
  761. HO╫ T╧ US┼ THES┼ ROUTINES:é  Thσ DIR╞ o≥ DIRF╙ routine≤ wil∞ probì
  762. abl∙ bσ useΣ t∩ perforφ you≥ director∙ acces≤ function≤ thσ ávas⌠ ì
  763. majorit∙ áoµ thσ time«  Giveε ß buffer¼ aε ambiguou≤ áfilσ áspec¼ ì
  764. anΣ áß selectioε flag¼ DIR╞ anΣ DIRF╙ loaΣ thσ desireΣ file≤ áfo≥ ì
  765. yo⌡ áanΣ átheε yo⌡ caε worδ witΦ thσ 1╢-bytσ áfilσ áentrie≤ áfroφ ì
  766. there«  ┴ typica∞ callinτ sequencσ fo≥ DIR╞ o≥ DIRF╙ is:
  767.           CAL╠      CODEN─                   ; point to buffer space
  768.           L─        DE,FC┬                   ; point to FCB of file spec
  769.           L─        A,11000000┬              ; select all files in user 0
  770.           CAL╠      DIR╞                     ; load entries
  771.           J╥        Z,TPAOVF╠                ; ..jump if error
  772.           ..«                                ; HL pts to 1st entry,
  773.                                              ; ..BC=number of files
  774.  
  775. Iµ yo⌡ wisΦ t∩ deviatσ froφ thσ "normaló usσ fo≥ DIR╞ anΣ áDIRFS¼ ì
  776. acces≤ át∩ thσ routine≤ useΣ b∙ DIR╞ anΣ DIRF╙ i≤ áavailable« á ┴ ì
  777. casσ iε whicΦ yo⌡ ma∙ wan⌠ t∩ d∩ thi≤ i≤ wheε yo⌡ arσ áinteresteΣ ì
  778. iε áfile≤ whicΦ matcΦ morσ thaε onσ filσ spec¼ sucΦ a≤ *.AS═ áanΣ ì
  779. *.TXT«  ┴ typica∞ callinτ sequencσ fo≥ thi≤ typσ oµ acces≤ is:
  780. 
  781.      ; setup
  782.                CAL╠      CODEN─              ; point to buffer space
  783.                CAL╠      DBUFFE╥             ; get internal info and ptrs
  784.                CAL╠      DIRLOA─             ; ..or DIRSLOAD to load names
  785.                J╥        Z,TPAOVF╠           ; jump if error condition
  786.                ...
  787.      ; select first set of files
  788.                L─        DE,FCB▒             ; pt to first FCB to match
  789.                L─        A,11000000┬         ; select all files in user 0
  790.                CAL╠      DIRSE╠              ; select entries from buffer
  791.      ; repeat the following 2 lines as necessary
  792.                L─        DE,FCB▓             ; pt to 2nd FCB to match
  793.                CAL╠      DIRSE╠              ; select again
  794.      ; finish up
  795.                CAL╠      DIRPAC╦             ; pack the file entries,
  796.                                              ; ..leaving only the validè                                             ; ..entries in the buffer
  797.                L─        A,░                 ; alphabetize
  798.                CAL╠      DIRALPHA
  799.      ; done -- HL pts to first file entry, BC=number of entries
  800. .paèBUFFE╥ ALLOCATION:
  801.  
  802.      Routine║   DBUFFER
  803.      Function║ Buffer allocation routine
  804.      Entry:    HL = address of buffer start (usually CODEND to CCP)
  805.      Exit:     HL = points to first byte at which DIR entries loaded
  806.                A <> 0, zero flag clear (NZ) if OK
  807.                A = 0, zero flag set (Z) if CCP overwritten
  808.      Affected║ AF¼ HL
  809.      Usage:    Allocate≤ áthσ buffe≥ spacσ necessar∙ fo≥ thσ áse⌠ ì
  810. áááááááááááááááoµ director∙ function≤ iε general«  Iε particular¼ ì
  811. ááááááááááááááái⌠ allocate≤ thσ necessar∙ spacσ fo≥ thσ alphabetì
  812. áááááááááááááááizatioε áfunctioε a≤ wel∞ a≤ thσ loadeΣ ádirector∙ ì
  813. áááááááááááááááitself«  Thi≤ routinσ mus⌠ bσ useΣ iµ thσ DIRALPH┴ ì
  814. ááááááááááááááároutinσ i≤ t∩ bσ late≥ useΣ t∩ sor⌠ thσ directory╗ ì
  815. áááááááááááááááthi≤ routinσ allocate≤ al∞ thσ spacσ necessar∙ áb∙ ì
  816. áááááááááááááááDIRALPH┴ t∩ sor⌠ thσ routinσ (pointe≥ space)« á Iµ ì
  817. áááááááááááááááthi≤ ároutinσ ái≤ called¼ i⌠ i≤ no⌠ ánecessar∙ át∩ ì
  818. ááááááááááááááácal∞ thσ DPARAM╙ routine.
  819.  
  820. DIS╦ FRE┼ SPACE:
  821.  
  822.      Routine║   DFREE
  823.      Function║ Free space computation routine (CP/M 2.2 and 3)
  824.      Entry:    None
  825.                DPARAM╙ á(o≥ DBUFFE╥ whicΦ call≤ DPARAMS⌐ mus⌠ ábσ ì
  826. ááááááááááááááácalleΣ ábeforσ usinτ thi≤ routinσ unde≥ áCP/═ á2.▓ ì
  827. ááááááááááááááácompatiblσ systems.
  828.      Exit:     DE = free disk space in kilobytes on current disk
  829.      Affected: DE
  830.      Usage:    Commonl∙ áuseΣ áiε director∙ listinτ ároutine≤ át∩ ì
  831. áááááááááááááááobtaiε áthσ áamoun⌠ oµ freσ spacσ áoε áthσ áloggeΣ ì
  832. ááááááááááááááádisk« á I⌠ ma∙ als∩ bσ useΣ beforσ ß filσ cop∙ át∩ ì
  833. áááááááááááááááinsurσ tha⌠ adequatσ spacσ exist≤ oε thσ ádestinßì
  834. ááááááááááááááátioε drive«  Unde≥ CP/═ Plu≤ (CP/═ 3)¼ BDO╙ áfuncì
  835. ááááááááááááááátioε á4╢ i≤ automaticall∙ useΣ t∩ properl∙ áreturε ì
  836. áááááááááááááááfilσ sizσ iε ß bankeΣ system.
  837.  
  838. DIRECTOR┘ ALPHABETIZATION:
  839.  
  840.      Routine║   DIRALPHA
  841.      Function║ Directory alphabetization routine
  842.      Entry:    H╠ ╜ pointe≥ t∩ firs⌠ director∙ entr∙ (usuall∙ se⌠ ì
  843. áááááááááááááááb∙ DBUFFER)
  844.                B├ á╜ ánumbe≥ áoµ file≤ t∩ sor⌠ á(usuall∙ áse⌠ áb∙ ì
  845. áááááááááááááááDIRLOA─ o≥ DIRSLOAD)
  846.                ┴ á╜ ásor⌠ flag╗ ░ ╜ sor⌠ b∙ filenamσ átheε átype¼ ì
  847. ááááááááááááááánoε-░ ╜ sor⌠ b∙ filetypσ theε name
  848.      Exit:     None (directory list is sorted)
  849.      Affected: AF
  850.      Usage:    T∩ alphabetizσ thσ file≤ iε thσ director∙ ápointeΣ ì
  851. ááááááááááááááát∩ áb∙ H╠ b∙ eithe≥ filenamσ anΣ átypσ á(STEST.AS═ ì
  852. ááááááááááááááágoe≤ ábeforσ áTEST.AAA⌐ o≥ b∙ áfiletypσ áanΣ ánamσ ì
  853. ááááááááááááááá(TEST.AA┴ goe≤ beforσ STEST.ASM)«  Iε thσ unlikel∙ ì
  854. áááááááááááááááeven⌠ átha⌠ aε interna∞ erro≥ i≤ detecteΣ áiε áthσ ìèáááááááááááááááinterna∞ ásor⌠ routine¼ DIRALPH┴ wil∞ senΣ áß áBE╠ ì
  855. ááááááááááááááácharacte≥ t∩ thσ consolσ anΣ abor⌠ t∩ thσ áoperatì
  856. áááááááááááááááinτ systeφ viß thσ BDO╙ warφ boo⌠ vector.
  857.  
  858. GENERALIZE─ DIRECTOR┘ ROUTINES:
  859.  
  860.      Routine║   DIRF
  861.      Function║ Generalized directory routine without sizing
  862.      Entry:    HL = pointer to buffer area after user code
  863.                DE = pointer selection FCB (first 12 bytes used)
  864.                A = selection flag structured as:
  865.                     b7 -- set to select non-system files
  866.                     b6 -- set to select system files
  867.                     b5 -- set to select all user areas
  868.                     b┤-b░ ¡¡ iµ bi⌠ ╡ rese⌠ (0)¼ contain≤ numbe≥
  869.                              oµ use≥ areß t∩ select
  870.      Exit:     HL = pointer to first 16-byte file entry in buffer
  871.                BC = number of files selected
  872.                A <> 0, zero flag clear (NZ) if OK
  873.                A = 0, zero flag set (Z) if TPA overflow
  874.      Affected: AF¼ BC¼ HL
  875.      Usage:    Thσ mos⌠ flexible¼ thougΦ slowest¼ oµ thσ directoì
  876. ááááááááááááááár∙ routine≤ iε SYSLIB«  I⌠ initialize≤ thσ ábuffe≥ ì
  877. áááááááááááááááarea¼ load≤ ß disδ directory¼ select≤ ß áspecifieΣ ì
  878. áááááááááááááááse⌠ áoµ files¼ pack≤ anΣ sort≤ thσ lis⌠ oµ áfiles«  ì
  879. áááááááááááááááDIR╞ áexecute≤ slightl∙ faste≥ sincσ i⌠ ádoe≤ áno⌠ ì
  880. áááááááááááááááobtaiε sizinτ information¼ whilσ DIRF╙ obtain≤ al∞ ì
  881. áááááááááááááááinformatioε whicΦ ma∙ bσ passeΣ t∩ thσ FSIZ┼ árouì
  882. ááááááááááááááátinσ át∩ determinσ thσ sizσ oµ eacΦ entr∙ áiε áthσ ì
  883. ááááááááááááááádirectory«  Fo≥ entr∙ parameters¼ thσ addres≤ áfo≥ ì
  884. áááááááááááááááthσ ábuffe≥ ái≤ usuall∙ obtaineΣ froφ áß ácal∞ át∩ ì
  885. áááááááááááááááCODEN─ áwhicΦ return≤ thσ addres≤ oµ áfreσ ámemor∙ ì
  886. áááááááááááááááabovσ áyou≥ program«  Thσ FC┬ useΣ áfo≥ áselectioε ì
  887. áááááááááááááááneeΣ no⌠ bσ ß completσ FC┬ sincσ onl∙ thσ ácharacì
  888. áááááááááááááááter≤ iε thσ filenamσ anΣ typσ field≤ arσ used«  I⌠ ì
  889. áááááááááááááááma∙ thereforσ bσ a≤ shor⌠ a≤ 1▓ byte≤ (drivσ byte¼ ì
  890. áááááááááááááááfilenamσ anΣ type).
  891.  
  892.      Routine║   DIRFS
  893.      Function║ Generalized directory routine with sizing data
  894.      Entry:    HL = pointer to buffer area after user code
  895.                DE = pointer selection FCB (first 12 bytes used)
  896.                A = selection flag structured as:
  897.                     b7 -- set to select non-system files
  898.                     b6 -- set to select system files
  899.                     b5 -- set to select all user areas
  900.                     b┤-b░ ¡¡ iµ bi⌠ ╡ rese⌠ (0)¼ contain≤ numbe≥
  901.                              oµ use≥ areß t∩ select
  902.      Exit:     HL = pointer to first 16-byte file entry in buffer
  903.                BC = number of files selected
  904.                A <> 0, zero flag clear (NZ) if OK
  905.                A = 0, zero flag set (Z) if TPA overflow
  906.      Affected: AF¼ BC¼ HL
  907.      Usage:    Thσ mos⌠ flexible¼ thougΦ slowest¼ oµ thσ directoì
  908. ááááááááááááááár∙ routine≤ iε SYSLIB«  I⌠ initialize≤ thσ ábuffe≥ ìèáááááááááááááááarea¼ load≤ ß disδ directory¼ select≤ ß áspecifieΣ ì
  909. áááááááááááááááse⌠ áoµ files¼ pack≤ anΣ sort≤ thσ lis⌠ oµ áfiles«  ì
  910. áááááááááááááááDIR╞ áexecute≤ slightl∙ faste≥ sincσ i⌠ ádoe≤ áno⌠ ì
  911. áááááááááááááááobtaiε sizinτ information¼ whilσ DIRF╙ obtain≤ al∞ ì
  912. áááááááááááááááinformatioε whicΦ ma∙ bσ passeΣ t∩ thσ FSIZ┼ árouì
  913. ááááááááááááááátinσ át∩ determinσ thσ sizσ oµ eacΦ entr∙ áiε áthσ ì
  914. ááááááááááááááádirectory«  Fo≥ entr∙ parameters¼ thσ addres≤ áfo≥ ì
  915. áááááááááááááááthσ ábuffe≥ ái≤ usuall∙ obtaineΣ froφ áß ácal∞ át∩ ì
  916. áááááááááááááááCODEN─ áwhicΦ return≤ thσ addres≤ oµ áfreσ ámemor∙ ì
  917. áááááááááááááááabovσ áyou≥ program«  Thσ FC┬ useΣ áfo≥ áselectioε ì
  918. áááááááááááááááneeΣ no⌠ bσ ß completσ FC┬ sincσ onl∙ thσ ácharacì
  919. áááááááááááááááter≤ iε thσ filenamσ anΣ typσ field≤ arσ used«  I⌠ ì
  920. áááááááááááááááma∙ thereforσ bσ a≤ shor⌠ a≤ 1▓ byte≤ (drivσ byte¼ ì
  921. áááááááááááááááfilenamσ anΣ type).
  922.  
  923. DIRECTOR┘ LOA─ ROUTINES:
  924.  
  925.      Routine║   DIRLOAD
  926.      Function║ Directory load routine without sizing
  927.      Entry:    HL = pointer to buffer area after user code
  928.      Exit:     BC = number of 16-byte file entries loaded in buffer
  929.                A <> 0, zero flag clear (NZ) if load OK
  930.                A = 0, zero flag set (Z) if TPA overflow error
  931.      Affected: AF¼ BC
  932.      Usage:    Load≤ entrie≤ fo≥ al∞ undeleteΣ file≤ oε thσ ácurì
  933. ááááááááááááááárentl∙ áloggeΣ drivσ fo≥ late≥ selection¼ ásortinτ ì
  934. áááááááááááááááo≥ othe≥ actions«  DIRLOA─ i≤ faste≥ thaε DIRSLOA─ ì
  935. ááááááááááááááásincσ i⌠ doe≤ no⌠ havσ t∩ loaΣ sizinτ information¼ ì
  936. áááááááááááááááwhilσ áthσ latte≥ return≤ informatioε áwhicΦ áwil∞ ì
  937. áááááááááááááááallo≈ áFSIZ┼ t∩ returε thσ filσ size«  Iµ ásortinτ ì
  938. ááááááááááááááái≤ át∩ bσ done¼ thσ valuσ returneΣ iε H╠ froφ áthσ ì
  939. áááááááááááááááDBUFFE╥ routinσ i≤ ß correc⌠ inpu⌠ fo≥ thesσ árouì
  940. ááááááááááááááátines.
  941.  
  942.      Routine:   DIRSLOAD
  943.      Function║ Directory load routine with sizing data
  944.      Entry:    HL = pointer to buffer area after user code
  945.      Exit:     BC = number of 16-byte file entries loaded in buffer
  946.                A <> 0, zero flag clear (NZ) if load OK
  947.                A = 0, zero flag set (Z) if TPA overflow error
  948.      Affected: AF¼ BC
  949.      Usage:    Load≤ entrie≤ fo≥ al∞ undeleteΣ file≤ oε thσ ácurì
  950. ááááááááááááááárentl∙ áloggeΣ drivσ fo≥ late≥ selection¼ ásortinτ ì
  951. áááááááááááááááo≥ othe≥ actions«  DIRLOA─ i≤ faste≥ thaε DIRSLOA─ ì
  952. ááááááááááááááásincσ i⌠ doe≤ no⌠ havσ t∩ loaΣ sizinτ information¼ ì
  953. áááááááááááááááwhilσ áthσ latte≥ return≤ informatioε áwhicΦ áwil∞ ì
  954. áááááááááááááááallo≈ áFSIZ┼ t∩ returε thσ filσ size«  Iµ ásortinτ ì
  955. ááááááááááááááái≤ át∩ bσ done¼ thσ valuσ returneΣ iε H╠ froφ áthσ ì
  956. áááááááááááááááDBUFFE╥ routinσ i≤ ß correc⌠ inpu⌠ fo≥ thesσ árouì
  957. ááááááááááááááátines.
  958. .paèDIRECTOR┘ PAC╦ ROUTINES:
  959.  
  960.      Routine║   DIRPACK
  961.      Function║ Pack directory buffer retaining selected entries
  962.      Entry:    HL = pointer to directory buffer (from DBUFFER)
  963.                BC = number of files in buffer (from DIRLOAD)
  964.      Exit:     BC = number of files remaining in buffer
  965.      Affected: BC
  966.      Usage:    UseΣ áafte≥ selectioε oµ director∙ ároutine≤ áwitΦ ì
  967. áááááááááááááááDIRSE╠ áo≥ áequivalen⌠ t∩ deletσ al∞ áfile≤ áwhicΦ ì
  968. áááááááááááááááhavσ no⌠ beeε selecteΣ b∙ settinτ thσ mos⌠ ásignΘì
  969. áááááááááááááááfican⌠ ábi⌠ áoµ áthσ firs⌠ ábytσ áiε áeacΦ áentry«  ì
  970. áááááááááááááááDIRPAC╦ áremove≤ áreference≤ t∩ áthosσ áfile≤ ánotÖ ì
  971. ááááááááááááááámarked«  DIRNPAC╦ remove≤ thosσ entrie≤ whicΦ áareÖ ì
  972. ááááááááááááááámarked¼ keepinτ thosσ whicΦ arσ no⌠ markeΣ á(negßì
  973. ááááááááááááááátivσ pack)«  DIRSE╠ MUS╘ bσ calleΣ beforσ DIRNPAC╦ ì
  974. ááááááááááááááái≤ áuseΣ sincσ DIRNPAC╦ use≤ aε interna∞ flaτ áse⌠ ì
  975. áááááááááááááááb∙ DIRSE╠ (fo≥ SYSTE═ anΣ R/╧ information).
  976.  
  977.      Routine║   DIRNPACK
  978.      Function║ Pack directory buffer retaining non-selected entries
  979.      Entry:    HL = pointer to directory buffer (from DBUFFER)
  980.                BC = number of files in buffer (from DIRLOAD)
  981.      Exit:     BC = number of files remaining in buffer
  982.      Affected: BC
  983.      Usage:    UseΣ áafte≥ selectioε oµ director∙ ároutine≤ áwitΦ ì
  984. áááááááááááááááDIRSE╠ áo≥ áequivalen⌠ t∩ deletσ al∞ áfile≤ áwhicΦ ì
  985. áááááááááááááááhavσ no⌠ beeε selecteΣ b∙ settinτ thσ mos⌠ ásignΘì
  986. áááááááááááááááfican⌠ ábi⌠ áoµ áthσ firs⌠ ábytσ áiε áeacΦ áentry«  ì
  987. áááááááááááááááDIRPAC╦ áremove≤ áreference≤ t∩ áthosσ áfile≤ ánotÖ ì
  988. ááááááááááááááámarked«  DIRNPAC╦ remove≤ thosσ entrie≤ whicΦ áareÖ ì
  989. ááááááááááááááámarked¼ keepinτ thosσ whicΦ arσ no⌠ markeΣ á(negßì
  990. ááááááááááááááátivσ pack)«  DIRSE╠ MUS╘ bσ calleΣ beforσ DIRNPAC╦ ì
  991. ááááááááááááááái≤ áuseΣ sincσ DIRNPAC╦ use≤ aε interna∞ flaτ áse⌠ ì
  992. áááááááááááááááb∙ DIRSE╠ (fo≥ SYSTE═ anΣ R/╧ information).
  993.  
  994. OPTIMA╠ DIRECTOR┘ ROUTINES:
  995.  
  996.      Routine║   DIRQ
  997.      Function║ Quick access directory routine without sizing
  998.      Entry:    HL = pointer to buffer area (from CODEND)
  999.                DE = pointer to 12-byte select FCB
  1000.                A = modσ selection flag
  1001.                     b7 -- if set, select non-system files
  1002.                     b6 -- if set, select system files
  1003.                     b╡ ¡¡ iµ se⌠ (1)¼ sor⌠ b∙ filetypσ anΣ name╗
  1004.                           iµ rese⌠ (0)¼ sor⌠ b∙ filenamσ anΣ type
  1005.                     b4-b0 -¡ unused
  1006.      Exit:     HL = points to first 16-byte buffer entry
  1007.                BC = number of files selected
  1008.                A <> 0, zero flag clear (NZ) if load OK
  1009.                A = 0, zero flag set (Z) if TPA overflow
  1010.      Affected: AF¼ BC¼ HL
  1011.      Usage:    Commonl∙ useΣ wherσ ß simplσ sorteΣ director∙ lis⌠ ì
  1012. ááááááááááááááái≤ áneedeΣ áwitΦ minimuφ timσ anΣ ácodσ áoverhead«  ìèáááááááááááááááInformatioε i≤ gathereΣ b∙ DIRQ╙ whicΦ wil∞ áallo≈ ì
  1013. áááááááááááááááFSIZ┼ át∩ ácalculatσ filσ sizes¼ whilσ áDIR╤ ádoe≤ ì
  1014. ááááááááááááááánot«  Sincσ DIRQ╙ obtain≤ sizinτ informatioε a≤ i⌠ ì
  1015. áááááááááááááááload≤ thσ director∙ information¼ i⌠ run≤ áslightl∙ ì
  1016. áááááááááááááááslower« á Iε áthσ unlikel∙ even⌠ áoµ áaε áinterna∞ ì
  1017. ááááááááááááááápointe≥ ásor⌠ error¼ ß BE╠ characte≥ wil∞ bσ ásen⌠ ì
  1018. ááááááááááááááát∩ áthσ áconsolσ anΣ thσ prograφ wil∞ ábσ áaborteΣ ì
  1019. áááááááááááááááwitΦ ß warφ boot.
  1020.  
  1021.      Routine║   DIRQS
  1022.      Function║ Quich access directory routine With sizing data
  1023.      Entry:    HL = pointer to buffer area (from CODEND)
  1024.                DE = pointer to 12-byte select FCB
  1025.                A = modσ selection flag
  1026.                     b7 -- if set, select non-system files
  1027.                     b6 -- if set, select system files
  1028.                     b╡ ¡¡ iµ se⌠ (1)¼ sor⌠ b∙ filetypσ anΣ name╗
  1029.                           iµ rese⌠ (0)¼ sor⌠ b∙ filenamσ anΣ type
  1030.                     b4-b0 -- unused
  1031.      Exit:     HL = points to first 16-byte buffer entry
  1032.                BC = number of files selected
  1033.                A <> 0, zero flag clear (NZ) if load OK
  1034.                A = 0, zero flag set (Z) if TPA overflow
  1035.      Affected: AF¼ BC¼ HL
  1036.      Usage:    Commonl∙ useΣ wherσ ß simplσ sorteΣ director∙ lis⌠ ì
  1037. ááááááááááááááái≤ áneedeΣ áwitΦ minimuφ timσ anΣ ácodσ áoverhead«  ì
  1038. áááááááááááááááInformatioε i≤ gathereΣ b∙ DIRQ╙ whicΦ wil∞ áallo≈ ì
  1039. áááááááááááááááFSIZ┼ át∩ ácalculatσ filσ sizes¼ whilσ áDIR╤ ádoe≤ ì
  1040. ááááááááááááááánot«  Sincσ DIRQ╙ obtain≤ sizinτ informatioε a≤ i⌠ ì
  1041. áááááááááááááááload≤ thσ director∙ information¼ i⌠ run≤ áslightl∙ ì
  1042. áááááááááááááááslower« á Iε áthσ unlikel∙ even⌠ áoµ áaε áinterna∞ ì
  1043. ááááááááááááááápointe≥ ásor⌠ error¼ ß BE╠ characte≥ wil∞ bσ ásen⌠ ì
  1044. ááááááááááááááát∩ áthσ áconsolσ anΣ thσ prograφ wil∞ ábσ áaborteΣ ì
  1045. áááááááááááááááwitΦ ß warφ boot«  
  1046.  
  1047. DIRECTOR┘ ENTR┘ SELECTION:
  1048.  
  1049.      Routine║   DIRSEL
  1050.      Function║ Directory entry selection routine
  1051.      Entry:    HL = pointer to directory buffer (set by DBUFFER)
  1052.                DE = pointer to 12-byte selection FCB
  1053.                B├ ╜ numbe≥ oµ file≤ iε director∙ (froφ DIRLOA─ o≥ ì
  1054. áááááááááááááááDIRSLOAD)
  1055.                A = modσ selection flag:
  1056.                     b7 -- set to select non-system files
  1057.                     b6 -- set to select system files
  1058.                     b5 -- set to select all user areas
  1059.                     b┤-b░ ¡¡ iµ bi⌠ ╡ rese⌠ (0)¼ contain≤ numbe≥
  1060.                              oµ use≥ areß t∩ select
  1061.      Exit:     None.  MSB set on first byte of selected entries
  1062.      Affected: None
  1063.      Usage:    Mark≤ áal∞ file≤ iε thσ director∙ buffe≥ ámatchinτ ì
  1064. áááááááááááááááthσ áspecifieΣ criteriß b∙ settinτ thσ MS┬ oµ áthσ ì
  1065. áááááááááááááááfirs⌠ ábyte« á I⌠ áma∙ bσ useΣ afte≥ áan∙ áoµ áthσ ì
  1066. áááááááááááááááSYSLI┬ ádirector∙ ároutine≤ á(DIRF¼ áDIRFS¼ áDIRQ¼ ìèáááááááááááááááDIRQS⌐ át∩ selec⌠ ß subse⌠ oµ al∞ entrie≤ áiε áthσ ì
  1067. ááááááááááááááádirector∙ buffer.
  1068.  
  1069. DIS╦ PARAMETE╥ INFORMATION:
  1070.  
  1071.      Routine║   DPARAMS
  1072.      Function║ Disk parameter information extraction routine
  1073.      Entry:    None
  1074.      Exit:     None (information is placed in local buffers)
  1075.      Affected: None
  1076.      Usage:    Extract≤ necessar∙ informatioε froφ thσ disδ paraì
  1077. ááááááááááááááámete≥ áblocδ (DPB⌐ anΣ store≤ i⌠ awa∙ fo≥ áusσ áb∙ ì
  1078. áááááááááááááááothe≥ disδ director∙ routines«  Iµ DBUFFE╥ (o≥ an∙ ì
  1079. áááááááááááááááoµ thσ SYSLI┬ director∙ routines⌐ i≤ called¼ i⌠ i≤ ì
  1080. áááááááááááááááno⌠ necessar∙ t∩ cal∞ DPARAM╙ again«  Thσ áfollowì
  1081. áááááááááááááááinτ globa∞ variable≤ arσ se⌠ froφ DP┬ information:
  1082.  
  1083. .ix BLKSHF (g)
  1084.      Global║   BLKSHF -- Block shift factor (1 byte)
  1085.  
  1086. .ix BLKMSK (g)
  1087.      Global║   BLKMSK -- Block mask (1 byte)
  1088.  
  1089. .ix EXTENT (g)
  1090.      Global║   EXTENT -- Extent mask (1 byte)
  1091.  
  1092. .ix BLKMAX (g)
  1093.      Global:   BLKMAX á¡¡ áMaximuφ numbe≥ oµ block≤ áoε ádisδ á(▓ ì
  1094. ááááááááááááááábytes)
  1095.  
  1096. .ix DIRMAX (g)
  1097.      Global:   DIRMAX á¡¡ Maximuφ numbe≥ oµ director∙ entrie≤ á(▓ ì
  1098. ááááááááááááááábytes)
  1099.  
  1100. FIL┼ SIZ┼ COMPUTATION:
  1101.  
  1102.      Routine║   FSIZE
  1103.      Function║ File size computation routine
  1104.      Entry:    HL = pointer to first byte of 16-byte file entry
  1105.                DPARAM╙ (o≥ DBUFFER¼ DIRFS¼ DIRQS¼ DIRSLOAD⌐ ámus⌠ ì
  1106. ááááááááááááááábσ ácalleΣ beforσ FSIZ┼ s∩ tha⌠ thσ ácorrec⌠ ádisδ ì
  1107. áááááááááááááááparamete≥ informatioε i≤ established.
  1108.      Exit:     DE = file size in kilobytes (K)
  1109.      Affected: DE
  1110.      Usage:    Normall∙ áuseΣ t∩ computσ thσ sizσ oµ ß filσ áconì
  1111. ááááááááááááááátaineΣ áiε áß director∙ produceΣ áb∙ áDIRSLOA─ áo≥ ì
  1112. áááááááááááááááDIRQS« á Thi≤ ároutinσ wil∞ ágenerall∙ áwork¼ ábu⌠ ì
  1113. áááááááááááááááreturε incorrec⌠ results¼ iµ thσ entr∙ wa≤ áloadeΣ ì
  1114. áááááááááááááááb∙ áDIRLOA─ áo≥ DIR╤ whicΦ d∩ áno⌠ áreturε ásizinτ ì
  1115. áááááááááááááááinformation.
  1116. .paèBYT┼-ORIENTE─ FIL┼ INPUT/OUTPU╘ ROUTINES:é  Thσ followinτ documenì
  1117. tatioε cover≤ thσ serie≤ oµ bytσ-orienteΣ filσ input/outpu⌠ árouì
  1118. tine≤ áiε SYSLIB«  Thesσ routine≤ allo≈ yo⌡ t∩ sequentiall∙ áreaΣ ì
  1119. froφ á(GET⌐ anΣ writσ t∩ (PUT⌐ ß filσ oε ß ábytσ-fo≥-bytσ ábasis«  ì
  1120. Hence¼ thesσ routine≤ providσ aε exceptionall∙ simplσ methoΣ áfo≥ ì
  1121. handlinτ inpu⌠ froφ anΣ outpu⌠ t∩ ß file.
  1122.  
  1123. ┴ átypica∞ áprograφ whicΦ employ≤ thesσ routine≤ ámus⌠ áopeε áthσ ì
  1124. requireΣ file≤ beforσ doinτ an∙ processing¼ mus⌠ theε perforφ thσ ì
  1125. processinτ áoε áthσ openeΣ files¼ anΣ mus⌠ theε closσ áthσ áfile≤ ì
  1126. wheε áthσ processinτ i≤ completσ (closinτ thσ file≤ ái≤ áoptiona∞ ì
  1127. fo≥ inpu⌠ file≤ anΣ mandator∙ fo≥ outpu⌠ files).
  1128.  
  1129. SYSLI┬ áprovide≤ áfou≥ set≤ oµ routine≤ áfo≥ ábytσ-orienteΣ áfilσ ì
  1130. inpu⌠ anΣ output:
  1131.  
  1132. input open  output open   GET     PUT   input close  output close
  1133.  FI0$OPEN    FO0$OPEN    F0$GET  F0$PUT  FI0$CLOSE    FO0$CLOSE
  1134.  FI1$OPEN    FO1$OPEN    F1$GET  F1$PUT  FI1$CLOSE    FO1$CLOSE
  1135.  FI2$OPEN    FO2$OPEN    F2$GET  F2$PUT  FI2$CLOSE    FO2$CLOSE
  1136.  FI3$OPEN    FO3$OPEN    F3$GET  F3$PUT  FI3$CLOSE    FO3$CLOSE
  1137.  
  1138. Thi≤ systeφ allow≤ thσ use≥ t∩ havσ u≡ t∩ ╕ file≤ opeε simultaneì
  1139. ousl∙ ¡¡ fou≥ arσ opeε fo≥ inpu⌠ usinτ GE╘ anΣ fou≥ arσ opeε áfo≥ ì
  1140. outpu⌠ áusinτ PUT«  Fo≥ example¼ thσ followinτ i≤ ß ásamplσ ácodσ ì
  1141. sectioε usinτ thesσ routine≤ fo≥ tw∩ files:
  1142. 
  1143.           EX╘       FI0$OPE╬                 ; declare library references
  1144.           EXT       FO0$OPEN
  1145.           EXT       FI0$CLOSE
  1146.           EXT       FO0$CLOSE
  1147.           EXT       F0$GET
  1148.           EXT       F0$PUT
  1149.           ...
  1150.           LD        DE,FCBI                  ; pt to FCB of input file
  1151.           CALL      FI0$OPEN
  1152.           LD        DE,FCBO                  ; pt to FCB of output file
  1153.           CALL      FO0$OPEN
  1154.           ...
  1155.      [body containing CALL F0$GET and CALL F0$PUT]
  1156.           ...
  1157.           CALL      FI0$CLOSE                ; close file
  1158.           CALL      FO0$CLOSE
  1159.           ...
  1160.           END
  1161. 
  1162. Notσ tha⌠ onl∙ thσ routine≤ t∩ bσ useΣ arσ referenceΣ iε thσ áEX╘ ì
  1163. statements« á Iµ áyo⌡ d∩ no⌠ neeΣ ß particula≥ ároutine¼ ád∩ áno⌠ ì
  1164. referencσ it«  No⌠ referencinτ aε unneedeΣ routinσ usuall∙ ásave≤ ì
  1165. thσ overheaΣ memor∙ spacσ oµ loadinτ i⌠ froφ thσ library.
  1166.  
  1167. EacΦ áse⌠ oµ INPU╘ OPEN¼ INPU╘ CLOSE¼ OUTPU╘ OPEN¼ OUTPU╘ áCLOSE¼ ì
  1168. GET¼ áanΣ áPU╘ routine≤ i≤ containeΣ iε onσ álibrar∙ ámodule¼ ás∩ ì
  1169. referencinτ an∙ oµ thesσ routine≤ cause≤ thσ entirσ modulσ t∩ ábσ ì
  1170. loaded¼ anΣ al∞ thσ routine≤ arσ accessablσ t∩ thσ use≥ (provideΣ ìèthe∙ arσ mentioneΣ iε thσ externa∞ definitions⌐ withou⌠ an∙ addiì
  1171. tiona∞ ámemor∙ áoverhead« á Specifically¼ áFI0$OPEN¼ ááFI0$CLOSE¼ ì
  1172. FO0$OPEN¼ áFO0$CLOSE¼ áF0$GET¼ anΣ F0$PU╘ arσ ácontaineΣ áiε áonσ ì
  1173. module¼ áanΣ referencσ t∩ an∙ oµ thesσ routine≤ load≤ thσ áentirσ ì
  1174. module╗ thσ samσ i≤ truσ fo≥ thσ othe≥ set≤ oµ routines.
  1175.  
  1176. Thσ áCLOS┼ routinσ fo≥ outpu⌠ (FOn$CLOSE⌐ i≤ alwaysÖ required╗ ái⌠ ì
  1177. fill≤ áthσ áres⌠ oµ thσ curren⌠ blocδ witΦ ^┌ followeΣ áb∙ á<NUL╛ ì
  1178. byte≤ áanΣ áproperl∙ close≤ file«  Thσ CLOS┼ ároutinσ áfo≥ áinpu⌠ ì
  1179. (FIn$CLOSE⌐ i≤ requireΣ onl∙ ifÖ yo⌡ arσ goinτ t∩ late≥ opeε áanoì
  1180. the≥ áfilσ áfo≥ áinpu⌠ áusinτ áthσ ácorrespondinτ áOPE╬ áároutinσ ì
  1181. (FIn$OPEN)« á FIn$CLOS┼ onl∙ serve≤ t∩ rese⌠ thσ OPE╬ flaτ á(useΣ ì
  1182. t∩ GE╘ t∩ ascertaiε tha⌠ thσ filσ ha≤ beeε properl∙ opened).
  1183.  
  1184.      Routines║  FI0$OPEN ,  FI1$OPEN ,  FI2$OPEN ,  FI3$OPEN
  1185.      Function║ Open file for byte inpu⌠
  1186.      Entry:    DE = address of FCB of file to open
  1187.      Exit:     A = 0, zero flag set (Z) if open successful
  1188.                A = error code, zero flag clear (NZ) if error
  1189.      Affected: AF
  1190.      Usage:    Open≤ áthσ áspecifieΣ áfilσ fo≥ áinpu⌠ á(usσ áwitΦ ì
  1191. áááááááááááááááF$GET)¼ áanΣ outpu⌠ (usσ witΦ F$PUT)« á The∙ áiniì
  1192. ááááááááááááááátializσ thσ FC┬ fields¼ s∩ furthe≥ áinitializßtioε ì
  1193. ááááááááááááááái≤ no⌠ necessary«  Thσ outpu⌠ opeε function≤ áals∩ ì
  1194. ááááááááááááááácreatσ áthσ indicateΣ filσ iµ i⌠ doe≤ no⌠ áalread∙ ì
  1195. áááááááááááááááexist.
  1196.  
  1197.      Routines:  FO0$OPEN ,  FO1$OPEN ,  FO2$OPEN ,  FO3$OPEN
  1198.      Function║ Open file for byte output
  1199.      Entry:    DE = address of FCB of file to open
  1200.      Exit:     A = 0, zero flag set (Z) if open successful
  1201.                A = error code, zero flag clear (NZ) if error
  1202.      Affected: AF
  1203.      Usage:    Open≤ áthσ áspecifieΣ áfilσ fo≥ áinpu⌠ á(usσ áwitΦ ì
  1204. áááááááááááááááF$GET)¼ áanΣ outpu⌠ (usσ witΦ F$PUT)« á The∙ áiniì
  1205. ááááááááááááááátializσ thσ FC┬ fields¼ s∩ furthe≥ áinitializßtioε ì
  1206. ááááááááááááááái≤ no⌠ necessary«  Thσ outpu⌠ opeε function≤ áals∩ ì
  1207. ááááááááááááááácreatσ áthσ indicateΣ filσ iµ i⌠ doe≤ no⌠ áalread∙ ì
  1208. áááááááááááááááexist.
  1209.  
  1210.      Routines║  FI0$CLOSE ,  FI1$CLOSE ,  FI2$CLOSE ,  FI3$CLOSE
  1211.      Function║ Close byte input file
  1212.      Entry:    None
  1213.      Exit:     A = 0, zero flag set (Z) if close successful
  1214.                A = error code, zero flag clear (NZ) if error
  1215.      Affected: AF
  1216.      Usage:    Close≤ file≤ previousl∙ openeΣ b∙ thσ ácorrespondì
  1217. áááááááááááááááinτ FI$OPE╬ o≥ FO$OPE╬ routines«  Whilσ closinτ aε ì
  1218. áááááááááááááááinpu⌠ filσ i≤ optiona∞ iµ anothe≥ filσ wil∞ no⌠ bσ ì
  1219. áááááááááááááááopeneΣ late≥ b∙ thσ correspondinτ FI$OPE╬ routine¼ ì
  1220. ááááááááááááááái⌠ ái≤ poo≥ programminτ practicσ whicΦ áma∙ ácausσ ì
  1221. áááááááááááááááproblem≤ áiε ámorσ áadvanceΣ áopera⌠inτ áásystems«  ì
  1222. áááááááááááááááClosinτ áoutpu⌠ file≤ i≤ mandatoryÖ iµ yo⌡ wan⌠ át∩ ì
  1223. áááááááááááááááretaiε thσ file.
  1224. è     Routines║  FO0$CLOSE ,  FO1$CLOSE ,  FO2$CLOSE ,  FO3$CLOSE
  1225.      Function║ Close byte output file
  1226.      Entry:    None
  1227.      Exit:     A = 0, zero flag set (Z) if close successful
  1228.                A = error code, zero flag clear (NZ) if error
  1229.      Affected: AF
  1230.      Usage:    Close≤ file≤ previousl∙ openeΣ b∙ thσ ácorrespondì
  1231. áááááááááááááááinτ FI$OPE╬ o≥ FO$OPE╬ routines«  Whilσ closinτ aε ì
  1232. áááááááááááááááinpu⌠ filσ i≤ optiona∞ iµ anothe≥ filσ wil∞ no⌠ bσ ì
  1233. áááááááááááááááopeneΣ late≥ b∙ thσ correspondinτ FI$OPE╬ routine¼ ì
  1234. ááááááááááááááái⌠ ái≤ poo≥ programminτ practicσ whicΦ áma∙ ácausσ ì
  1235. áááááááááááááááproblem≤ áiε ámorσ áadvanceΣ áopera⌠inτ áásystems«  ì
  1236. áááááááááááááááClosinτ áoutpu⌠ file≤ i≤ mandatoryÖ iµ yo⌡ wan⌠ át∩ ì
  1237. áááááááááááááááretaiε thσ file.
  1238.  
  1239.      Routines║  F0$GET ,  F1$GET ,  F2$GET ,  F3$GET
  1240.      Function║ Get next byte from input file
  1241.      Entry:    None
  1242.      Exit:     A = byte from file, zero set (Z) if OK
  1243.                A = error code, zero clear (NZ) if error
  1244.      Affected: AF
  1245.      Usage:    Get≤ ß bytσ froφ thσ filσ specifieΣ iε thσ ácorreì
  1246. áááááááááááááááspondinτ Fn$OPE╬ routine.
  1247.  
  1248.      Routines:  F0$PUT ,  F1$PUT ,  F2$PUT ,  F3$PUT
  1249.      Function║ Put a byte to output file
  1250.      Entry:    A = byte to add to file
  1251.      Exit:     A = 0, zero flag set (Z) if OK
  1252.                A = error code, zero clear (NZ) if error
  1253.      Affected: AF
  1254.      Usage:    Put≤ áß bytσ t∩ thσ filσ specifieΣ iε áthσ ácorreì
  1255. áááááááááááááááspondinτ Fn$OPE╬ routine.
  1256. .paèERRO╥ áRETUR╬ áCODES:é  Fo≥ eacΦ oµ thσ routine≤ iε áthi≤ áse⌠ áoµ ì
  1257. bytσ-orienteΣ filσ I/╧ routines¼ thσ zer∩ flaτ anΣ thσ ┴ registe≥ ì
  1258. pla∙ áß ke∙ rolσ iε indicatinτ thσ erro≥ condition≤ oµ áthσ árouì
  1259. tines.
  1260.  
  1261. Iµ áthσ zer∩ flaτ i≤ se⌠ (Z⌐ afte≥ ß routinσ ha≤ ábeeε áexecuted¼ ì
  1262. theε áthi≤ indicate≤ tha⌠ n∩ erro≥ ha≤ occurred«  Thσ ┴ áregiste≥ ì
  1263. i≤ eithe≥ unaffecteΣ (iε mos⌠ cases⌐ o≥ contain≤ ß returneΣ valuσ ì
  1264. (iµ s∩ indicated¼ a≤ iε Fn$GE╘ routines).
  1265.  
  1266. Iµ thσ zer∩ flaτ i≤ clea≥ (NZ⌐ afte≥ ß routinσ ha≤ beeε executed¼ ì
  1267. theε áthi≤ indicate≤ tha⌠ aε erro≥ ha≤ occurred«  Thσ ┴ áregiste≥ ì
  1268. no≈ contain≤ thσ erro≥ code«  Followinτ i≤ ß summar∙ oµ thσ erro≥ ì
  1269. codes.
  1270.  
  1271.    code   meaning
  1272.      ▒    GET or PUT attempted on an unopened file
  1273.      2    Disk full (ran out of space)
  1274.      3    Input file not found
  1275.      4    Attempt to read past EOF
  1276.      5    Directory full
  1277.      6    Error in closing a file
  1278.      7    ┴ttempt to open a file which is already open
  1279. .paèBYT┼-ORIENTE─ FIL┼ I/╧ WIT╚ VARIABL┼ BUFFERS:é  Iε additioε t∩ thσ ì
  1280. routine≤ ámentioneΣ previously¼ ß se⌠ oµ bytσ-orienteΣ áfilσ áI/╧ ì
  1281. routine≤ ái≤ availablσ unde≥ SYSLI┬ ┤ whicΦ permit≤ thσ áuse≥ át∩ ì
  1282. definσ áthσ ásizσ anΣ locatioε oµ thσ buffer≤ t∩ ábσ áused« á Thσ ì
  1283. routine≤ mentioneΣ abovσ al∞ usσ 12╕¡ bytσ buffers¼ and¼ oε largì
  1284. e≥ capacit∙ disδ system≤ (anΣ oε an∙ system≤ iε general)¼ i⌠ áma∙ ì
  1285. bσ morσ efficien⌠ t∩ buffe≥ morσ thaε 12╕ byte≤ a⌠ ß time« á Thi≤ ì
  1286. wil∞ ácu⌠ dowε oε disδ activit∙ anΣ leavσ morσ memor∙-baseΣ áproì
  1287. cessinτ overhead«  Thσ routine≤ describeΣ iε thi≤ sectioε are:
  1288.  
  1289.      routine        function
  1290.      FXI$OPEN       open file for input   (similar to FIn$OPEN)
  1291.      FXO$OPEN       open file for output  (similar to FOn$OPEN)
  1292.      FXI$CLOS┼      close input file      (similar to FIn$CLOSE)
  1293.      FXO$CLOSE      close output file     (similar to FOn$CLOSE)
  1294.      FX$GET         get a byte            (similar to Fn$GET)
  1295.      FX$PUT         put a byte            (similar to Fn$PUT)
  1296.  
  1297. Al∞ oµ thσ filσ extendeΣ bytσ I/╧ routine≤ (F╪ mean≤ filσ extendì
  1298. ed⌐ worδ witΦ aε I/╧ Contro∞ Blocδ whicΦ i≤ structureΣ as:
  1299.  
  1300.    block    length     user-
  1301.    offset   (bytes)    set?*       function
  1302.      0         1         Y         Number of 128-byte pages in
  1303.                                    working buffer
  1304.      1         1         N         End of file flag
  1305.      2         2         N         byte counter
  1306.      4         2         N         Next byte pointer
  1307.      6         2         Y         Address of working buffer
  1308.      8        36         Y         FCB of file (only Fn and Ft
  1309.                                    fields set by user)
  1310.  
  1311.      *"Use≥-Setó mean≤ tha⌠ yo⌡ mus⌠ initializσ thi≤ valuσ beforσ ì
  1312. áááááthesσ routine≤ arσ called.
  1313.  
  1314. Thσ áfollowinτ áDEFB/DEF╙ structurσ caε bσ useΣ áiε áthσ ácallinτ ì
  1315. prograφ t∩ implemen⌠ thσ I/╧ Contro∞ Block:
  1316. 
  1317.      IOCTL:    DEFB      8                   ; use 8 128-byte pages (1K)
  1318.                DEFS      1                   ; filled in by FXIO
  1319.                DEFS      2                   ; filled in by FXIO
  1320.                DEFS      2                   ; filled in by FXIO
  1321.                DEFW      WORK                ; address of working buffer
  1322.      IOCFCB:
  1323.                DEFS      1                   ; filled in by FXIO to 0
  1324.                DEFB      'MYFILE  '          ; filename
  1325.                DEFB      'TXT'               ; filetype
  1326.                DEFS      24                  ; filled in by FXIO
  1327.      WORK:     DEFS      128*8               ; working buffer (1K)
  1328. 
  1329. .paèAl∞ oµ thσ FXI╧ routine≤ arσ consisten⌠ iε tha⌠ D┼ alway≤ ápoint≤ ì
  1330. t∩ thσ I/╧ Contro∞ Blocδ (IOCT╠ above⌐ anΣ ┴ anΣ thσ PS╫ arσ useΣ ì
  1331. t∩ ápas≤ áflag≤ anΣ values«  ┴ samplσ prograφ bod∙ áwhicΦ áillusì
  1332. trate≤ thσ callinτ procedures:
  1333. 
  1334.                ...
  1335.      [Initialize IOCTL1 and IOCTL2, where 1 is input, 2 is output]
  1336.                ...
  1337.                LD        DE,IOCTL1
  1338.                CALL      FXI$OPEN            ; open 1 for input
  1339.                JR        Z,FNF               ; file not found error
  1340.                LD        DE,IOCTL2
  1341.                CALL      FXO$OPEN            ; open 2 for output
  1342.                JR        Z,NODIR             ; no dir space error
  1343.                ...
  1344.                ...
  1345.                LD        DE,IOCTL1
  1346.                CALL      FX$GET              ; get next input byte in A
  1347.                JR        Z,EOF               ; process EOF
  1348.                ...
  1349.                LD        DE,IOCTL2
  1350.                CALL      FX$PUT              ; put byte in A to output file
  1351.                JR        Z,WERR              ; process write error
  1352.                ...
  1353.                LD        DE,IOCTL1
  1354.                CALL      FXI$CLOSE           ; close input file
  1355.                JR        Z,FCERR             ; file close error
  1356.                LD        DE,IOCTL2
  1357.                CALL      FXO$CLOSE           ; close output file
  1358.                JR        Z,FCERR
  1359.                ...
  1360. 
  1361. Thi≤ simplσ examplσ illustrate≤ thσ flexibilit∙ oµ thσ FXI╧ árouì
  1362. tines«  A≤ man∙ file≤ a≤ desireΣ ma∙ bσ opeε fo≥ inpu⌠ o≥ output¼ ì
  1363. eacΦ áfilσ havinτ it≤ owε I/╧ Contro∞ Blocδ anΣ áworkinτ ábuffer«  ì
  1364. Thσ advantage≤ iε efficien⌠ disδ accessinτ witΦ thi≤ se⌠ oµ árouì
  1365. tine≤ ove≥ thσ previou≤ one≤ arσ notable.
  1366.  
  1367. Thσ ámajo≥ disadvantagσ oµ usinτ thesσ routine≤ i≤ tha⌠ thσ ábufì
  1368. fer≤ áarσ álarge≥ áanΣ thσ overheaΣ oµ alway≤ áensurinτ átha⌠ áD┼ ì
  1369. point≤ át∩ áthσ prope≥ I/╧ Contro∞ Blocδ beforσ eacΦ ároutinσ ái≤ ì
  1370. calleΣ i≤ present.
  1371. .paè     Routines║  FXI$OPEN ¼  FXO$OPEN
  1372.      Function║ Open file for inpu⌠ o≥ output
  1373.      Entry:    DE = address of I/O Control Block of file to open
  1374.      Exit:     A <> 0, zero flag clear (NZ) if OK
  1375.                A = 0, zero flag set (Z) if error
  1376.      Affected: AF
  1377.      Usage:    Open≤ thσ filσ specifieΣ b∙ thσ addresseΣ I/╧ Coεì
  1378. ááááááááááááááátro∞ áBlocδ fo≥ inpu⌠ o≥ output« á FXI$OPE╬ áopen≤ ì
  1379. áááááááááááááááthσ filσ iε thσ curren⌠ director∙ afte≥ initiali·ì
  1380. áááááááááááááááinτ thσ FC┬ anΣ load≤ a≤ mucΦ oµ thσ buffe≥ áspacσ ì
  1381. áááááááááááááááa≤ possiblσ witΦ datß froφ thσ file«  Iµ thσ áfilσ ì
  1382. ááááááááááááááádoe≤ áno⌠ exist¼ FXI$OPE╬ return≤ aε áerro≥ ácode«  ì
  1383. áááááááááááááááFXO$OPE╬ delete≤ thσ filσ referenceΣ b∙ thσ FC┬ iµ ì
  1384. ááááááááááááááái⌠ áexist≤ anΣ open≤ thσ referenceΣ filσ fo≥ áou⌠ì
  1385. áááááááááááááááput«  Iµ therσ i≤ n∩ director∙ spacσ remaininτ áiε ì
  1386. áááááááááááááááwhicΦ t∩ storσ thσ file'≤ entry¼ FXO$OPE╬ áreturn≤ ì
  1387. áááááááááááááááaε áerro≥ ácode«  Thσ FXI╧ standarΣ áerro≥ áreturε ì
  1388. ááááááááááááááácode≤ áarσ áused«  A=░ anΣ zer∩ flaτ áse⌠ á(Z⌐ áiµ ì
  1389. áááááááááááááááerror.
  1390.  
  1391.      Routines║  FXI$CLOSE ¼  FXO$CLOSE
  1392.      Function║ Close inpu⌠ o≥ outpu⌠ file
  1393.      Entry:    DE = address of an I/O Control Block
  1394.      Exit:     A <> 0, zero flag clear (NZ) if OK
  1395.                A = 0, zero flag set (Z) if close error
  1396.      Affected: AF
  1397.      Usage:    Close≤ áthσ áfilσ whosσ I/╧ Contro∞ Blocδ ái≤ áadì
  1398. ááááááááááááááádresseΣ b∙ DE«  FXI$CLOS┼ simpl∙ close≤ thσ áfile«  ì
  1399. áááááááááááááááFXO$CLOS┼ áflushe≤ áthσ workinτ ábuffe≥ át∩ ádisk¼ ì
  1400. áááááááááááááááfillinτ áthσ las⌠ 12╕-bytσ blocδ witΦ ^Z'≤ iµ áno⌠ ì
  1401. ááááááááááááááácompletel∙ filleΣ already¼ anΣ close≤ thσ filσ áoε ì
  1402. ááááááááááááááádisk« á Thσ FXI╧ standarΣ erro≥ returε ácode≤ áarσ ì
  1403. áááááááááááááááuseΣ áwitΦ áA=░ anΣ thσ zer∩ flaτ se⌠ á(Z⌐ áiµ áaε ì
  1404. áááááááááááááááerro≥ occured.
  1405.  
  1406.      Routine║   FX$GET
  1407.      Function║ Byte input routine
  1408.      Entry:    None
  1409.      Exit:     A = next byte from file, zero clear (NZ) if no error
  1410.                A = 0, zero flag set (Z) if read past EOF
  1411.      Affected: AF
  1412.      Usage:    Get≤ thσ nex⌠ bytσ froφ thσ filσ whosσ I/╧ Contro∞ ì
  1413. áááááááááááááááBlocδ i≤ pointeΣ t∩ b∙ DE«  Thσ correspondinτ opeε ì
  1414. áááááááááááááááfunctioε á(FXI$OPEN⌐ mus⌠ havσ beeε calleΣ ábeforσ ì
  1415. áááááááááááááááan∙ cal∞ t∩ FX$GET.
  1416.  
  1417.      Routine║   FX$PUT
  1418.      Function║ Byte output routine
  1419.      Entry:    A = byte to output to specified file
  1420.      Exit:     A = output byte, zero clear (NZ) if put OK
  1421.                A = 0, zero flag set if write error
  1422.      Affected: AF
  1423.      Usage:    Put≤ thσ specifieΣ bytσ int∩ thσ filσ speπifieΣ iε ì
  1424. áááááááááááááááthσ I/╧ Contro∞ Blocδ pointeΣ t∩ b∙ DE«  Thσ ácorì
  1425. ááááááááááááááárespondinτ opeε functioε (FXO$OPEN⌐ mus⌠ havσ beeε ìèááááááááááááááácalleΣ beforσ an∙ cal∞ t∩ FX$PUT.
  1426.  
  1427. BYT┼-ORIENTE─ FIL┼ I/╧ WIT╚ VARIABL┼ BUFFER╙ AN─ UNGET:é Iε áaddiì
  1428. tioε át∩ thσ F╪ routine≤ covereΣ iε thσ previou≤ sectioε arσ áthσ ì
  1429. F┘ routines«  Fo≥ onl∙ ß sligh⌠ increasσ iε memor∙ árequirements¼ ì
  1430. thσ F┘ prefi° routine≤ providσ thσ samσ function≤ a≤ thσ F╪ árouì
  1431. tine≤ anΣ adΣ thσ UNGE╘ function.
  1432.  
  1433. FY$UNGE╘ set≤ thσ nex⌠ characte≥ t∩ bσ returneΣ b∙ FY$GET« á Onl∙ ì
  1434. onσ characte≥ aheaΣ caε bσ set«  Thi≤ functioε i≤ extremel∙ áuseì
  1435. fu∞ iε application≤ whicΦ reaΣ anΣ parsσ aε inpu⌠ filσ iε ß ásinì
  1436. glσ ápass« á Ofteε thσ enΣ oµ ß tokeε i≤ detecteΣ onl∙ áwheε áthσ ì
  1437. characte≥ áafte≥ thσ tokeε i≤ pickeΣ u≡ anΣ áexamined« á FY$UNGE╘ ì
  1438. allow≤ áyo⌡ t∩ pu⌠ thi≤ characte≥ back¼ s∩ tha⌠ thσ ánex⌠ áFY$GE╘ ì
  1439. pick≤ ái⌠ áu≡ anΣ caε proces≤ i⌠ iε it≤ owε righ⌠ a≤ áopposeΣ át∩ ì
  1440. beinτ ß par⌠ oµ thσ tokeε processinτ routine.
  1441.  
  1442. Asidσ froφ thσ ne≈ FY$UNGE╘ function¼ F┘ prefi° routine≤ áprovidσ ì
  1443. thσ ásamσ function≤ a≤ thσ F╪ prefi° routines«  Thσ áI/╧ áContro∞ ì
  1444. Blocδ fo≥ thσ F┘ routines¼ however¼ i≤ tw∩ byte≤ large≥ thaε áthσ ì
  1445. IOC┬ fo≥ thσ F╪ routines«  Thσ routine≤ describeΣ iε thi≤ sectioε ì
  1446. are:
  1447.  
  1448.      routine        similar to     function
  1449.      FYI$OPEN       FXI$OPEN       open file for input
  1450.      FYO$OPEN       FXO$OPEN       open file for output
  1451.      FYI$CLOSE      FXI$CLOSE      close input file
  1452.      FYO$CLOSE      FXO$CLOSE      close output file
  1453.      FY$GET         FX$GET         get byte
  1454.      FY$UNGET                      unget byte
  1455.      FY$PUT         FX$PUT         put byte
  1456.  
  1457. Al∞ oµ thσ filσ extendeΣ bytσ I/╧ routine≤ (F┘ mean≤ filσ extendì
  1458. eΣ beyonΣ FX⌐ worδ witΦ aε I/╧ Contro∞ Blocδ structureΣ as:
  1459.  
  1460.   block     length     user-
  1461.   offset    (bytes)    set?*       function
  1462.      0         1         Y         Number of 128-byte pages in
  1463.                                    working buffer
  1464.      1         1         N         End of file flag
  1465.      2         2         N         Byte counter
  1466.      4         2         N         Next byte pointer
  1467.      6         1         N         Character pending flag
  1468.      7         1         N         Pending character
  1469.      8         2         Y         Address of working buffer
  1470.     10        36         Y         FCB of file (only Fn and Ft
  1471.                                    fields set by user)
  1472.  
  1473.      *"use≥-setó mean≤ tha⌠ yo⌡ mus⌠ initializσ thi≤ valuσ beforσ ì
  1474. áááááthesσ routine≤ arσ called.
  1475. .paèThσ áfollowinτ áDEFB/DEF╙ structurσ caε bσ useΣ áiε áthσ ácallinτ ì
  1476. prograφ t∩ implemen⌠ thσ I/╧ Contro∞ Block:
  1477. 
  1478.      IOCTL:    DEFB      ╕                   ; use 8 128-byte pages (1K)
  1479.                DEFS      7                   ; filled in by FYIO
  1480.                DEF╫      WOR╦                ╗ addres≤ oµ workinτ buffer
  1481.      IOCFCB:
  1482.                DEFS      1                   ; filled in by FYIO to 0
  1483.                DEFB      'MYFILE  '          ; filename
  1484.                DEFB      'TXT'               ; filetype
  1485.                DEFS      24                  ; filled in by FYIO
  1486.      WORK:     DEFS      128*8               ; working buffer (1K)
  1487. 
  1488. Al∞ oµ thσ FYI╧ routine≤ arσ consisten⌠ iε tha⌠ D┼ alway≤ ápoint≤ ì
  1489. t∩ thσ I/╧ Contro∞ Blocδ (IOCT╠ above⌐ anΣ ┴ anΣ thσ PS╫ arσ useΣ ì
  1490. t∩ ápas≤ áflag≤ anΣ values«  ┴ samplσ prograφ bod∙ áwhicΦ áillusì
  1491. trate≤ thσ callinτ procedures:
  1492. 
  1493.                ...
  1494.      [Initialize IOCTL1 and IOCTL2, where 1 is input, 2 is output]
  1495.                ...
  1496.                LD        D,IOCTL1
  1497.                CALL      FYI$OPEN            ; open 1 for input
  1498.                J╥        Z,FN╞               ╗ ..jum≡ iµ filσ no⌠ found err
  1499.                LD        D,IOCTL2
  1500.                CALL      FYO$OPEN            ; open 2 for output
  1501.                JR        Z,NODIR             ; ..jump if no dir space error
  1502.                ...
  1503.                ...
  1504.                LD        D,IOCTL1
  1505.                CALL      FY$GET              ; get next input byte in A
  1506.                JR        Z,EOF               ; ..jump to process EOF
  1507.                ...
  1508.                LD        D,IOCTL1
  1509.                LD        A,CH                ; unget character CH
  1510.                CALL      FY$UNGET
  1511.                ...
  1512.                LD        D,IOCTL2
  1513.                CALL      FY$PUT              ; put byte in A to output file
  1514.                JR        Z,WERR              ; ..jump to process write error
  1515.                ...
  1516.                LD        D,IOCTL1
  1517.                CALL      FYI$CLOSE           ; close input file
  1518.                JR        Z,FCERR             ; ..jump if file close error
  1519.                LD        D,IOCTL2
  1520.                CALL      FYO$CLOSE           ; close output file
  1521.                JR        Z,FCERR             ; ..jump if error
  1522.                ...
  1523. 
  1524. Thi≤ simplσ examplσ illustrate≤ thσ flexibilit∙ oµ thσ FYI╧ árouì
  1525. tines«  A≤ man∙ file≤ a≤ desireΣ ma∙ bσ opeε fo≥ inpu⌠ o≥ output¼ ì
  1526. eacΦ áfilσ havinτ it≤ owε I/╧ Contro∞ Blocδ anΣ áworkinτ ábuffer«  ì
  1527. Thσ advantage≤ iε efficien⌠ disδ accessinτ witΦ thi≤ se⌠ oµ árouì
  1528. tine≤ ove≥ thσ previou≤ one≤ arσ notable.
  1529. èThσ ámajo≥ disadvantagσ oµ usinτ thesσ routine≤ i≤ tha⌠ thσ ábufì
  1530. fer≤ áarσ álarge≥ áanΣ thσ overheaΣ oµ alway≤ áensurinτ átha⌠ áD┼ ì
  1531. point≤ át∩ áthσ prope≥ I/╧ Contro∞ Blocδ beforσ eacΦ ároutinσ ái≤ ì
  1532. calleΣ i≤ present.
  1533.  
  1534.      Routines║  FYI$OPEN ,  FYO$OPEN
  1535.      Function║ FYIO filσ open routines
  1536.      Entry:    DE = pointer to I/O Control Block of file to open
  1537.      Exit:     A <> 0, zero flag clear (NZ) if OK
  1538.                A = 0, zero flag set (Z) if error
  1539.      Affected: AF
  1540.      Usage:    Open≤ file≤ fo≥ subsσquen⌠ processinτ b∙ othe≥ F┘-ì
  1541. áááááááááááááááprefi° ároutines«  FYI$OPE╬ open≤ thσ filσ iε áthσ ì
  1542. ááááááááááááááácurren⌠ ádirector∙ afte≥ initializinτ thσ FC┬ áanΣ ì
  1543. áááááááááááááááload≤ a≤ mucΦ oµ thσ buffe≥ spacσ a≤ possiblσ witΦ ì
  1544. ááááááááááááááádatß áfroφ thσ file«  Iµ thσ filσ doe≤ no⌠ áexist¼ ì
  1545. áááááááááááááááFYI$OPE╬ rσturn≤ aε erro≥ code«  FYO$OPE╬ ádelete≤ ì
  1546. áááááááááááááááthσ áfilσ referenceΣ b∙ thσ FC┬ iµ i⌠ áexist≤ áanΣ ì
  1547. áááááááááááááááopen≤ thσ referenceΣ filσ fo≥ output«  Iµ therσ i≤ ì
  1548. ááááááááááááááán∩ direπtor∙ spacσ remaininτ iε whicΦ t∩ storσ thσ ì
  1549. áááááááááááááááfile'≤ entry¼ FYO$OPE╬ return≤ aε erro≥ code.
  1550.  
  1551.      Routine║   FYI$CLOSE ,  FYO$CLOSE
  1552.      Function║ FYIO file close routines
  1553.      Entry:    DE = pointer to I/O Control Block
  1554.      Exit:     A <> 0, zero flag clear (NZ) if OK
  1555.                A = 0, zero flag set (Z) if close error
  1556.      Affected: AF
  1557.      Usage:    Close≤ áfile≤ openeΣ b∙ thσ árespectivσ áF┘-prefi° ì
  1558. áááááááááááááááopeε routines«  FYI$CLOS┼ simpl∙ close≤ thσ áfile«  ì
  1559. áááááááááááááááFYO$CLOS┼ áflushe≤ áthσ workinτ ábuffe≥ át∩ ádisk¼ ì
  1560. áááááááááááááááfillinτ thσ las⌠ 12╕-bytσ blocδ witΦ ^┌ character≤ ì
  1561. áááááááááááááááiµ áno⌠ completel∙ filleΣ already¼ anΣ close≤ áthσ ì
  1562. áááááááááááááááfile.
  1563.  
  1564.      Routine║   FY$GET
  1565.      Function║ FYIO bytσ inpu⌠ routine
  1566.      Entry:    None
  1567.      Exit:     A = next byte, zero clear (NZ) if no error
  1568.                A = 0, zero flag set (Z) if past EOF
  1569.      Affected: AF
  1570.      Usage:    Read≤ thσ content≤ oµ file≤ openeΣ b∙ áa≡propriatσ ì
  1571. áááááááááááááááF┘ opeε routines«  FY$GE╘ get≤ thσ nex⌠ bytσ áfroφ ì
  1572. áááááááááááááááthσ áspecifieΣ áfile« á FYI$OPE╬ ámus⌠ áhavσ ábeeε ì
  1573. ááááááááááááááácalleΣ beforσ an∙ cal∞ t∩ FY$GET.
  1574.  
  1575.      Routine║   FY$UNGET
  1576.      Function║ FYIO bytσ unge⌠ routine
  1577.      Entry:    A = byte to "Unget"
  1578.      Exit:     A = character, zero flag clear (NZ) if OK
  1579.                A = character, zero set (Z) if byte pending already
  1580.      Affected: AF
  1581.      Usage:    Set≤ áthσ ánex⌠ ábytσ t∩ bσ áreturneΣ áb∙ áFY$GET«  ì
  1582. áááááááááááááááFY$UNGE╘ áma∙ onl∙ bσ calleΣ oncσ beforσ thσ ánex⌠ ì
  1583. áááááááááááááááFY$GET¼ sincσ i⌠ work≤ onl∙ onσ bytσ ahead«  Iµ áß ìèááááááááááááááábytσ áwa≤ áalread∙ pending¼ áFY$UNGE╘ áreturn≤ áaε ì
  1584. áááááááááááááááerro≥ ácodσ áwitΦ n∩ UNGE╘ function« á ┴ ácal∞ át∩ ì
  1585. áááááááááááááááFYI$OPE╬ i≤ requireΣ beforσ FY$UNGE╘ caε bσ used.
  1586.  
  1587.      Routine║   FY$PUT
  1588.      Function║ FYIO bytσ output routine
  1589.      Entry:    A = byte to output
  1590.      Exit:     A = character, zero flag clear (NZ) if OK
  1591.                A = 0, zero flag set (Z) if write error
  1592.      Affected: AF
  1593.      Usage:    Change≤ thσ content≤ oµ file≤ openeΣ b∙ áappropriì
  1594. áááááááááááááááatσ áF┘ opeε routines«  FY$PU╘ put≤ thσ nex⌠ ábytσ ì
  1595. áááááááááááááááint∩ thσ specifieΣ file«  FYO$OPE╬ mus⌠ havσ ábeeε ì
  1596. ááááááááááááááácalleΣ beforσ an∙ cal∞ t∩ FY$PUT.
  1597.  
  1598. GENERA╠ áPURPOS┼ CP/═ FIL┼ MANIPULATIO╬ ROUTINES:é áThσ áfollowinτ ì
  1599. routine≤ arσ genera∞-purposσ filσ I/╧ routine≤ whicΦ interfacσ t∩ ì
  1600. CP/═ áthrougΦ thσ entr∙ poin⌠ a⌠ locatioε 5«  The∙ ápreservσ áBC¼ ì
  1601. DE¼ anΣ HL¼ anΣ returε witΦ thσ standarΣ CP/═ erro≥ code≤ fo≥ thσ ì
  1602. correspondinτ routines«  Thesσ routine≤ are:
  1603.  
  1604.      F$CLOS┼        F$MAK┼         F$REA─         F$WRITE
  1605.      F$DELET┼       F$MOPE╬        F$RENAM┼       R$READ
  1606.      F$EXIS╘        F$OPE╬         F$SIZ┼         R$WRITE
  1607.  
  1608. Thσ ároutine≤ GFA¼ SCFA¼ anΣ SF┴ al∞ dea∞ witΦ gettinτ (GFA⌐ áanΣ ì
  1609. settinτ á(SCF┴ áanΣ SFA⌐ thσ attribute≤ oµ file≤ whosσ áFCB≤ áarσ ì
  1610. addresseΣ b∙ DE.
  1611.  
  1612. Thσ followinτ file≤ allo≈ yo⌡ t∩ appenΣ t∩ thσ enΣ oµ aε existinτ ì
  1613. filσ conveniently«  The∙ returε uniquσ erro≥ codes.
  1614.  
  1615.      F$APPEN─       GETR╥          GETFS
  1616.      F$APPL         GETRR1         GETFS1
  1617.  
  1618.      Routine║   F$CLOSE
  1619.      Function║ Close a file
  1620.      Entry:    DE = points to FCB for desired file
  1621.      Exit:     A = 0, ·ero flag set (Z) if close OK
  1622.                A <> 0, zero clear (NZ) if error in closing
  1623.      Affected: AF
  1624.      Usage:    Close≤ áß specifieΣ filσ iε thσ curren⌠ drivσ áanΣ ì
  1625. áááááááááááááááuse≥ area.
  1626.  
  1627.      Routine║   F$DELETE
  1628.      Function║ Delete a file
  1629.      Entry:    DE = points to FCB for file to delete
  1630.      Exit:     A = 0, zero flag set (Z) if delete OK
  1631.                A <> 0, zero clear (NZ) if file not found
  1632.      Affected: AF
  1633.      Usage:    Delete≤ áß specifieΣ filσ froφ curren⌠ ádrivσ áanΣ ì
  1634. áááááááááááááááuse≥ area.
  1635. .paè     Routine║   F$EXIST
  1636.      Function║ Test for existence of a file
  1637.      Entry:    DE = address of an FCB for file to test
  1638.      Exit:     A <> 0, zero flag clear (NZ) if file exists
  1639.                A = 0, zero flag set (Z) if file not found
  1640.      Affected: AF
  1641.      Usage:    Test≤ fo≥ thσ presencσ oµ ß specifieΣ filσ iε áthσ ì
  1642. ááááááááááááááácurren⌠ ádisδ anΣ use≥ area«  Statu≤ ái≤ áreturneΣ ì
  1643. áááááááááááááááshowinτ thσ result≤ oµ thσ search.
  1644.  
  1645.      Routine║   F$MAKE
  1646.      Function║ Create a file
  1647.      Entry:    DE = points to an FCB for the desired file
  1648.      Exit:     A = directory code [0..3] if file i≤ created OK
  1649.                A = 0FFh if no directory space i≤ available
  1650.      Affected: AF
  1651.      Usage:    Create≤ á(makes⌐ ß specifieΣ filσ iε áthσ ácurren⌠ ì
  1652. ááááááááááááááádrivσ anΣ use≥ area.
  1653.  
  1654.      Routine║   F$OPEN
  1655.      Function║ Open a file
  1656.      Entry:    DE = pointer to FCB for desired file
  1657.      Exit:     A = 0, zero flag set (Z) if file opened OK
  1658.                A <> 0, zero flag clear (NZ) if not opened
  1659.      Affected: AF
  1660.      Usage:    Open≤ áß specifieΣ filσ iε thσ curren⌠ ádrivσ áanΣ ì
  1661. áááááááááááááááuse≥ area.
  1662.  
  1663.      Routine║   F$MOPEN
  1664.      Function║ Open a file with creation
  1665.      Entry:    DE = pointer to FCB for file to open
  1666.      Exit:     A = 0, zero flag set (Z) if file opened OK
  1667.                A <> 0, zero clear (NZ) if no directory space (error)
  1668.      Affected: AF
  1669.      Usage:    Open≤ ß specifieΣ file«  Iµ thσ filσ i≤ no⌠ found¼ ì
  1670. áááááááááááááááF$MOPE╬ trie≤ t∩ creatσ one«  Thi≤ routinσ áshoulΣ ì
  1671. áááááááááááááááno⌠ bσ useΣ a≤ ß substitutσ fo≥ existencσ átestinτ ì
  1672. áááááááááááááááwitΦ F$EXIST.
  1673.  
  1674.      Routine║   F$APPEND
  1675.      Function║ Append to a file
  1676.      Entry:    DE = pointer to an FCB for the desired file
  1677.      Exit:     A = 0, zero flag set (Z) if file opened OK
  1678.                A = error code, zero flag clear (NZ) if error is:
  1679.                     1 ╜ file not found
  1680.                     2 = file is full (no more room)
  1681.                     3 = file found but empty
  1682.      Affected: AF¼ current DMA buffer has last file record if A=0
  1683.      Usage:    Open≤ áß filσ fo≥ appending«  Thσ result≤ áoµ áthσ ì
  1684. áááááááááááááááoperatioε arσ reported«  Variou≤  erro≥ condΘtion≤ ì
  1685. ááááááááááááááácaε áoccur¼ anΣ arσ reported«  Erro≥ │ i≤ áß ánotσ ì
  1686. ááááááááááááááátha⌠ thσ filσ i≤ empt∙ anΣ i≤ no⌠ fata∞ á(pr∩cessì
  1687. áááááááááááááááinτ ácaε continue)«  Iµ thσ appenΣ i≤ ásucces≤ful¼ ì
  1688. áááááááááááááááthσ curren⌠ DM┴ buffe≥ contain≤ thσ las⌠ recorΣ iε ì
  1689. áááááááááááááááthσ file«  Thσ nex⌠ sequentia∞ writσ wil∞ writσ t∩ ìèáááááááááááááááthσ árecorΣ afte≥ thσ las⌠ onσ iε thσ file« á (Seσ ì
  1690. áááááááááááááááF$APP╠ whicΦ start≤ writinτ oε thσ las⌠ recorΣ áoµ ì
  1691. áááááááááááááááthσ file).
  1692.      Example║  Seσ F$APP╠ below.
  1693.  
  1694.      Routine║   F$APPL
  1695.      Function║ AppenΣ t∩ ß file
  1696.      Entry:    DE = pointer to FCB for desired file
  1697.      Exit:     A = 0, zero flag set (Z) if file opened OK
  1698.                A = error code, zero flag clear (NZ) if error
  1699.                     1 = file not found
  1700.                     2 = file is full (no more room)
  1701.                     3 = file found but empty
  1702.      Affected: AF¼ current DMA buffer has last record if A=0
  1703.      Usage:    Open≤ áß filσ fo≥ appending«  Thσ result≤ áoµ áthσ ì
  1704. áááááááááááááááoperatioε arσ reported«  Variou≤  erro≥ condΘtion≤ ì
  1705. ááááááááááááááácaε áoccur¼ anΣ arσ reported«  Erro≥ │ i≤ áß ánotσ ì
  1706. ááááááááááááááátha⌠ thσ filσ i≤ empt∙ anΣ i≤ no⌠ fata∞ á(pr∩cessì
  1707. áááááááááááááááinτ caε continue)«  Iµ thσ APP╠ i≤ successful¼ thσ ì
  1708. ááááááááááááááálas⌠ árecorΣ áiε thσ filσ i≤ iε áthσ ácurren⌠ áDM┴ ì
  1709. ááááááááááááááábuffer«  Thσ nex⌠ sequentia∞ writσ (F$WRITE⌐ áwil∞ ì
  1710. áááááááááááááááwritσ bacδ ove≥ thσ las⌠ recorΣ iε thσ file.
  1711.      Example:  Thσ followinτ codσ segmen⌠ illustrate≤ thσ intendì
  1712. áááááááááááááááeΣ usagσ fo≥ thσ tw∩ filσ appenΣ routines.
  1713.                  With F$APPEND:            With F$APPL:
  1714.                          ...                            ...
  1715.                          LD    DE,FCB                   L─    DE,FCB
  1716.                          CALL  F$APPEND                 CALL  F$APPL
  1717.                          ...                            ...
  1718.                 [Preparσ nex⌠ record▌           [Modif∙ las⌠ record]
  1719.                          ...                            ...
  1720.                          LD    DE,FCB                   LD    DE,FCB
  1721.                          CALL  F$WRITE ╗ after last     CALL  F$WRITE ; on last
  1722.                          ...                            ...
  1723.                          LD    DE,FCB                   LD    DE,FCB
  1724.                          CALL  F$CLOSE ╗ close file     CALL  F$CLOSE ; close
  1725.                          ...                            ...
  1726.  
  1727.      Routine║   F$READ
  1728.      Function║ Read a block from a file
  1729.      Entry:    DE = pointer to FCB for desired file
  1730.      Exit:     A = 0, zero flag set (Z) if read OK
  1731.                A = error code, zero flag clear (NZ) if error
  1732.                     1 ╜ read past end of file
  1733.                     2 ╜ reading unwritten data in random access
  1734.      Usage:    Read≤ áthσ nex⌠ blocδ (12╕ bytes⌐ oµ datß froφ áaε ì
  1735. áááááááááááááááopeε filσ iε thσ curren⌠ drivσ anΣ use≥ area«  Thσ ì
  1736. ááááááááááááááádatß i≤ loadeΣ int∩ thσ curren⌠ DM┴ buffer.
  1737. .paè     Routine║   F$RENAME
  1738.      Function║ Rename a file
  1739.      Entry:    HL = pointer to first 12 bytes of new FCB
  1740.                DE = pointer to first 12 bytes of old FCB
  1741.      Exit:     A <> 0, zero flag clear (NZ) if rename OK
  1742.                A = 0, zero flag set (Z) if file not found error
  1743.      Affected: AF
  1744.      Usage:    Rename≤ ß filσ iε thσ curren⌠ drivσ anΣ use≥ area«  ì
  1745. áááááááááááááááOnl∙ áthσ Fε anΣ F⌠ field≤ arσ signifΘcan⌠ iε áthσ ì
  1746. áááááááááááááááFCB's¼ s∩ thσ res⌠ oµ thσ FC┬ neeΣ no⌠ bσ ápresen⌠ ì
  1747. áááááááááááááááfo≥ thi≤ functioε t∩ work.
  1748.  
  1749.      Routine║   F$SIZE
  1750.      Function║ Compute file size
  1751.      Entry:    DE = pointer to the 1st 12 bytes of an FCB
  1752.      Exit:     HL = file size in kilobytes
  1753.      Affected: AF
  1754.      Usage:    Obtain≤ áthσ computeΣ sizσ oµ ß filσ (iε K⌐ ábaseΣ ì
  1755. áááááááááááááááoε it≤ recorΣ count«  Thi≤ routinσ give≤ thσ áfilσ ì
  1756. ááááááááááááááásizσ ácorrec⌠ át∩ thσ nex⌠ 1K¼ bu⌠ doe≤ áno⌠ átakσ ì
  1757. áááááááááááááááint∩ accoun⌠ thσ groupinτ factor.
  1758.  
  1759.      Routine║   F$WRITE
  1760.      Function║ Write a block to a file
  1761.      Entry:    DE = pointer to FCB for open file
  1762.      Exit:     A = 0, zero flag set (Z) if write OK
  1763.                A = error code, zero clear (NZ) if error
  1764.                     1 = error in extending file
  1765.                     2 = end of disk data
  1766.                     0FFh ╜ no more directory space
  1767.      Affected: AF
  1768.      Usage:    Writσ áthσ ánex⌠ 12╕ bytσ blocδ oµ datß áfroφ áthσ ì
  1769. ááááááááááááááácurren⌠ DM┴ buffe≥ t∩ ß specifieΣ opeε filσ iε thσ ì
  1770. ááááááááááááááácurren⌠ drivσ anΣ use≥ area.
  1771.  
  1772.      Routines║  GETRR ,  GETRR1
  1773.      Function║ Get random record number
  1774.      Entry:    DE = pointer to FCB
  1775.      Exit:     HL = random record number
  1776.                A = 0, zero flag set (Z) if no error
  1777.                ┴ á<╛ á0¼ zer∩ flaτ clea≥ (NZ⌐ áiµ árandoφ árecorΣ ì
  1778. áááááááááááááááoverflo≈ (valuσ iε ┴ i≤ erro≥ code)
  1779.      Affected: AF¼ HL
  1780.      Usage:    Returε thσ randoφ recorΣ numbe≥ oµ thσ las⌠ recorΣ ì
  1781. áááááááááááááááreaΣ áo≥ writteε sequentiall∙ froφ áthσ áspecifieΣ ì
  1782. áááááááááááááááfile«  Thesσ routine≤ arσ convenien⌠ iε ádetermiεì
  1783. áááááááááááááááinτ áthσ curren⌠ positioε iε ß file« á GETR╥ ádoe≤ ì
  1784. áááááááááááááááno⌠ áaffec⌠ thσ randoφ recorΣ numbe≥ fielΣ oµ áthσ ì
  1785. áááááááááááááááFC┬ anΣ i≤ large≥ iε size«  GETRR▒ i≤ smaller¼ bu⌠ ì
  1786. ááááááááááááááádoesô affec⌠ thσ randoφ recorΣ numbe≥ fielΣ oµ áthσ ì
  1787. áááááááááááááááFCB.
  1788. .paè     Routines║  GETFS ,  GETFS1
  1789.      Function║ Get file size in records
  1790.      Entry:    DE = pointer to FCB
  1791.      Exit:     HL = number of records in file (file size)
  1792.                A = 0, zero flag set (Z) if no error
  1793.                ┴ á<╛ á0¼ zer∩ flaτ clea≥ (NZ⌐ áiµ árandoφ árecorΣ ì
  1794. áááááááááááááááoverflo≈ (valuσ iε ┴ i≤ erro≥ code)
  1795.      Affected: AF¼ HL
  1796.      Usage:    Returε thσ filσ sizσ (iε term≤ oµ records⌐ oµ áthσ ì
  1797. áááááááááááááááfilσ áwhosσ FC┬ i≤ pointeΣ t∩ b∙ DE« á Thesσ áro⌡ì
  1798. ááááááááááááááátine≤ arσ convenien⌠ iε determininτ thσ numbe≥ áoµ ì
  1799. ááááááááááááááárecord≤ áiε áß file«  GETF╙ doe≤ áno⌠ áaffec⌠ áthσ ì
  1800. ááááááááááááááárandoφ recorΣ numbe≥ fielΣ oµ thσ FC┬ anΣ i≤ larτì
  1801. áááááááááááááááe≥ áiε size«  GETFS▒ i≤ smaller¼ bu⌠ ádoe≤ áaffec⌠ ì
  1802. áááááááááááááááthσ randoφ recorΣ numbe≥ fielΣ oµ thσ FCB.
  1803.  
  1804.      Routine║   GFA
  1805.      Function║ Get file attributes
  1806.      Entry:    DE = pointer to FCB
  1807.      Exit:     A = attribute code
  1808.                     b0 = read-only attribute (1 = R/O, 0 = R/W)
  1809.                     b7 = system attribute (1 = SYS, 0 = DIR)
  1810.      Affected: AF
  1811.      Usage:    Return≤ áthσ attribute≤ oµ thσ filσ whosσ áFC┬ ái≤ ì
  1812. ááááááááááááááápointeΣ át∩ b∙ DE«  Oε return¼ ┴ contain≤ áß ácodσ ì
  1813. áááááááááááááááindicatinτ áthσ R/╧ anΣ SY╙ attributes¼ wherσ áthσ ì
  1814. ááááááááááááááá8tΦ ábi⌠ áoµ ┴ (b7⌐ i≤ ▒ iµ thσ filσ i≤ áß ásysteφ ì
  1815. áááááááááááááááfilσ anΣ ░ iµ thσ filσ i≤ ß director∙ (noε-system⌐ ì
  1816. áááááááááááááááfilσ anΣ thσ 1s⌠ bi⌠ oµ ┴ (b0⌐ i≤ ▒ iµ thσ filσ i≤ ì
  1817. áááááááááááááááread/onl∙ áanΣ ░ iµ thσ filσ i≤ read/write«  A≤ áß ì
  1818. ááááááááááááááásidσ effect¼ thσ MSB≤ oµ al∞ byte≤ iε thσ filenamσ ì
  1819. áááááááááááááááanΣ filetypσ field≤ oµ thσ origina∞ FC┬ (byte≤ á▒-ì
  1820. ááááááááááááááá11¼ áwherσ bytσ ░ i≤ first⌐ arσ se⌠ equa∞ át∩ áthσ ì
  1821. áááááááááááááááMSB≤ oµ thσ correspondinτ director∙ entry.
  1822.  
  1823.      Routine║   R$READ
  1824.      Function║ Random read a block from a file
  1825.      Entry:    DE = pointer to FCB
  1826.                HL = random record number
  1827.      Exit:     A = 0, zero flag set (Z) if no error
  1828.                A = error code, zero clear (NZ) if error where:
  1829.                     1 ╜ attempt to read unwritten record
  1830.                     3 ╜ CP/M could not close current extent
  1831.                     4 ╜ attempt to read unwritten extent
  1832.                     6 ╜ attempt to read beyond end of disk
  1833.      Affected: AF
  1834.      Usage:    Read≤ áß blocδ froφ thσ specifieΣ filσ áiε árandoφ ì
  1835. ááááááááááááááámode« á I⌠ ái≤ assumeΣ tha⌠ thσ filσ áha≤ áalread∙ ì
  1836. ááááááááááááááábeeε openeΣ b∙ thσ F$OPE╬ routinσ o≥ equΘvalent.
  1837. .paè     Routine║   R$WRITE
  1838.      Function║ Random write of a block to a file
  1839.      Entry:    DE = pointer to FCB
  1840.                HL = random record number
  1841.      Exit:     A = 0, zero flag set (Z) if no error
  1842.                A = error code, zero flag clear (NZ) if error:
  1843.                     0 ╜ no error (Z flag set)
  1844.                     1 ╜ attempt to read unwritten record
  1845.                     3 ╜ CP/M could not close current extent
  1846.                     4 ╜ attempt to read unwritten extent
  1847.                     5 ╜ directory full
  1848.                     6 ╜ attempt to read beyond end of disk
  1849.      Affected: AF
  1850.      Usage:    Write≤ ádatß áa⌠ thσ curren⌠ DM┴ positioε át∩ áthσ ì
  1851. ááááááááááááááádesignateΣ filσ iε ß specifiπ recorΣ number«  Thi≤ ì
  1852. áááááááááááááááfilσ shoulΣ havσ beeε previousl∙ openeΣ b∙ ß ácal∞ ì
  1853. ááááááááááááááát∩ F$OPE╬ o≥ equivalent.
  1854.  
  1855.      Routine║   SCFA
  1856.      Function║ Set and clear file attributes
  1857.      Entry:    DE = pointer to FCB
  1858.                A = attribute code:
  1859.                     b0 = read-only (1=set to R/O, 0=set to R/W)
  1860.                     b7 = system (1=set to SYS, 0=set to DIR)
  1861.      Exit:     A = 0, zero flag set (Z) if operation OK
  1862.                A <> 0, zero clear (NZ) if ambiguous filσ o≥ not found
  1863.      Affected: AF
  1864.      Usage:    Set≤ o≥ clear≤ reaΣ-onl∙ anΣ systeφ attribute≤ áoµ ì
  1865. áááááááááááááááthσ specifieΣ filσ anΣ clea≥ al∞ othe≥ áattribute≤ ì
  1866. ááááááááááááááát∩ ░ (thσ MSB≤ oµ byte≤ ▒-╕ anΣ 1▒ arσ se⌠ t∩ á0)«  ì
  1867. áááááááááááááááBit≤ ░ anΣ ╖ oµ thσ ┴ registe≥ arσ se⌠ t∩ ásignif∙ ì
  1868. áááááááááááááááho≈ thσ reaΣ-onl∙ anΣ systeφ bit≤ arσ t∩ bσ se⌠ iε ì
  1869. áááááááááááááááthσ file«  Al∞ attributσ bit≤ othe≥ theε reaΣ-onl∙ ì
  1870. áááááááááááááááanΣ systeφ arσ cleareΣ t∩ zero.
  1871.  
  1872.      Routine║   SFA
  1873.      Function║ Set file attributes
  1874.      Entry:    DE = pointer to FCB
  1875.                A = attribute code:
  1876.                     b0 = read-only (1 = set to R/O, 0 = set to R/W)
  1877.                     b7 = system (1 = set t∩ SYS, 0 = set DIR)
  1878.      Exit:     A = 0, zero flag set (Z) if operation OK
  1879.                A <> 0, zero clear (NZ) if ambiguous filσ o≥ not found
  1880.      Affected: AF
  1881.      Usage:    Set≤ o≥ clear≤ thσ reaΣ-onl∙ and/o≥ systeφ áattriì
  1882. ááááááááááááááábute≤ áoµ thσ specifieΣ filσ whilσ áno⌠ áaffec⌠inτ ì
  1883. áááááááááááááááthσ othe≥ attributσ bit≤ (byte≤ ▒-11¼ wherσ bytσ ░ ì
  1884. ááááááááááááááái≤ áfirst)«  Al∞ attribute≤ iε thσ FC┬ arσ se⌠ át∩ ì
  1885. áááááááááááááááthosσ oµ thσ director∙ entr∙ excep⌠ fo≥ áreaΣ-onl∙ ì
  1886. áááááááááááááááanΣ system.
  1887. .paèLIBRAR┘ FIL┼ MANIPULATION:é  Librarie≤ arσ ß methoΣ oµ combininτ ß ì
  1888. numbe≥ oµ file≤ int∩ ß singlσ filσ iε sucΦ ß wa∙ tha⌠ eacΦ membe≥ ì
  1889. filσ ácaε ábσ discretel∙ accessed«  Advantage≤ oµ álibrarie≤ áarσ ì
  1890. tha⌠ áonl∙ onσ director∙ entr∙ i≤ needeΣ fo≥ thσ álibrar∙ árathe≥ ì
  1891. thaε onσ fo≥ eacΦ file¼ anΣ onl∙ ß maximuφ oµ 12╖ byte≤ pe≥ áfilσ ì
  1892. i≤ áwasteΣ ácompareΣ t∩ severa∞ thousanΣ byte≤ wasteΣ áfo≥ ásmal∞ ì
  1893. file≤ oε largσ harΣ disks.
  1894.  
  1895. Thesσ ároutine≤ providσ ß standarΣ wa∙ t∩ acces≤ file≤ ácontaineΣ ì
  1896. iε libraries«  Acces≤ t∩ librar∙ file≤ i≤ viß ß librar∙ utility
  1897. descriptor which is a block of memory organized as:
  1898.      LUD║      DEFS      2         ; length of lbr directory (set by LUxx)
  1899.                DEFS      2         ; next block of curr file (set by LUxx)
  1900.                DEFS      2         ; # of remaining blks in file (by LUxx)
  1901.      LUFIL:    DEFS      11        ; name of current file (set by LUOPEN)
  1902.      LUFCB:    DEFS      36        ; FCB of library (Fn.Ft set by user)
  1903.  
  1904. Multiple Libraries may be accessed by using several LUD's.
  1905.  
  1906.      Routine║   LUINIT
  1907.      Function║ Initialize file for library file manipulation
  1908.      Entry:    D┼ á╜ pointe≥ t∩ aε LU─ containinτ FC┬ áanΣ áothe≥ ì
  1909. áááááááááááááááinf∩ áDrivσ áanΣ use≥ oµ librar∙ mus⌠ áalread∙ ábσ ì
  1910. áááááááááááááááset.
  1911.      Exit:     A = 0, zero flag set (Z) if no error
  1912.                A = error code, zero reset (NZ) if error is:
  1913.                     1 = file not found
  1914.                     2 = file empty
  1915.                     3 = library file format error
  1916.      Affected: AF¼ DMA address is set to 80hH by this routine
  1917.      Usage:    Mus⌠ ábσ calleΣ fo≥ eacΦ LU─ beforσ i⌠ i≤ useΣ át∩ ì
  1918. áááááááááááááááacces≤ an∙ oµ thσ othe≥ routine≤ iε thi≤ ásection«  ì
  1919. áááááááááááááááYo⌡ mus⌠ insurσ tha⌠ byte≤ ▒-1▒ iε thσ FC┬ sectioε ì
  1920. áááááááááááááááoµ áthσ LU─ arσ se⌠ witΦ thσ desireΣ librar∙ ánamσ ì
  1921. áááááááááááááááanΣ typσ beforσ callinτ LUINIT.
  1922.  
  1923.      Routine║   LUDIR
  1924.      Function║ Return directory list for library
  1925.      Entry:    DE = address of a library utility descriptor (LUD)
  1926.                HL = address of ambiguous 11-char filename and type
  1927.                BC = pointer to start of memory buffer
  1928.                Drivσ anΣ use≥ oµ librar∙ mus⌠ alread∙ bσ set.
  1929.      Exit:     A = 0, zero flag set (Z) if operation OK
  1930.                A <> 0, zero flag reset (NZ) if TPA overflow
  1931.      Affected: AF¼ DMA address is set to 80h by this routine
  1932.      Usage:    Locate≤ áal∞ file≤ iε ß librar∙ matchinτ ß áspeciì
  1933. áááááááááááááááfieΣ ambiguou≤ o≥ noε-ambiguou≤ filenamσ anΣ type«  ì
  1934. áááááááááááááááIµ áal∞ questioε mark≤ o≥ space≤ arσ specΘfied¼ áß ì
  1935. áááááááááááááááfilσ witΦ al∞ space≤ iε namσ anΣ typσ field≤ áwil∞ ì
  1936. ááááááááááááááábσ returned«  File≤ arσ listeΣ iε 1╖-bytσ áentrie≤ ì
  1937. áááááááááááááááorganizeΣ as:
  1938.                          DEF┬      'FILENAMEº     ; 11-char filename
  1939.                          DEF┬      'TYPº          ╗ │-cha≥ filetype
  1940.                          DEFW      START_IDX      ; index of file start
  1941.                          DEFW      LENGTH         ; # of 128-byte blocks in fileè                         DEFW      FILE_CRC       ; CRC of file
  1942.  
  1943.      Routine║   LUOPEN
  1944.      Function║ Open a library file for access
  1945.      Entry:    DE = address of a library utility descriptor (LUD)
  1946.                HL = pointer to filename and type
  1947.                Drive and user of library must already be set
  1948.      Exit:     A = 0, zero flag set (Z) if open OK
  1949.                A <> 0, zero flag reset (NZ) if file not found
  1950.      Affected: AF¼ DM┴ addres≤ i≤ se⌠ t∩ 80Φ b∙ thi≤ routine
  1951.      Usage:    Open≤ áß filσ iε ß librar∙ fo≥ acces≤ áb∙ áLUREAD«  ì
  1952. áááááááááááááááThσ áfilenamσ anΣ typσ addresseΣ b∙ H╠ ma∙ bσ áamì
  1953. ááááááááááááááábiguou≤ iε whicΦ casσ thσ firs⌠ filσ iε thσ libraì
  1954. ááááááááááááááár∙ matchinτ thσ specificatioε wil∞ bσ opened«  Thσ ì
  1955. áááááááááááááááexac⌠ ánamσ áma∙ bσ determineΣ áb∙ áexamininτ áthσ ì
  1956. ááááááááááááááácurren⌠ filσ Namσ sectioε oµ thσ LU─ afte≥ callinτ ì
  1957. áááááááááááááááLUOPEN.
  1958.  
  1959.      Routine║   LUCLOSE
  1960.      Function║ Close a library file
  1961.      Entry:    DE = points to library utility descriptor
  1962.      Exit:     None
  1963.      Affected║ None
  1964.      Usage:    Zero≤ thσ inde° anΣ lengtΦ field≤ oµ thσ LUD¼ ábu⌠ ì
  1965. ááááááááááááááádoe≤ ánothinτ elsσ sincσ n∩ closσ i≤ needeΣ áoε áß ì
  1966. áááááááááááááááfilσ whicΦ i≤ onl∙ accesseΣ fo≥ reading.
  1967.  
  1968.      Routine║   LUREAD
  1969.      Function║ Read record from a file in a library
  1970.      Entry:    DE = address of a library utility descriptor (LUD)
  1971.                Drive and user of library must already be set
  1972.      Exit:     A = 0, zero flag set (Z) if read OK
  1973.                A <> 0, zero flag reset (NZ) if end-of-file
  1974.      Affected: AF
  1975.      Usage:    Ma∙ ábσ áuseΣ iε thσ samσ manne≥ a≤ áothe≥ áSYSLI┬ ì
  1976. ááááááááááááááároutine≤ át∩ reaΣ ß singlσ 12╕-bytσ recorΣ t∩ áthσ ì
  1977. ááááááááááááááácurren⌠ DM┴ address«  Thσ curren⌠ recorΣ anΣ ánumì
  1978. ááááááááááááááábe≥ áoµ árecord≤ remaininτ field≤ oµ thσ áLU─ áarσ ì
  1979. áááááááááááááááupdateΣ b∙ eacΦ cal∞ t∩ LUREAD.
  1980.  
  1981. FILENAME STRING PARSER:
  1982.  
  1983.      Routine║   FNAME
  1984.      Function║ Filename string parser
  1985.      Entry:    HL = pointer to target string ending with delimiter
  1986.                DE = pointer to a 36-byte long FCB
  1987.      Exit:     ┬ ╜ disk (drive A=1..P=16, 0FFΦ=no disk specified)
  1988.                ├ ╜ user (0..31, '?'=all users, 0FFh=no user spec)
  1989.                HL = pointer to the character which ended the scan
  1990.                A <> 0, zero flag clear (NZ) if string parsed OK
  1991.                A = 0, zero set (Z) if invalid disk or user
  1992.      Affected: AF¼ BC¼ HL
  1993.      Usage:    Parse≤ ß strinτ t∩ ß specifieΣ FCB¼ anΣ put≤ ádisδ ì
  1994. áááááááááááááááanΣ áuse≥ t∩ registers«  Thσ strinτ i≤ assumeΣ át∩ ì
  1995. ááááááááááááááábσ iε form:è               ü     DU:FILENAME.TYP
  1996.                wherσ áan∙ par⌠ oµ thσ specificatioε i≤ áoptional«  ì
  1997. áááááááááááááááI⌠ clear≤ al∞ byte≤ oµ thσ FC┬ t∩ zer∩ excep⌠ áfo≥ ì
  1998. áááááááááááááááthσ áFε (filename⌐ anΣ F⌠ (filetype⌐ field≤ áwhicΦ ì
  1999. áááááááááááááááarσ áinitializeΣ át∩ ávalue≤ áextracteΣ áfroφ áthσ ì
  2000. ááááááááááááááástring¼ o≥ space≤ iµ absent.
  2001.  
  2002.                Thσ strinτ pointeΣ t∩ b∙ H╠ i≤ no⌠ ß áconventiona∞ ì
  2003. ááááááááááááááástrinτ áiε áthσ sensσ oµ thσ res⌠ áoµ áthσ áSYSLI┬ ì
  2004. ááááááááááááááároutines« á I⌠ ái≤ endeΣ b∙ an∙ oµ áthσ áfollowinτ ì
  2005. ááááááááááááááádelimiters¼ a≤ opposeΣ b∙ simpl∙ alway≤ beinτ te≥ì
  2006. áááááááááááááááminateΣ áb∙ áß binar∙ zero«  Thσ ádelimiter≤ áare║  ì
  2007. ááááááááááááááá<NUL>¼ <SP>¼ "="¼ "_"¼ ";"¼ ","¼ "<"¼ ">"
  2008.  Examples║     TEST.TXT ╜ FN=TEXT, FT=TXT, B=0FFh, C=0FFh
  2009.                A:T = FN=T, FT=<Spaces>, B=1, C=0FFh
  2010.                5:T = FN=T, FT=<Spaces>, B=0FFh, C=5
  2011.                C10:X.Y = FN=X, FT=Y, B=3, C=10
  2012.  
  2013. FIL┼ CONTRO╠ BLOC╦ INITIALIZTION:
  2014.  
  2015.      Routine║   INITFCB
  2016.      Function║ FCB initialization
  2017.      Entry:    DE = pointer to 36-byte FCB buffer
  2018.      Exit:     None
  2019.      Affected: None
  2020.      Usage:    ┴ ágenera∞ purposσ applicatioε t∩ clea≥ al∞ ábyte≤ ì
  2021. áááááááááááááááiε aε FC┬ t∩ zer∩ excep⌠ fo≥ thσ filenamσ anΣ typσ ì
  2022. áááááááááááááááfields« á Usinτ áINITFC┬ t∩ preparσ FCB≤ áfo≥ áusσ ì
  2023. ááááááááááááááádestroy≤ an∙ drivσ specificatioε iε thσ firs⌠ bytσ ì
  2024. áááááááááááááááoµ áthσ FCB«  I⌠ wil∞ bσ se⌠ t∩ zer∩ áequatinτ át∩ ì
  2025. áááááááááááááááthσ currentl∙ loggeΣ drive.
  2026.  
  2027. DISK/USE╥ áMANIPULATIO╬ ROUTINES:é  Thi≤ i≤ ß se⌠ oµ si° ároutine≤ ì
  2028. whicΦ áallo≈ áthσ use≥ t∩ readil∙ movσ arounΣ betweeε ádisk≤ áanΣ ì
  2029. use≥ Areas«  Thesσ routine≤ are:
  2030.      GUA -¡ return the current user
  2031.      SUA -¡ log into a specified user area
  2032.      RETUD -- return the current disδ anΣ user
  2033.      LOGUD -- log into a specified disδ anΣ user
  2034.      PUTUD -- save away the current disδ anΣ user
  2035.      GETUD -- restore the disδ anΣ user saved by PUTUD
  2036.  
  2037. GU┴ anΣ SU┴ arσ t∩ bσ useΣ t∩ finΣ ou⌠ wha⌠ use≥ areß thσ prograφ ì
  2038. i≤ áiε (GUA⌐ anΣ t∩ ente≥ ß specifiπ use≥ areß (SUA)«  Fo≥ áexamì
  2039. ple:
  2040.           CAL╠      GUA       ; find out current user
  2041.           PUSH      AF        ; save it
  2042.      [move around on other user areas]
  2043.           POP       AF        ; get current user
  2044.           CALL      SUA       ; log into user
  2045. GU┴ áanΣ áSU┴ arσ usefu∞ iε conjunctioε witΦ thσ áautomatiπ ádisδ ì
  2046. logginτ áfeaturσ oµ CP/M¼ wherσ thσ firs⌠ bytσ oµ thσ áFC┬ áindiì
  2047. cate≤ ß disδ t∩ autoloτ (0=default¼ 1=A¼ 2=B¼ etc.).
  2048.  
  2049. RETU─ áanΣ LOGU─ arσ t∩ bσ useΣ t∩ finΣ ou⌠ wherσ thσ prograφ ái≤ ìè(RETUD⌐ anΣ t∩ ente≥ ß specifiπ disδ anΣ use≥ areß (LOGUD)« á Fo≥ ì
  2050. example:
  2051.           CALL      RETUD     ; find out where we are
  2052.           PUSH      BC        ; save disk/user
  2053.      [move around on disks/users]
  2054.           POP       BC        ; get disk/user
  2055.           CALL      LOGUD     ; log into disk/user
  2056. PUTUD and GETUD are designed to be used as a place marker and ì
  2057. return combination.  They are intended to be used in such code ì
  2058. sequences as the following:
  2059.           CALL      PUTUD     ; mark current location
  2060.      [move around on disks/users]
  2061.           CALL      GETUD     ; return to marked location
  2062. Sincσ PUTU─ store≤ thσ value≤ iε ß singlσ leve∞ buffer¼ ámultiplσ ì
  2063. call≤ át∩ áPUTU─ shoulΣ bσ avoideΣ sincσ GETU─ wil∞ árestorσ áthσ ì
  2064. las⌠ disk/use≥ saveΣ b∙ PUTUD.
  2065.  
  2066.      Routine║   GUA
  2067.      Function║ Return current user area
  2068.      Entry:    None
  2069.      Exit:     A = user area (0-31)
  2070.      Affected: AF
  2071.      Usage:    Return≤ thσ currentl∙ loggeΣ use≥ area«  N∩ áerro≥ ì
  2072. ááááááááááááááácode≤ exis⌠ witΦ thi≤ function.
  2073.  
  2074.      Routine:   SUA
  2075.      Function║ Set current user area
  2076.      Entry:    A = user area (0-31)
  2077.      Exit:     None
  2078.      Affected: None
  2079.      Usage:    Log≤ áint∩ thσ use≥ areß representeΣ b∙ áthσ álo≈-ì
  2080. áááááááááááááááorde≥ á╡ bit≤ oµ thσ supplieΣ valuσ (valuσ á░-31)«  ì
  2081. áááááááááááááááN∩ erro≥ code≤ exis⌠ witΦ thi≤ function.
  2082.  
  2083.      Routine║   RETUD
  2084.      Function║ Return the current disδ anΣ user
  2085.      Entry:    None
  2086.      Exit:     ┬ ╜ disk (drive A=0), ├ ╜ user (0..31)
  2087.      Affected: BC
  2088.      Usage:    Return≤ thσ currentl∙ loggeΣ use≥ numbe≥ anΣ ácurì
  2089. ááááááááááááááárentl∙ loggeΣ drivσ iε ß singlσ operation.
  2090.  
  2091.      Routine║   LOGUD
  2092.      Function║ Log into a disδ anΣ user
  2093.      Entry:    ┬ ╜ disk (drive A=0), ├ ╜ user (0..31)
  2094.      Exit:     None
  2095.      Affected: None
  2096.      Usage:    Log≤ áiε ß specifieΣ drivσ anΣ set≤ thσ áspecifieΣ ì
  2097. áááááááááááááááuse≥ areß t∩ curren⌠ iε ß singlσ operation.
  2098. .paè     Routine║   PUTUD
  2099.      Function║ Save away disδ anΣ user
  2100.      Entry:    None
  2101.      Exit:     None
  2102.      Affected: None
  2103.      Usage:    Commonl∙ áuseΣ nea≥ thσ beginninτ oµ ß prograφ áo≥ ì
  2104. ááááááááááááááároutinσ t∩ savσ thσ curren⌠ use≥ anΣ disδ ánumber≤ ì
  2105. áááááááááááááááfo≥ árestoratioε áupoε prograφ áo≥ ároutinσ áexit«  ì
  2106. áááááááááááááááPUTU─ ásave≤ thσ curren⌠ disδ anΣ use≥ iε ß áloca∞ ì
  2107. ááááááááááááááábuffer¼ whilσ GETU─ restore≤ thesσ saveΣ ásetting≤ ì
  2108. ááááááááááááááát∩ áthσ currentl∙ loggeΣ BDO╙ values«  Thσ ábuffe≥ ì
  2109. áááááááááááááááuseΣ b∙ PUTU─ anΣ GETU─ i≤ interna∞ anΣ no⌠ availì
  2110. áááááááááááááááablσ fo≥ genera∞ use.
  2111.  
  2112.      Routine:   GETUD
  2113.      Function║ Restore disδ anΣ user saved by PUTUD
  2114.      Entry:    None
  2115.      Exit:     None
  2116.      Affected: None
  2117.      Usage:    Commonl∙ áuseΣ nea≥ thσ beginninτ oµ ß prograφ áo≥ ì
  2118. ááááááááááááááároutinσ t∩ savσ thσ curren⌠ use≥ anΣ disδ ánumber≤ ì
  2119. áááááááááááááááfo≥ árestoratioε áupoε prograφ áo≥ ároutinσ áexit«  ì
  2120. áááááááááááááááPUTU─ ásave≤ thσ curren⌠ disδ anΣ use≥ iε ß áloca∞ ì
  2121. ááááááááááááááábuffer¼ whilσ GETU─ restore≤ thesσ saveΣ ásetting≤ ì
  2122. ááááááááááááááát∩ áthσ currentl∙ loggeΣ BDO╙ values«  Thσ ábuffe≥ ì
  2123. áááááááááááááááuseΣ b∙ PUTU─ anΣ GETU─ i≤ interna∞ anΣ no⌠ availì
  2124. áááááááááááááááablσ fo≥ genera∞ use.
  2125.  
  2126.      Routine║   SETDMA
  2127.      Function║ Set the BDOS DMA transfer address
  2128.      Entry:    HL = start of DMA buffer to set
  2129.      Exit:     None
  2130.      Affected: None
  2131.      Usage:    Set≤ thσ DM┴ transfe≥ addres≤ withiε thσ BDO╙ áanΣ ì
  2132. áááááááááááááááBIO╙ t∩ thσ specifieΣ address«  Sincσ n∩ register≤ ì
  2133. áááááááááááááááarσ destroyeΣ b∙ thi≤ routine¼ i⌠ i≤ suitablσ áfo≥ ì
  2134. áááááááááááááááusσ withiε loop≤ iε programs.
  2135.  
  2136. NUMERIC STRING EVALUATION:
  2137.  
  2138.      Routine║   EVAL
  2139.      Function║ General-purpose numeric string evaluation
  2140.      Entry:    HL = address of first byte of string to convert
  2141.      Exit:     H╠ á╜ point≤ t∩ characte≥ afte≥ áconverteΣ ástrinτ ì
  2142. ááááááááááááááá(o≥ characte≥ causinτ erro≥ iµ erro≥ flaτ set)
  2143.                DE = 16-bit binary value of string
  2144.                A = E value, carry flag clear (NC) if OK
  2145.                Carry flag set (C) if error in string
  2146.      Affected: AF¼ DE¼ HL
  2147.      Usage:    Convert≤ áthσ ácharacte≥ strinτ pointeΣ t∩ áb∙ áH╠ ì
  2148. áááááááááááááááint∩ áß 1╢-bi⌠ binar∙ representation« á EVA╠ áperì
  2149. áááááááááááááááform≤ thσ conversioε unti∞ ß noε-hexadecima∞ charì
  2150. áááááááááááááááacte≥ ái≤ encountered¼ a⌠ whicΦ timσ i⌠ álook≤ áa⌠ ì
  2151. áááááááááááááááthσ álas⌠ characte≥ anΣ thσ previou≤ characte≥ át∩ ì
  2152. ááááááááááááááádeterminσ iµ thσ strinτ i≤ representinτ ß ábinary¼ ìèáááááááááááááááoctal¼ ádecimal¼ áo≥ áhexadecima∞ ánumber« á Inpu⌠ ì
  2153. ááááááááááááááástrinτ ácharacter≤ ma∙ bσ uppercasσ o≥ álowercase«  ì
  2154. áááááááááááááááValiΣ inpu⌠ strinτ format≤ are:
  2155.                     binar∙ strinτ¼ wherσ b=░ o≥ b=1
  2156.                          bbbbbbbbbbbbbbbbB
  2157.                     decima∞ string¼ wherσ ░ <╜ ⌠ <= ╣
  2158.                          ttttt
  2159.                          tttttD
  2160.                     hexadecima∞ string¼ wherσ ░ <╜ Φ <╜ F
  2161.                          hhhhH
  2162.                          hhhhX
  2163.                     octa∞ string¼ wherσ ░ <╜ ∩ <╜ 7
  2164.                          oooooooO
  2165.                          oooooooQ
  2166.  
  2167.      Routine║   EVAL16
  2168.      Function║ Hexadecimal string evaluation
  2169.      Entry:    H╠ ╜ addres≤ oµ firs⌠ characte≥ oµ strinτ t∩ áconì
  2170. ááááááááááááááávert
  2171.      Exit:     HL = points to character terminating conversion
  2172.                DE = contains the 16-bit binary value of string
  2173.                A = E value
  2174.      Affected: AF¼ DE¼ HL
  2175.      Usage:    Convert≤ áthσ strinτ oµ ASCI╔ hexadecima∞ ácharacì
  2176. áááááááááááááááter≤ pointeΣ t∩ b∙ H╠ int∩ ß 1╢-bi⌠ binar∙ ávalue«  ì
  2177. áááááááááááááááConversioε progresse≤ unti∞ aε invaliΣ hexadecima∞ ì
  2178. ááááááááááááááádigi⌠ (░-9¼ ┴-F⌐ i≤ encountered.
  2179.  
  2180.      Routine║   EVAL10
  2181.      Function║ Decimal string evaluation
  2182.      Entry:    HL = address of first character of string to convert
  2183.      Exit:     HL = points to character terminating conversion
  2184.                DE = contains the 16-bit binary value of string
  2185.                A = E value
  2186.      Affected: AF¼ DE¼ HL
  2187.      Usage:    Convert≤ áthσ strinτ oµ ASCI╔ ádecima∞ ácha≥acter≤ ì
  2188. ááááááááááááááápointeΣ át∩ áb∙ áH╠ int∩ ß á1╢-bi⌠ ábinar∙ áva∞ue«  ì
  2189. áááááááááááááááConversioε áprogresse≤ áunti∞ aε áinvaliΣ ádecΘma∞ ì
  2190. ááááááááááááááádigi⌠ (░-9⌐ i≤ encountered.
  2191.  
  2192.      Routine║   EVAL8
  2193.      Function║ Octal string evaluation
  2194.      Entry:    HL = address of first character of string to convert
  2195.      Exit:     HL = points to character terminating conversion
  2196.                DE = contains the 16-bit binary value of string
  2197.                A = E value
  2198.      Affected: AF¼ DE¼ HL
  2199.      Usage:    Convert≤ áthσ ástrinτ oµ áASCI╔ áocta∞ ácharacter≤ ì
  2200. ááááááááááááááápointeΣ át∩ áb∙ áH╠ int∩ ß á1╢-bi⌠ ábinar∙ ávalue«  ì
  2201. áááááááááááááááConversioε progresse≤ unti∞ aε invaliΣ octa∞ digi⌠ ì
  2202. ááááááááááááááá(░-7⌐ i≤ encountered.
  2203. .paè     Routine║   EVAL2
  2204.      Function║ Binary string evaluation
  2205.      Entry:    HL = address of first character of string to convert
  2206.      Exit:     HL = points to character terminating conversion
  2207.                DE = contains the 16-bit binary value of string
  2208.                A = E value
  2209.      Affected: AF¼ DE¼ HL
  2210.      Usage:    Convert≤ áthσ ástrinτ oµ ASCI╔ ábinar∙ ácharacter≤ ì
  2211. ááááááááááááááápointeΣ át∩ áb∙ áH╠ int∩ ß á1╢-bi⌠ ábinar∙ ávalue«  ì
  2212. áááááááááááááááConversioε áprogresse≤ áunti∞ áaε áinvaliΣ ábinar∙ ì
  2213. ááááááááááááááádigi⌠ (░-1⌐ i≤ encountered.
  2214.  
  2215. TH┼ áL¼ M¼ P¼ AN─ ╙ NUMERI├ OUTPU╘ ROUTINES:é  Thσ numeriπ áoutpu⌠ ì
  2216. routine≤ describeΣ herσ arσ useΣ t∩ outpu⌠ eithe≥ thσ H╠ registe≥ ì
  2217. pai≥ o≥ thσ ┴ registe≥ iε ß variet∙ oµ forms«  Thesσ form≤ arσ a≤ ì
  2218. hexadecima∞ characters¼ a≤ decima∞ characters¼ a≤ decima∞ characì
  2219. ter≤ witΦ leadinτ spaces¼ anΣ a≤ decima∞ character≤ witΦ n∩ leadì
  2220. inτ zeroe≤ o≥ spaces.
  2221.  
  2222. Iε addition¼ eacΦ oµ thesσ routine≤ ha≤ ß prefi° t∩ thei≥ ánames║ ì
  2223. L¼ áM¼ P¼ o≥ S«  Thesσ prefixe≤ indicatσ thσ outpu⌠ ádestination«  ì
  2224. ╠ áindicate≤ thσ LS╘ devicσ (o≥ printer)¼ ═ indicate≤ ámemory¼ á╨ ì
  2225. indicate≤ áthσ áconsolσ á(prin⌠ thσ output)¼ anΣ á╙ áindicate≤ áß ì
  2226. switcheΣ outpu⌠ t∩ nothing¼ thσ console¼ thσ printer¼ o≥ both.
  2227.  
  2228. Fo≥ áexample¼ áPAD├ send≤ ┴ a≤ decima∞ ácharacter≤ áwitΦ áleadinτ ì
  2229. space≤ át∩ thσ console¼ whilσ LAD├ send≤ ┴ a≤ decima∞ ácharacter≤ ì
  2230. witΦ leadinτ space≤ t∩ thσ printer.
  2231.  
  2232. Thσ á╙-serie≤ oµ routine≤ i≤ differen⌠ froφ thσ othe≥ áserie≤ áiε ì
  2233. tha⌠ áthσ ╙-serie≤ use≤ aε externa∞ datß bytσ t∩ determinσ áwherσ ì
  2234. thσ áoutpu⌠ i≤ t∩ bσ routed«  Thi≤ bytσ i≤ referreΣ t∩ a≤ áSCTLF╠ ì
  2235. (╙ áContro∞ Flag)¼ anΣ it≤ switchinτ functioε i≤ áillustrateΣ áiε ì
  2236. thσ followinτ table.
  2237.  
  2238.      SCTLFL:
  2239.            binary        hex       outputs to
  2240.           00000000b      00h       nothing
  2241.           00000001b      01h       console
  2242.           10000000b      80h       printer
  2243.           10000001b      81h       console and printer
  2244.  
  2245. Iµ yo⌡ d∩ no⌠ initializσ thσ SCTLF╠ variablσ beforσ usinτ thσ á╙-ì
  2246. routine¼ outpu⌠ wil∞ g∩ t∩ thσ consolσ (thσ defaul⌠ i≤ 01h).
  2247.  
  2248. An example of code using S-routines is:
  2249.                EX╘       SCTLFL,SADC         ; SCTLFL flag, SADC routine
  2250.                ...
  2251.                LD        A,81H               ; enable printer and console
  2252.                LD        (SCTLFL),A
  2253.                ...
  2254.                LD        A,32                ; print number 32
  2255.                CALL      SADC
  2256.                ...
  2257.                LD        A,80H               ; enable printer onlyè               LD        (SCTLFL),A
  2258.                ...
  2259.                LD        A,150               ; print number 150
  2260.                CALL      SADC
  2261.                ...
  2262.  
  2263. SAMPL┼ áNUMERI├ áOUTPUTS:é  Thσ followinτ átable≤ áillustratσ áho≈ ì
  2264. value≤ áwil∞ bσ outpu⌠ b∙ thσ variou≤ routines« á Thσ áunderscorσ ì
  2265. characte≥ (_⌐ indicate≤ ß space.
  2266.  
  2267.         Value     xA2HC     xA3DC     xADC      xAFDC
  2268.             0        00        000      __0     0
  2269.            10        0A        010      _10     10
  2270.           255        FF        255      255     255
  2271.  
  2272.         Value     xHL4HC    xHL5DC    xHLDC     xHLFDC
  2273.             0      0000      00000    ____0     0
  2274.            10      000A      00010    ___10     10
  2275.           100      0064      00100    __100     100
  2276.          1000      03E8      01000    _1000     1000
  2277.         65535      FFFF      65535    65535     65535
  2278.  
  2279.      Routines║  LA2HC ,  PA2HC ,  SA2HC
  2280.      Function║ Print A as two hex characters
  2281.      Entry:    A = value to be converted and printed
  2282.      Exit:     None
  2283.      Affected: None
  2284.      Usage:    Print≤ áß ábytσ a≤ tw∩ hexidecima∞ ácharacter≤ áoε ì
  2285. áááááááááááááááLST║ á(LA2HC)¼ CON║   (PA2HC)¼ o≥ switcheΣ áoutpu⌠ ì
  2286. ááááááááááááááá(SA2HC).
  2287.  
  2288.      Routine:   MA2HC
  2289.      Function║ Store A as two hex characters in memory
  2290.      Entry:    A = value to be converted and stored
  2291.                DE = pointer to start of 2-byte buffer
  2292.      Exit:     DE = points to byte after string
  2293.      Affected: DE
  2294.      Usage:    Store≤ áß ábytσ iε memor∙ a≤ tw∩ á(2⌐ áhexadecima∞ ì
  2295. ááááááááááááááácharacters.
  2296.  
  2297.      Routines║  LA3DC ,  PA3DC ,  SA3DC
  2298.      Function║ Print A as three decimal digits
  2299.      Entry:    A = binary value to convert and print
  2300.      Exit:     None
  2301.      Affected: None
  2302.      Usage:    Print≤ ß bytσ (0..255⌐ a≤ threσ (3⌐ decima∞ ácha≥ì
  2303. áááááááááááááááacter≤ áiε ß fixeΣ lengtΦ spacσ oε áLST║ á(LA3DC)¼ ì
  2304. áááááááááááááááCON║ (PA3DC)¼ o≥ switcheΣ outpu⌠ (SA3DC).
  2305. .paè     Routine║   MA3DC
  2306.      Function║ Store A as three decimal digits in memory
  2307.      Entry:    A = binary value to convert and store
  2308.                DE = pointer to 3-byte buffer
  2309.      Exit:     DE = points to the byte after the buffer
  2310.      Affected: DE
  2311.      Usage:    Store≤ ß bytσ iε memor∙ a≤ threσ (3⌐ decima∞ ádigì
  2312. áááááááááááááááits.
  2313.  
  2314.      Routines║  LADC ,  PADC ,  SADC
  2315.      Function║ Print byte as up to three decimal digits
  2316.      Entry:    A = binary value to convert and print
  2317.      Exit:     None
  2318.      Affected: None
  2319.      Usage:    Print≤ áß ábytσ iε variablσ áforma⌠ áwitΦ áleadinτ ì
  2320. áááááááááááááááspace≤ á(righ⌠ ájustified⌐ oε áLST║ á(LADC)¼ áCON║ ì
  2321. ááááááááááááááá(PADC)¼ o≥ switcheΣ outpu⌠ (SADC).
  2322.  
  2323.      Routine:   MADC
  2324.      Function║ Store a byte as up to three digits in memory
  2325.      Entry:    A = binary value to convert and store
  2326.                DE = pointer to 3-byte memory buffer
  2327.      Exit:     DE = points to byte after the buffer
  2328.      Affected: DE
  2329.      Usage:    Store≤ ß bytσ iε memor∙ iε ß fixeΣ threσ characte≥ ì
  2330. ááááááááááááááábuffe≥ a≤ u≡ t∩ threσ (3⌐ decima∞ character≤ áwitΦ ì
  2331. áááááááááááááááleadinτ spaces.
  2332.  
  2333.      Routines║  LAFDC ,  PAFDC ,  SAFDC
  2334.      Function║ Print A as 1 to 3 digits (variable)
  2335.      Entry:    A = binary value to be converted and printed
  2336.      Exit:     None
  2337.      Affected: None
  2338.      Usage:    Print≤ áß bytσ a≤ onσ t∩ threσ decima∞ ácharacter≤ ì
  2339. áááááááááááááááwitΦ án∩ áleadinτ áspace≤ oε áLST║ á(LAFDC)¼ áCON║ ì
  2340. ááááááááááááááá(PAFDC)¼ o≥ switcheΣ outpu⌠ (SAFDC).
  2341.  
  2342.      Routine:   MAFDC
  2343.      Function║ Store A as 1 to 3 digits (variable) in memory
  2344.      Entry:    A = value to be converted and stored
  2345.                DE = pointer to a 3-byte buffer
  2346.      Exit:     DE = points to the byte after the last one saved
  2347.      Affected: DE
  2348.      Usage:    Store≤ ß bytσ a≤ u≡ t∩ threσ (3⌐ decima∞ digit≤ iε ì
  2349. áááááááááááááááß │-bytσ memor∙ buffer.
  2350.  
  2351.      Routines║  LHL4HC ,  PHL4HC ,  SHL4HC
  2352.      Function║ Print 16-bit value as four hexadecimal chars
  2353.      Entry:    HL = 16-bit value to print
  2354.      Exit:     None
  2355.      Affected: None
  2356.      Usage:    Print≤ áH╠ a≤ fou≥ (4⌐ hexadecima∞ ácharacter≤ áoε ì
  2357. áááááááááááááááLST║ á(LHL4HC)¼ CON║ (PHL4HC)¼ o≥ switcheΣ áoutpu⌠ ì
  2358. ááááááááááááááá(SHL4HC).
  2359. .paè     Routine:   MHL4HC
  2360.      Function║ Save 16-bit value as four hexadecimal characters
  2361.      Entry:    HL = 16-bit value to convert and save
  2362.                DE = pointer to 4-byte buffer
  2363.      Exit:     DE = points to byte after buffer
  2364.      Affected: DE
  2365.      Usage:    Store≤ H╠ a≤ fou≥ (4⌐ hexadecima∞ character≤ iε áß ì
  2366. ááááááááááááááá┤-bytσ memor∙ buffer.
  2367.  
  2368.      Routine║   LHL5DC ,  PHL5DC ,  SHL5DC
  2369.      Function║ Print 16-bit value as 5 decimal characters
  2370.      Entry:    HL = 16-bit value to print
  2371.      Exit:     None
  2372.      Affected: None
  2373.      Usage:    Print≤ áH╠ a≤ fivσ (5⌐ decima∞ character≤ oε áLST║ ì
  2374. ááááááááááááááá(LHL5DC)¼ ááCON║ á(PHL5DC)¼ áo≥ áswitcheΣ ááoutpu⌠ ì
  2375. ááááááááááááááá(SHL5DC).
  2376.  
  2377.      Routine:   MHL5DC
  2378.      Function║ Save 16-bit value as 5 decimal characters
  2379.      Entry:    HL = value to be converted and stored
  2380.                DE = pointer to 5-byte buffer
  2381.      Exit:     DE = points to byte after buffer
  2382.      Affected: DE
  2383.      Usage:    Store≤ áH╠ a≤ fivσ (5⌐ decima∞ character≤ iε ß á╡-ì
  2384. ááááááááááááááábytσ memor∙ buffer.
  2385.  
  2386.      Routine║   LHLDC ,  PHLDC ,  SHLDC
  2387.      Function║ Print 16-bit value as 1-5 decimal digits
  2388.      Entry:    HL = value to be printed
  2389.      Exit:     None
  2390.      Affected: None
  2391.      Usage:    Print≤ áH╠ áa≤ áonσ t∩ fivσ ádecima∞ ádigit≤ áwitΦ ì
  2392. áááááááááááááááleadinτ áspace≤ oε LST║ (LHLDC)¼ CON║ (PHLDC)¼ áo≥ ì
  2393. áááááááááááááááswitcheΣ outpu⌠ (SHLDC).
  2394.  
  2395.      Routine:   MHLDC
  2396.      Function║ Store 16-bit value as 1-5 decimal digits in memory
  2397.      Entry:    HL = value to convert and store
  2398.                DE = pointer to five byte memory buffer
  2399.      Exit:     DE = points to byte after buffer
  2400.      Affected: DE
  2401.      Usage:    Convert≤ áanΣ ástore≤ H╠ a≤ onσ át∩ áfivσ ádecima∞ ì
  2402. ááááááááááááááácharacter≤ witΦ leadinτ space≤ iε ß ╡-bytσ ámemor∙ ì
  2403. ááááááááááááááábuffer.
  2404.  
  2405.      Routine║   LHLFDC ,  PHLFDC ,  SHLFDC
  2406.      Function║ Print HL as 1 to 5 decimal digits
  2407.      Entry:    HL = value to be printed
  2408.      Exit:     None
  2409.      Affected: None
  2410.      Usage:    Print≤ áH╠ a≤ onσ t∩ fivσ decima∞ digit≤ áwitΦ án∩ ì
  2411. áááááááááááááááleadinτ space≤ oε LST║ (LHLFDC)¼ CON║ (PHLFDC)¼ o≥ ì
  2412. áááááááááááááááswitcheΣ outpu⌠ (SHLFDC).
  2413. .paè     Routine:   MHLFDC
  2414.      Function║ Store HL as 1 to 5 decimal digits in memory
  2415.      Entry:    HL = value to convert and store
  2416.                DE = pointer to 5-byte memory buffer
  2417.      Exit:     DE = points to byte after last one stored
  2418.      Affected: DE
  2419.      Usage:    Convert≤ áanΣ ástore≤ H╠ a≤ onσ át∩ áfivσ ádecima∞ ì
  2420. ááááááááááááááádigit≤ iε ß ╡-bytσ buffer.
  2421.  
  2422. INPU╘ áLIN┼ áEDITORS:é  Aε inpu⌠ linσ edito≥ i≤ useΣ t∩ áaccep⌠ áß ì
  2423. linσ áoµ tex⌠ froφ thσ terminal¼ allowinτ yo⌡ t∩ áissuσ ácommand≤ ì
  2424. likσ ábackspacσ anΣ ^╪ (erasσ al∞ oµ linσ typeΣ s∩ far⌐ át∩ áedi⌠ ì
  2425. tex⌠ a≤ yo⌡ ente≥ it«  Oncσ thσ tex⌠ ha≤ beeε entered¼ thσ áinpu⌠ ì
  2426. linσ edito≥ return≤ t∩ thσ callinτ prograφ witΦ you≥ tex⌠ ástoreΣ ì
  2427. iε ß buffer«  Thi≤ tex⌠ i≤ terminateΣ b∙ ß binar∙ 0.
  2428.  
  2429. Tw∩ áoµ áthσ inpu⌠ linσ editor≤ iε SYSLI┬ usσ thσ áCP/═ áBDO╙ át∩ ì
  2430. providσ thσ linσ edito≥ function«  The∙ mainl∙ servσ t∩ ápreservσ ì
  2431. thσ register≤ durinτ thσ functioε cal∞ anΣ t∩ storσ thσ terminatì
  2432. inτ zer∩ a⌠ thσ enΣ oµ thσ text«  The∙ occup∙ les≤ spacσ thaε thσ ì
  2433. thirΣ inpu⌠ linσ editor¼ INLINE.
  2434.  
  2435. Thσ áthirΣ áinpu⌠ linσ editor¼ INLINE¼ i≤ useΣ wheε ásecurit∙ ái≤ ì
  2436. important«  Unlikσ thσ othe≥ two¼ wheε typinτ ß ^├ t∩ INLINE¼ thσ ì
  2437. inpu⌠ álinσ edito≥ (anΣ callinτ program⌐ i≤ no⌠ aborteΣ anΣ áconì
  2438. tro∞ áreturneΣ át∩ áCP/M«  Instead¼ thσ ^├ ácharacte≥ ái≤ ásimpl∙ ì
  2439. storeΣ áiε you≥ line«  Also¼ unlikσ thσ othe≥ two¼ INLIN┼ caε ábσ ì
  2440. instructeΣ át∩ ech∩ o≥ no⌠ ech∩ thσ inpu⌠ characters«  Thi≤ áfeaì
  2441. turσ ái≤ áusefu∞ áfo≥ program≤ whicΦ wan⌠ t∩ áinpu⌠ áß ápassword«  ì
  2442. INLIN┼ ácaε bσ instructeΣ no⌠ t∩ ech∩ thσ password¼ bu⌠ ái⌠ áwil∞ ì
  2443. stil∞ providσ thσ linσ editinτ function≤ s∩ tha⌠ yo⌡ caε ácorrec⌠ ì
  2444. an∙ mistakes.
  2445.  
  2446.      Routine║   BBLINE
  2447.      Function║ BDOS-based line editor with internal buffer
  2448.      Entry:    A = 0 to not capitalize line
  2449.                A <> 0 to capitalizσ line
  2450.      Exit:     HL = pointer to first character in the line
  2451.                ┴ á╜ numbe≥ oµ characters≤ iε thσ linσ á(excludinτ ì
  2452. áááááááááááááááendinτ zero)
  2453.      Affected: AF¼ HL
  2454.      Usage:    BBLIN┼ provide≤ ß ver∙ convenien⌠ interfacσ t∩ thσ ì
  2455. áááááááááááááááBDO╙ fo≥ inpu⌠ linσ edito≥ functions«  I⌠ contain≤ ì
  2456. áááááááááááááááaε áinterna∞ buffe≥ fo≥ storagσ oµ thσ inpu⌠ álinσ ì
  2457. ááááááááááááááá(20░ byte≤ allocated)¼ anΣ i⌠ return≤ ß pointe≥ t∩ ì
  2458. áááááááááááááááthσ firs⌠ bytσ oµ thσ linσ upoε return«  Thσ álinσ ì
  2459. ááááááááááááááástoreΣ iε thi≤ buffe≥ i≤ terminateΣ b∙ ß NU╠ á(0)«  ì
  2460. áááááááááááááááT∩ áusσ BBLINE¼ yo⌡ onl∙ neeΣ t∩ cal∞ i⌠ witΦ áthσ ì
  2461. ááááááááááááááácapitalizatioε flaτ se⌠ fo≥ thσ desireΣ action.
  2462. .paè     Routine║   BLINE
  2463.      Function║ BDOS-based line editor with user-supplied buffer
  2464.      Entry:    A = 0 to not capitalize line
  2465.                A <> 0 to capitalizσ line
  2466.                HL = pointer to first byte of user-supplied buffer
  2467.      Exit:     HL = pointer to first character in the line
  2468.                ┴ á╜ numbe≥ oµ character≤ iε thσ álinσ á(excludinτ ì
  2469. áááááááááááááááendinτ zero)
  2470.      Affected: AF¼ HL
  2471.      Usage:    BLIN┼ áperform≤ áthσ ásamσ átypσ áoµ áfunctioε áa≤ ì
  2472. áááááááááááááááBBLINE¼ ábu⌠ doe≤ no⌠ contaiε aε interna∞ ábuffer«  ì
  2473. áááááááááááááááYo⌡ áarσ expecteΣ t∩ providσ ß buffer¼ ástructureΣ ì
  2474. áááááááááááááááas:
  2475.                     SIZE║     DEF┬                ╗ sizσ oµ buffer
  2476.                     CCNT:     DEF╙      1
  2477.                     LINE:     DEFS                ╗ size of buffer + 1
  2478.                T∩ áusσ áBLINE¼ cal∞ i⌠ witΦ thσ áaddres≤ áoµ áthσ ì
  2479. ááááááááááááááábuffe≥ (SIZ┼ iε thσ example)¼ anΣ thσ ácapitalizaì
  2480. ááááááááááááááátioε áflag«  BLIN┼ return≤ ß pointe≥ t∩ thσ áfirs⌠ ì
  2481. ááááááááááááááábytσ áoµ áthσ linσ (LINE⌐ upoε return« á Thσ álinσ ì
  2482. ááááááááááááááástoreΣ iε thi≤ buffe≥ i≤ NU╠-terminated.
  2483.  
  2484.      Routine║   INLINE
  2485.      Function║ Independent input line editor
  2486.      Entry:    HL = pointer to input line buffer
  2487.                A = echo flag (A=0 for no echo, A<>0 to echo input)
  2488.      Exit:     None
  2489.      Affected: None
  2490.      Usage:    INLIN┼ essentiall∙ provide≤ al∞ oµ thσ conventioεì
  2491. áááááááááááááááa∞ áinpu⌠ linσ edito≥ functions«  I⌠ ái≤ ásomewha⌠ ì
  2492. ááááááááááááááámorσ áflexiblσ áthaε áBLIN┼ anΣ áBBLINE¼ ábu⌠ áthσ ì
  2493. ááááááááááááááátradeofµ ái≤ tha⌠ INLIN┼ take≤ u≡ morσ space« á Iµ ì
  2494. ááááááááááááááásecurit∙ i≤ no⌠ required¼ yo⌡ shoulΣ usσ BLIN┼ áo≥ ì
  2495. áááááááááááááááBBLIN┼ áinsteaΣ oµ INLINE«  Yo⌡ ma∙ edi⌠ thσ átex⌠ ì
  2496. áááááááááááááááa≤ yo⌡ typσ i⌠ witΦ thσ followinτ edito≥ commands:
  2497.                     ke∙       function
  2498.                     <BS>      Deletσ previou≤ characte≥ anΣ ábacδ ì
  2499. ááááááááááááááááááááááááááááááu≡ cursor
  2500.                    <DEL>      Delete previous character and echo it
  2501.                     <CR>      Inpu⌠ ácomplete¼ returε t∩ ácallinτ ì
  2502. ááááááááááááááááááááááááááááááprogram
  2503.                     <LF>      G∩ t∩ nex⌠ physica∞ line╗ addinτ áß ì
  2504. áááááááááááááááááááááááááááááá<CR><LF╛ t∩ buffer
  2505.                    <TAB>      Movσ to next tab stop (every ╕ spaces)
  2506.                     ^U        Erasσ álinσ (clea≥ buffer⌐ anΣ áreì
  2507. áááááááááááááááááááááááááááááástar⌠ inpu⌠ (samσ a≤ ^X)
  2508.                     ^X        Erasσ álinσ (clea≥ buffer⌐ anΣ áreì
  2509. áááááááááááááááááááááááááááááástar⌠ inpu⌠ (samσ a≤ ^U)
  2510.                     ^R        Retype current line
  2511.                     ^E        G∩ át∩ nex⌠ physica∞ line╗ adΣ ánoì
  2512. ááááááááááááááááááááááááááááááthinτ t∩ buffer
  2513.  
  2514.                Oε áexit¼ áthσ buffe≥ contain≤ áthσ átex⌠ áentereΣ ì
  2515. áááááááááááááááfolloweΣ b∙ ß <NUL╛ (binar∙ 0)╗ thσ <CR╛ typeΣ át∩ ì
  2516. áááááááááááááááenΣ thσ inpu⌠ i≤ no⌠ placeΣ iε thσ buffer.è
  2517.                INLIN┼ offer≤ tw∩ feature≤ no⌠ founΣ iε BLIN┼ áanΣ ì
  2518. áááááááááááááááBBLINE«  First¼ i⌠ canno⌠ bσ aborteΣ b∙ ß ^C╗ thi≤ ì
  2519. ááááááááááááááái≤ good¼ sincσ i⌠ caε bσ useΣ iε "secureó program≤ ì
  2520. áááááááááááááááwithou⌠ áfea≥ áoµ ábreakinτ ou⌠ áoµ áthσ áprogram«  ì
  2521. áááááááááááááááSecond¼ ái⌠ ácaε bσ madσ t∩ ech∩ o≥ no⌠ áech∩ áthσ ì
  2522. áááááááááááááááinput╗ thi≤ provide≤ somσ protectioε fo≥ inputtinτ ì
  2523. ááááááááááááááásensitivσ information¼ sucΦ a≤ passwords.
  2524.  
  2525.                ┴ áBE╠ ácharacte≥ (bee≡ oε console⌐ i≤ áoutpu⌠ áiµ ì
  2526. áááááááááááááááattemp⌠ ái≤ madσ t∩ deletσ character≤ witΦ áB╙ áo≥ ì
  2527. áááááááááááááááDE╠ beforσ thσ beginninτ oµ thσ line«  N∩ limi⌠ o≥ ì
  2528. áááááááááááááááerro≥ ácheckinτ i≤ madσ oε thσ sizσ oµ áthσ áinpu⌠ ì
  2529. ááááááááááááááálinσ ábuffer¼ s∩ yo⌡ shoulΣ madσ thσ buffe≥ áarbiì
  2530. ááááááááááááááátraril∙ álargσ t∩ avoiΣ buffe≥ overflow« á ┴ áhasΦ ì
  2531. ááááááááááááááámarδ (#⌐ i≤ printeΣ iε responsσ t∩ ^R¼ ^U¼ anΣ ^X.
  2532.  
  2533. STRIN╟ áAN─ SWITCHE─ OUTPUT:é  Thσ switcheΣ outpu⌠ serie≤ oµ árouì
  2534. tine≤ ái≤ ádifferen⌠ froφ thσ othe≥ serie≤ iε tha⌠ áthσ áswitcheΣ ì
  2535. outpu⌠ serie≤ use≤ ß globa∞ datß bytσ (SCTLF╠ ¡¡ ╙ Coεtro∞ áFlag⌐ ì
  2536. t∩ ádeterminσ áwherσ thσ outpu⌠ i≤ t∩ bσ routed« á It≤ áswitchinτ ì
  2537. function≤ are:
  2538.  
  2539.      SCTLFL:
  2540.                binary         hex       outputs to
  2541.                00000000Γ      00Φ       nothing
  2542.                00000001b      01h       console
  2543.                10000000b      80h       printer
  2544.                10000001b      81h       console and printer
  2545.  
  2546. Iµ áyo⌡ d∩ no⌠ initializσ thσ SCTLF╠ variablσ beforσ usinτ aε á╙-ì
  2547. routine¼ áoutpu⌠ wil∞ g∩ t∩ thσ consolσ (defaul⌠ valuσ oµ áSCTLF╠ ì
  2548. i≤ 01h).
  2549.  
  2550. An example of code using S-routines is:
  2551.           EX╘       SCTLFL,SADC,SOUT         ; declare routines/value
  2552.           ...
  2553.           LD        A,81H                    ; enable printer and console
  2554.           LD        (SCTLFL),A
  2555.           ...
  2556.           LD        A,32                     ; print number 32
  2557.           CALL      SADC
  2558.           ...
  2559.           LD        A,80H                    ; enable printer only
  2560.           LD        (SCTLFL),A
  2561.           ...
  2562.           LD        A,'D'                    ; print letter "D"
  2563.           CALL      SOUT
  2564.           ...
  2565. .paè     Routines║  PRINT ¼  EPRINT ¼  LPRINT ¼  SPRINT
  2566.      Function: PRIN╘ print≤ t∩ consolσ interpretinτ contro∞ charì
  2567. áááááááááááááááacters¼ áEPRIN╘ print≤ t∩ consolσ áonl∙ áexpandinτ ì
  2568. ááááááááááááááátabs¼ áLPRIN╘ print≤ t∩ printe≥ interpretinτ áconì
  2569. ááááááááááááááátro∞ ácharacters¼ SPRIN╘ print≤ t∩ switcheΣ á(conì
  2570. ááááááááááááááásole/printer⌐ interpretinτ contro∞ characters
  2571.      Entry:    stack ╜ points to NUL-terminated (binary 0) string
  2572.      Exit:     None (execution resumes at byte after ending NUL)
  2573.      Affected: None
  2574.      Usage:    Mos⌠ áofteε useΣ fo≥ "inlineó áprin⌠ árequirement≤ ì
  2575. áááááááááááááááwherσ áthσ átex⌠ string≤ arσ embeddeΣ áwithiε áthσ ì
  2576. áááááááááááááááexecutablσ ácode«  WitΦ thσ exceptioε áoµ áEPRINT¼ ì
  2577. ááááááááááááááácontro∞ character≤ othe≥ thaε TAB¼ BS¼ CR¼ LF¼ anΣ ì
  2578. áááááááááááááááBE╠ arσ outpu⌠ a≤ "^có sequences«  (Seσ ácharacte≥ ì
  2579. áááááááááááááááoutpu⌠ routines.)
  2580.      Example:
  2581.                EX╘       PRINT               ; declare the routine
  2582.                ...                           ; ..preceeding code
  2583.                CALL      PRINT               ; print the following string
  2584.                DEFB      'Hello World',0
  2585.                ...                           ; execution resumes here
  2586.  
  2587.      Routines║  PSTR ¼  EPSTR ¼  LPSTR ¼  SPSTR
  2588.      Function: PST╥ print≤ t∩ consolσ interpretinτ contro∞ ácharì
  2589. áááááááááááááááacters¼ áEPST╥ áprint≤ t∩ consolσ áonl∙ áexpandinτ ì
  2590. ááááááááááááááátabs¼ LPST╥ print≤ t∩ printe≥ interpretinτ contro∞ ì
  2591. ááááááááááááááácharacters¼ áSPST╥ print≤ t∩ áswitcheΣ á(console/ì
  2592. áááááááááááááááprinter⌐ interpretinτ contro∞ characters
  2593.      Entry:    HL = pointer to NUL-terminated (binary 0) string
  2594.      Exit:     HL = points to byte following NUL terminating string
  2595.      Affected: HL
  2596.      Usage:    Print≤ NU╠-terminateΣ string≤ froφ indexeΣ string≤ ì
  2597. áááááááááááááááo≥ remotel∙-locateΣ place≤ iε thσ codσ body«  WitΦ ì
  2598. áááááááááááááááthσ áexceptioε oµ EPSTR¼ contro∞ character≤ áothe≥ ì
  2599. áááááááááááááááthaε áTAB¼ BS¼ CR¼ LF¼ anΣ BE╠ arσ outpu⌠ a≤ á"^có ì
  2600. ááááááááááááááásequences«  (Seσ characte≥ outpu⌠ routines.)
  2601.  
  2602. FILENAM┼ áOUTPUT:é á Filenamσ outpu⌠ routine≤ describeΣ áherσ áarσ ì
  2603. useΣ át∩ displa∙ thσ filenamσ anΣ filetypσ storeΣ iε aε FC┬ iε áß ì
  2604. variet∙ áoµ forms«  Thesσ form≤ arσ denoteΣ iε thσ routinσ áname≤ ì
  2605. (xFNn⌐ as:
  2606.      xFN1 -- print filename in 12-character field, embedded spaces
  2607.      xFN2 -- print filename in n-character field, no spaces
  2608.      xFN3 -- print filename in 12-character field, trailing spaces
  2609.  
  2610. Thσ áfollowinτ áillustrate≤ ho≈ value≤ wil∞ bσ áoutpu⌠ áb∙ áthesσ ì
  2611. routines«  Thσ underscorσ characte≥ (_⌐ indicate≤ ß space.
  2612.  
  2613.     FCB name/type      xFN1            xFN2            xFN3
  2614.      FILENAMETYP     FILENAME.TYP    FILENAME.TYP    FILENAME.TYP
  2615.      MYFILE  TXT     MYFILE__.TXT    MYFILE.TXT      MYFILE.TXT__
  2616.      R       R       R_______.R__    R.R             R.R_________
  2617.      S               S_______.___    S.              S.__________
  2618.              T       ________.T__    .T              .T__________
  2619. .paèIε additioε t∩ thσ methoΣ oµ printinτ thσ filenamσ anΣ áfiletype¼ ì
  2620. eacΦ oµ thesσ routine≤ ha≤ ß prefi° t∩ it≤ name║  L¼ M¼ P¼ o≥ áS«  ì
  2621. Thesσ prefixe≤ indicatσ wherσ thσ outpu⌠ i≤ t∩ bσ sent«  ╠ áindiì
  2622. cate≤ áthσ printe≥ (o≥ LS╘ device)¼ ═ fo≥ memory¼ ╨ fo≥ thσ áconì
  2623. solσ (prin⌠ thσ output)¼ anΣ ╙ fo≥ ß switcheΣ outpu⌠ t∩ ánothing¼ ì
  2624. thσ console¼ thσ printer¼ o≥ both«  Thσ lis⌠ is:
  2625.  
  2626.   letter     example     outputs to
  2627.      ╠         LFN1      LST device (printer)
  2628.      M         MFN1      Memory pointed to by HL
  2629.      P         PFN1      CON device (console)
  2630.      S         SFN1      Switched output
  2631.  
  2632.      Routines║  LFNn ¼  PFNn ¼  SFNn  
  2633.      Function: LFNnÖ print≤ filenamσ t∩ printe≥ (LS╘ device)¼ PFNnÖ ì
  2634. áááááááááááááááprint≤ áfilenamσ át∩ consolσ á(CO╬ ádevice)¼ áSFNnÖ ì
  2635. áááááááááááááááprint≤ filenamσ t∩ switcheΣ (LST/CON⌐ devices
  2636.      Entry:    DE = address of FCB+1
  2637.      Exit:     None
  2638.      Affected: None
  2639.      Usage:    Print≤ áfilenamσ anΣ filetypσ informatioε áfroφ áß ì
  2640. áááááááááááááááFilσ áContro∞ Blocδ (FCB)«  Thσ nÖ iε áthσ ároutinσ ì
  2641. ááááááááááááááánamσ specifie≤ thσ methoΣ iε whicΦ t∩ displa∙ áthσ ì
  2642. áááááááááááááááinformation« á Value≤ áoµ nÖ arσ ▒ t∩ á3¼ áwherσ á▒ ì
  2643. áááááááááááááááprint≤ áfixeΣ á1▓-characte≥ outpu⌠ áwitΦ áembeddeΣ ì
  2644. áááááááááááááááspaces¼ ▓ print≤ variablσ lengtΦ (u≡ t∩ 1▓ áchars⌐ ì
  2645. áááááááááááááááwitΦ án∩ trailinτ spaces¼ anΣ │ print≤ áfixeΣ á1▓-ì
  2646. ááááááááááááááácha≥ áoutpu⌠ witΦ trailinτ spaces«  (Seσ áFilenamσ ì
  2647. áááááááááááááááOutpu⌠ above.)
  2648.  
  2649.      Routine║   MFNn
  2650.      Function║ Store filename in memory
  2651.      Entry:    DE = pointer to FCB+1
  2652.                H╠ ╜ pointe≥ t∩ memor∙ buffe≥ oµ a⌠ leas⌠ 1▓ charì
  2653. áááááááááááááááacters
  2654.      Exit:     None
  2655.      Affected: None
  2656.      Usage:    Store≤ ß filenamσ anΣ filetypσ iε memor∙ formatteΣ ì
  2657. áááááááááááááááa≤ áthσ routine≤ fo≥ consolσ anΣ áprinte≥ áoutput«  ì
  2658. áááááááááááááááThσ ásuffi° ánÖ iε thσ routinσ namσ áspecifie≤ áthσ ì
  2659. áááááááááááááááforφ áoµ áthσ informatioε wherσ wherσ ▒ ástore≤ áß ì
  2660. áááááááááááááááfixeΣ á1▓-characte≥ fielΣ witΦ embeddeΣ spaces¼ á▓ ì
  2661. ááááááááááááááástore≤ ß variablσ lengtΦ (u≡ t∩ 1▓ characters⌐ áiε ì
  2662. áááááááááááááááthσ fielΣ witΦ n∩ trailinτ spaces¼ anΣ │ store≤ áß ì
  2663. áááááááááááááááfixeΣ á1▓-characte≥ áfielΣ witΦ átrailinτ áspaces«  ì
  2664. ááááááááááááááá(Seσ áFilenamσ áOutpu⌠ above.⌐ MFN▒ anΣ áMFN│ áarσ ì
  2665. áááááááááááááááquitσ ástraigh⌠-forwarΣ t∩ usσ sincσ áthe∙ áalway≤ ì
  2666. áááááááááááááááfil∞ exactl∙ 1▓ byte≤ oµ memory«  Advancinτ t∩ thσ ì
  2667. ááááááááááááááánex⌠ bytσ afte≥ thσ las⌠ onσ useΣ i≤ quitσ simple¼ ì
  2668. áááááááááááááááa≤ showε by:
  2669.                          L─        DE,FCB+▒       ; point to Fn field
  2670.                          LD        HL,BUFFER      ; ..and to memory buffer
  2671.                          CALL      MFN1           ; store the name
  2672.                          LD        BC,12          ; skip to after last byte
  2673.                          ADD       HL,BC          ; ..by adding 12 to startè               MFN▓ i≤ no⌠ quitσ a≤ eas∙ t∩ usσ sincσ i⌠ fill≤ a⌠ ì
  2674. ááááááááááááááámos⌠ 1▓ bytes¼ bu⌠ coulΣ fil∞ les≤ thaε this«  Thσ ì
  2675. áááááááááááááááprobleφ áma∙ bσ overcomσ b∙ usinτ áß á1│-characte≥ ì
  2676. ááááááááááááááábuffe≥ anΣ thσ FILL┬ anΣ SKNS╨ routines¼ as:
  2677.                          LD        HL,BUFFER      ; point to buffer
  2678.                          LD        B,13           ; fill 13 bytes w/spaces
  2679.                          LD        A,' '
  2680.                          CALL      FILLB
  2681.                          LD        DE,FCB+1       ; point to Fn field
  2682.                          CALL      MFN2           ; ..and store
  2683.                          CALL      SKNSP          ; skip over non-spaces (HL now
  2684.                          ...                      ; ..points to byte after last)
  2685.  
  2686. CHARACTE╥-ORIENTE─ áINPUT/OUTPUT:é  Thi≤ se⌠ oµ routine≤ áprovide≤ ì
  2687. simplσ áI/╧ capabilitie≤ witΦ absolutel∙ n∩ sidσ effect≤ áoε áan∙ ì
  2688. registers«  Direc⌠ BIO╙ call≤ arσ useΣ oε al∞ routine≤ excep⌠ fo≥ ì
  2689. BIN¼ áBIST¼ anΣ BOUT¼ s∩ function≤ sucΦ a≤ ^╨ (whicΦ áarσ áimpleì
  2690. menteΣ b∙ thσ BDOS⌐ wil∞ no⌠ worδ b∙-anΣ-large.
  2691.  
  2692. The I/O capabilities provided by these routines include:
  2693.      Character input from console and reader
  2694.      Character output to console, printer, and punch
  2695.      Characte≥ outpu⌠ t∩ console¼ printer¼ anΣ puncΦ witΦ contro∞ ì
  2696. áááááááááácharacte≥ processing
  2697.      Console input status
  2698.      Conditional input
  2699.      New line (CRLF) output
  2700.      Capitalized character input
  2701.  
  2702. SwitcheΣ áoutpu⌠ i≤ provideΣ iε thi≤ se⌠ oµ routines╗ áthesσ áarσ ì
  2703. calleΣ thσ ╙-serie≤ oµ routines¼ anΣ arσ complementar∙ t∩ thσ á╙-ì
  2704. serie≤ numeriπ prin⌠ routines.
  2705.  
  2706. .ix SCTLFL (g)
  2707. Thσ á╙-serie≤ oµ routine≤ i≤ differen⌠ froφ thσ othe≥ áserie≤ áiε ì
  2708. tha⌠ áthσ ╙-serie≤ use≤ aε externa∞ datß bytσ t∩ determinσ áwherσ ì
  2709. thσ áoutpu⌠ i≤ t∩ bσ routed«  Thi≤ bytσ i≤ referreΣ t∩ a≤ áSCTLF╠ ì
  2710. (╙ áContro∞ Flag)¼ anΣ it≤ switchinτ functioε i≤ áillustrateΣ áiε ì
  2711. thσ followinτ table:
  2712.  
  2713.      SCTLFL:
  2714.                 binary        hex       outputs to
  2715.                00000000Γ      00Φ       nothing
  2716.                00000001b      01h       console
  2717.                10000000b      80h       printer
  2718.                10000001b      81h       console and printer
  2719.  
  2720. Iµ áyo⌡ d∩ no⌠ initializσ thσ SCTLF╠ variablσ beforσ usinτ aε á╙-ì
  2721. routine¼ outpu⌠ wil∞ g∩ t∩ thσ consolσ (thσ defaul⌠ i≤ 01h).
  2722.  
  2723. An example of code using S-routines is:
  2724.                EX╘       SCTLFL,SOU╘         ; SCTLFL flag, SOUT routine
  2725.                ...
  2726.                LD        A,81H               ; enable printer and console
  2727.                LD        (SCTLFL),A
  2728.                ...è               LD        A,'A'               ; print character 'A'
  2729.                CALL      SOUT
  2730.                ...
  2731.                LD        A,80H               ; enable printer only
  2732.                LD        (SCTLFL),A
  2733.                ...
  2734.                LD        A,'a'               ; print character 'a'
  2735.                CALL      SOUT
  2736.                ...
  2737.  
  2738.      Routine║   BIN
  2739.      Function║ BDOS console character input routine
  2740.      Entry:    None
  2741.      Exit:     A = character input from CON
  2742.      Affected: AF
  2743.      Usage:    Input≤ áß characte≥ froφ thσ consolσ áwitΦ ánorma∞ ì
  2744. áááááááááááááááBDO╙ processinτ (echo¼ ^╨ anΣ ^╙ sensing).
  2745.  
  2746.      Routine║   BIST
  2747.      Function║ BDOS character input status routine
  2748.      Entry:    None
  2749.      Exit:     A <> 0, zero flag clear (NZ) if character ready
  2750.                A = 0, zero flag set (Z) if no character
  2751.      Affected: AF
  2752.      Usage:    Return≤ thσ consolσ inpu⌠ statu≤ viß BDO╙ functioε ì
  2753. ááááááááááááááá11.
  2754.  
  2755.      Routine║   BOUT
  2756.      Function║ BDOS character output routine
  2757.      Entry:    A = character to send to console display
  2758.      Exit:     None
  2759.      Affected: None
  2760.      Usage:    Output≤ ß characte≥ t∩ thσ consolσ viß BDO╙ áfuncì
  2761. ááááááááááááááátioε 2.
  2762.  
  2763.      Routines║  CAPIN ¼  CAPINE
  2764.      Function║ Capitalized character input
  2765.      Entry:    None
  2766.      Exit:     A = capitalized character input from console
  2767.      Affected: AF
  2768.      Usage:    Wait≤ áfo≥ áaε inpu⌠ characte≥ froφ áthσ áconsole¼ ì
  2769. ááááááááááááááácapitalize≤ áit¼ anΣ return≤ i⌠ t∩ áyou≥ áprogram«  ì
  2770. áááááááááááááááCAPI╬ ásimpl∙ return≤ thσ ácapitalizeΣ ácharacter¼ ì
  2771. áááááááááááááááwhilσ áCAPIN┼ als∩ echoe≤ i⌠ t∩ thσ áconsolσ ádisì
  2772. áááááááááááááááplay.
  2773.  
  2774.      Routines║  CIN ¼  RIN
  2775.      Function: Inpu⌠ ß characte≥ froφ thσ consolσ o≥ reade≥ (auxì
  2776. áááááááááááááááiliar∙ device)
  2777.      Entry:    None
  2778.      Exit:     A = character from console (CIN) or reader (RIN)
  2779.      Affected: AF
  2780.      Usage:    Provide≤ characte≥ inpu⌠ function≤ witΦ BIO╙-leve∞ ì
  2781. áááááááááááááááinterface≤ áavoidinτ áBDO╙ processing« á The∙ áarσ ì
  2782. ááááááááááááááásomewha⌠ faste≥ iε responsσ thaε thei≥ BDO╙ ácounìèáááááááááááááááterparts.
  2783.  
  2784.      Routines║  COUT ¼  COUT7 ¼  LOUT ¼  POUT ¼  SOUT
  2785.      Function: COU╘ áoutput≤ áß characte≥ t∩ thσ áconsole¼ áCOUT╖ ì
  2786. áááááááááááááááoutput≤ ß characte≥ t∩ thσ consolσ strippinτ áhigΦ ì
  2787. ááááááááááááááábit¼ áLOU╘ output≤ ß characte≥ t∩ thσ lis⌠ ádevicσ ì
  2788. ááááááááááááááá(printer)¼ áPOU╘ output≤ ß characte≥ t∩ thσ ápuncΦ ì
  2789. ááááááááááááááá(auxiliary⌐ ádevice¼ SOU╘ output≤ ß ácharacte≥ át∩ ì
  2790. áááááááááááááááthσ switcheΣ (CON/LST⌐ output
  2791.      Entry:    A = character to send to output device
  2792.      Exit:     Nonσ á(COUT╖ return≤ characte≥ iε ┴ witΦ higΦ ábi⌠ ì
  2793. áááááááááááááááclear)
  2794.      Affected: AF
  2795.      Usage:    Fo≥ ádirec⌠ áBIO╙-leve∞ outpu⌠ withiε áß áprogram¼ ì
  2796. áááááááááááááááthesσ routine≤ avoiΣ thσ BDO╙ characte≥ trap≤ áanΣ ì
  2797. áááááááááááááááprocessing¼ anΣ arσ thereforσ somewha⌠ faste≥ thaε ì
  2798. áááááááááááááááBDO╙ routines«  COUT╖ i≤ identica∞ t∩ COU╘ áexcep⌠ ì
  2799. ááááááááááááááátha⌠ thσ higΦ-orde≥ bi⌠ i≤ strippeΣ froφ thσ áoutì
  2800. ááááááááááááááápu⌠ characte≥ beforσ passinτ i⌠ t∩ thσ driver.
  2801.  
  2802.      Routines║  CCOUT ¼  CLOUT ¼  CPOUT ¼  CSOUT
  2803.      Function: CCOU╘ áoutput≤ t∩ consolσ witΦ ácontro∞ ácharacte≥ ì
  2804. ááááááááááááááádisplay¼ CLOU╘ output≤ t∩ lis⌠ devicσ witΦ contro∞ ì
  2805. ááááááááááááááácharacte≥ ádisplay¼ CPOU╘ output≤ t∩ puncΦ ádevicσ ì
  2806. áááááááááááááááwitΦ ácontro∞ characte≥ display¼ CSOU╘ output≤ át∩ ì
  2807. áááááááááááááááswitcheΣ CON/LS╘ witΦ contro∞ characte≥ display
  2808.      Entry:    A = character to output
  2809.      Exit:     None
  2810.      Affected: Flags
  2811.      Usage:    Thesσ routine≤ shoulΣ bσ useΣ t∩ contro∞ áprintinτ ì
  2812. ááááááááááááááát∩ device≤ whicΦ ma∙ bσ disturbeΣ b∙ ánoε-printinτ ì
  2813. ááááááááááááááá(control⌐ ácharacters« á The∙ áfunctioε áa≤ áthei≥ ì
  2814. áááááááááááááááprimar∙ counterpart≤ fo≥ norma∞ printablσ ácharaπì
  2815. áááááááááááááááters¼ bu⌠ trea⌠ al∞ ASCI╔ code≤ les≤ thaε ß áspacσ ì
  2816. ááááááááááááááá(20H⌐ áexcep⌠ áfo≥ <NUL>¼ <BEL>¼ <BS>¼ á<LF>¼ áanΣ ì
  2817. ááááááááááááááá<CR╛ iε ß specia∞ manner«  Thesσ value≤ arσ outpu⌠ ì
  2818. áááááááááááááááa≤ áaε ácare⌠ (^⌐ followeΣ áb∙ áthσ ácorrespondinτ ì
  2819. ááááááááááááááálette≥ ágenerateΣ b∙ addinτ 40Φ t∩ áthσ ácharacte≥ ì
  2820. ááááááááááááááávaluσ (i.e.¼ ▒ output≤ a≤ "^A"¼ ▓ a≤ "^B"¼ etc.).
  2821.  
  2822.      Routine║   CONDIN
  2823.      Function║ Conditional console input
  2824.      Entry:    None
  2825.      Exit:     A = console character, zero clear (NZ) if present
  2826.                A indeterminate, zero set (Z) if n∩ character
  2827.      Affected: AF
  2828.      Usage:    Test≤ áfo≥ an∙ waitinτ characte≥ oε áthσ áconsole¼ ì
  2829. áááááááááááááááanΣ áreturn≤ it«  Iµ n∩ characte≥ i≤ waiting¼ áthσ ì
  2830. ááááááááááááááároutinσ return≤ ß flaτ indicatinτ tha⌠ n∩ ácharacì
  2831. áááááááááááááááte≥ wa≤ returned.
  2832. .paè     Routine║   CRLF ¼  LCRLF ¼  SCRLF
  2833.      Function: CRL╞ senΣ carriagσ returε anΣ linefeeΣ t∩ console¼ ì
  2834. áááááááááááááááLCRL╞ ásenΣ ácarriagσ returε anΣ linefeeΣ át∩ áLS╘ ì
  2835. ááááááááááááááá(printer)¼ SCRL╞ senΣ carriagσ returε anΣ linefeeΣ ì
  2836. ááááááááááááááát∩ switcheΣ output
  2837.      Entry:    None
  2838.      Exit:     None
  2839.      Affected: None
  2840.      Usage:    Send≤ áß ne≈ linσ combinatioε oµ ácarriagσ áreturε ì
  2841. áááááááááááááááanΣ álinefeeΣ t∩ thσ CO╬ (CRLF)¼ LS╘ á(LCRLF)¼ áo≥ ì
  2842. áááááááááááááááswitcheΣ outpu⌠ (SCRLF).
  2843.  
  2844.      Routine║   CST
  2845.      Function║ Return console status routine
  2846.      Entry:    None
  2847.      Exit:     A = 0, zero flag set (Z) if console data available
  2848.                A = 1, zero clear (NZ) if no data available
  2849.      Affected: AF
  2850.      Usage:    Quickl∙ ásample≤ thσ consolσ statu≤ witΦ ß ádirec⌠ ì
  2851. áááááááááááááááBIO╙ interface.
  2852.  
  2853. BRANCHING:é á Thσ routine≤ iε thi≤ sectioε dea∞ áwitΦ áconditiona∞ ì
  2854. branchinτ viß CASE¼ computeΣ GOTO¼ anΣ arithmetiπ I╞ áconstructs«  ì
  2855. Thσ followinτ examplσ illustrate≤ thσ CASE concept:
  2856.           [register A = key value]
  2857.                CAL╠      ACASE1
  2858.                DEFB      SIZE                ; number of entries in table
  2859.                DEFW      ERROR               ; ..go here if no match
  2860.                DEFB      VAL1                ; first value to test for
  2861.                DEFW      ADDR1               ; ..go here if A = VAL1
  2862.                DEFB      VAL2                ; 2nd value to test for
  2863.                DEFW      ADDR2               ; ..go here if A = VAL2
  2864.                ...
  2865.                DEFB      VALSIZE             ╗ 'SIZE' value to test for
  2866.                DEFW      ADDRSIZE            ; ..go here if A = VALSIZE
  2867.  
  2868. The following example illustrates the computed GOTO:
  2869.           [register A = index (zero-relative)]
  2870.                CALL      AGOTO1
  2871.                DEFW      ADDR0               ; go here if A = 0
  2872.                DEFW      ADDR1               ; go here if A = 1
  2873.                ...
  2874.                DEFW      ADDRN               ; go here if A = N
  2875.  
  2876. Thσ followinτ examplσ illustrate≤ thσ computeΣ GOT╧ witΦ limits:
  2877.           [register A = index (zero-relative)]
  2878.           [register B = limit]
  2879.                CALL      AGOTO1
  2880.                DEFW      ADDR0               ; go here if A = 0
  2881.                DEFW      ADDR1               ; go here if A = 1
  2882.                ...
  2883.                DEFW      ADDRN               ; go here if A = N
  2884.           [error code]                       ; ..come here if A > B
  2885. .paèThe following example illustrates the arithmetic IF:
  2886.           [register A = key value]
  2887.           [register B = test value]
  2888.                CALL      AIF1
  2889.                DEFW      ADDRLT              ; go here if A < B
  2890.                DEFW      ADDREQ              ; go here if A = B
  2891.                DEFW      ADDRGT              ; go here if A > B
  2892.  
  2893. The following routines are provided:
  2894.  
  2895.      ACASE▒ -¡ case statement with A = key value
  2896.      ACASE2 -¡ like ACASE1, but DE = address of case table
  2897.      ACASE3 -¡ like ACASE2, but return address is left on stack
  2898.  
  2899.      HCASE1 -¡ like ACASE1, but HL = key value
  2900.      HCASE2 -¡ like ACASE2, but HL = key value
  2901.      HCASE3 -¡ like ACASE3, but HL = key value
  2902.  
  2903.      AGOTO1 -¡ computed GOTO with A = key value
  2904.      AGOTO2 -¡ like AGOTO1, but JPs rather than DEFW follow
  2905.  
  2906.      HGOTO1 -¡ computed GOTO with HL = key value
  2907.      HGOTO2 -¡ like AGOTO2, but HL = key value
  2908.  
  2909.      BGOTO1 -¡ like AGOTO1, but B = limit value
  2910.      BGOTO2 -¡ like AGOTO2, but B = limit value
  2911.  
  2912.      DGOTO1 -¡ like HGOTO1, but DE = limit value
  2913.      DGOTO2 -¡ like HGOTO2, but DE = limit value
  2914.  
  2915.      AIF1 -¡ arithmetic IF with A, B = values
  2916.      AIF2 -¡ like AIF1, but JPs rather than DEFW follow
  2917.  
  2918.      HIF1 -¡ arithmetic IF with HL, DE = values
  2919.      HIF2 -¡ like AIF2, but HL, DE = values
  2920.  
  2921.      Routine║   ACASE1
  2922.      Function║ Multiway jump from A register value, embedded table
  2923.      Entry:    A = value to test for branch
  2924.      Exit:     None  (branch is made)
  2925.      Affected: None
  2926.      Usage:    ┴ casσ statemen⌠ processo≥ whicΦ act≤ a≤ ß ámultiì
  2927. áááááááááááááááwa∙ ájum≡ áinstruction¼ sincσ thσ áreturε áaddres≤ ì
  2928. áááááááááááááááfroφ áthσ ácal∞ t∩ ACASE▒ i≤ áno⌠ áretained« á Thσ ì
  2929. ááááááááááááááávaluσ át∩ átes⌠ i≤ compareΣ t∩ value≤ áiε áß ácasσ ì
  2930. ááááááááááááááátablσ anΣ contro∞ i≤ transferreΣ t∩ aε áassociateΣ ì
  2931. áááááááááááááááaddres≤ iµ ß matcΦ i≤ found.
  2932. Example:
  2933.                          LD        A,TEST
  2934.                          CALL      ACASE1
  2935.                          DEFB      N              ; number of entries in table
  2936.                          DEFW      DEFAULT        ; goto address if no match
  2937.                          DEFB      VAL1           ; test for TEST = VAL1
  2938.                          DEFW      ADDR1          ; go here if TEST = VAL1
  2939.                          ...è                         DEFB      VALN           ; test for TEST = VALN
  2940.                          DEFW      ADDRN          ; go here if TEST = VALN
  2941.  
  2942.      Routine:   ACASE2
  2943.      Function║ Multiway jump from A register value, external table
  2944.      Entry:    A = value to test for branch
  2945.                DE = address of case table
  2946.      Exit:     None (branch is made)
  2947.      Affected: None
  2948.      Usage:    ┴ casσ statemen⌠ processo≥ whicΦ act≤ a≤ ß ámultiì
  2949. áááááááááááááááwa∙ ájump« á Thσ returε addres≤ froφ thσ ácal∞ át∩ ì
  2950. áááááááááááááááACASE▓ ái≤ no⌠ retained«  Aε entr∙ valuσ ái≤ ácomì
  2951. ááááááááááááááápareΣ át∩ ávalue≤ iε aε externa∞ ácasσ átablσ áanΣ ì
  2952. ááááááááááááááácontro∞ ái≤ transferreΣ t∩ thσ associateΣ áaddres≤ ì
  2953. áááááááááááááááupoε ß match.
  2954.      Example:
  2955.                          L─        A,TEST         ; value to test for
  2956.                          LD        DE,TABLE       ; address of table
  2957.                          CALL      ACASE2
  2958.                          ...
  2959.                TABLE:    DEFB      N              ; number of entries in table
  2960.                          DEFW      DEFAULT        ; goto address if no match
  2961.                          DEFB      VAL1           ; test for TEST = VAL1
  2962.                          DEFW      ADDR1          ; go here if TEST = VAL1
  2963.                          ...
  2964.                          DEFB      VALN           ; test for TEST = VALN
  2965.                          DEFW      ADDRN          ; go here if TEST = VALN
  2966.  
  2967.      Routine:   ACASE3
  2968.      Function║ Multiway call from A register, external table
  2969.      Entry:    A = value to test for call
  2970.                DE = address of case table
  2971.      Exit:     None (branch is made)
  2972.      Affected: None
  2973.      Usage:    ACASE│ ái≤ ß casσ statemen⌠ processo≥ whicΦ áfuncì
  2974. ááááááááááááááátion≤ áa≤ áß multiwa∙ CAL╠ áinstructioε áwitΦ áthσ ì
  2975. áááááááááááááááreturε addres≤ froφ thσ cal∞ t∩ ACASE│ lef⌠ oε thσ ì
  2976. ááááááááááááááástack«  Thσ routinσ i≤ entereΣ witΦ ß valuσ áwhicΦ ì
  2977. ááááááááááááááái≤ ácompareΣ át∩ thosσ iε ß tablσ anΣ ácontro∞ ái≤ ì
  2978. ááááááááááááááátransferreΣ t∩ aε associateΣ addres≤ iµ ß matcΦ i≤ ì
  2979. ááááááááááááááámade.
  2980.      Example:
  2981.                          L─        A,TEST         ; value to test for
  2982.                          LD        DE,TABLE       ; address of table
  2983.                          CALL      ACASE3
  2984.                     [resume execution here if routines execute a RET instr]
  2985.                          ...
  2986.                TABLE:    DEFB      N              ; number of entries in table
  2987.                          DEFW      DEFAULT        ; ..go here if no match
  2988.                          DEFB      VAL1           ; test for TEST = VAL1
  2989.                          DEFW      ADDR1          ; ..go here if TEST = VAL1
  2990.                          ...
  2991.                          DEFB      VALN           ; test for TEST = VALN
  2992.                          DEFW      ADDRN          ; ..go here if TEST = VALN
  2993. .paè     Routine║   HCASE1
  2994.      Function║ Multiway jump from HL, embedded table
  2995.      Entry:    HL = value to test for
  2996.      Exit:     None (branch is made)
  2997.      Affected: None
  2998.      Usage:    ┴ casσ statemen⌠ processo≥ wherσ ß 1╢-bi⌠ valuσ i≤ ì
  2999. ááááááááááááááácompareΣ át∩ áentrie≤ iε ß table«  Upoε áß ámatch¼ ì
  3000. ááááááááááááááácontro∞ ái≤ transferreΣ t∩ aε associateΣ áaddress«  ì
  3001. áááááááááááááááThσ returε addres≤ froφ thσ CAL╠ t∩ HCASE▒ i≤ áno⌠ ì
  3002. áááááááááááááááretaineΣ makinτ thi≤ analagou≤ t∩ ß jum≡ áinstrucì
  3003. ááááááááááááááátion.
  3004. Example:
  3005.                          L─        HL,TEST
  3006.                          CALL      HCASE1
  3007.                          DEFW      N              ; number of entries in table
  3008.                          DEFW      DEFAULT        ; ..go here if no match
  3009.                          DEFW      VAL1           ; test for TEST = VAL1
  3010.                          DEFW      ADDR1          ; ..go here if TEST = VAL1
  3011.                          ...
  3012.                          DEFW      VALN           ; test for TEST = VALN
  3013.                          DEFW      ADDRN          ; ..go here if TEST = VALN
  3014.  
  3015.      Routine:   HCASE2
  3016.      Function║ Multiway jump from HL, external table
  3017.      Entry:    HL = value to test for
  3018.                DE = address of case table
  3019.      Exit:     None (branch is made)
  3020.      Affected: None
  3021.      Usage:    ┴ casσ statemen⌠ processo≥ wherσ ß 1╢-bi⌠ valuσ i≤ ì
  3022. ááááááááááááááácompareΣ át∩ entrie≤ iε aε addresseΣ table«  Iµ áß ì
  3023. ááááááááááááááámatcΦ i≤ found¼ contro∞ i≤ transferreΣ t∩ aε assoì
  3024. áááááááááááááááciateΣ addres≤ froφ thσ table«  Thσ returε addres≤ ì
  3025. áááááááááááááááfroφ áthσ CAL╠ t∩ HCASE▓ i≤ no⌠ retained¼ s∩ áthi≤ ì
  3026. ááááááááááááááároutinσ function≤ a≤ ß jump.
  3027.      Example:
  3028.                          LD        H,TEST         ; value to test for
  3029.                          LD        DE,TABLE       ; address of table
  3030.                          CALL      HCASE2
  3031.                          ...
  3032.                TABLE:    DEFW      N              ; number of entries in table
  3033.                          DEFW      DEFAULT        ; ..go here if no match
  3034.                          DEFW      VAL1           ; test for TEST = VAL1
  3035.                          DEFW      ADDR1          ; ..go here if TEST = VAL1
  3036.                          ...
  3037.                          DEFW      VALN           ; test for TEST = VALN
  3038.                          DEFW      ADDRN          ; ..go here if TEST = VALN
  3039.  
  3040.      Routine:   HCASE3
  3041.      Function║ Multiway call from HL, external table
  3042.      Entry:    HL = value to test for
  3043.                DE = address of case table
  3044.      Exit:     None (branch is made)
  3045.      Affected: None
  3046.      Usage:    ┴ casσ statemen⌠ processo≥ wherσ ß 1╢-bi⌠ valuσ i≤ ì
  3047. ááááááááááááááácompareΣ át∩ entrie≤ iε aε addresseΣ table«  Iß áß ìèááááááááááááááámatcΦ i≤ found¼ contro∞ i≤ transferreΣ t∩ aε assoì
  3048. áááááááááááááááciateΣ addres≤ froφ thσ table«  Thσ returε addres≤ ì
  3049. áááááááááááááááfroφ áthσ CAL╠ t∩ HCASE│ i≤ retaineΣ s∩ thi≤ árouì
  3050. ááááááááááááááátinσ function≤ a≤ ß call.
  3051.      Example:
  3052.                          LD        HL,TEST        ; value to test for
  3053.                          LD        DE,TABLE       ; address of table
  3054.                          CALL      HCASE3
  3055.                     [resume execution here if routines execute an RET instr]
  3056.                          ...
  3057.                TABLE║    DEF╫      N              ╗ numbe≥ oµ entrie≤ iε table
  3058.                          DEFW      DEFAULT        ; ..go here if no match
  3059.                          DEFW      VAL1           ; test for TEST = VAL1
  3060.                          DEFW      ADDR1          ; ..go here if TEST = VAL1
  3061.                          ...
  3062.                          DEFW      VALN           ; test for TEST = VALN
  3063.                          DEFW      ADDRN          ; ..go here if TEST = VALN
  3064.  
  3065.      Routine║   AGOTO1
  3066.      Function║ Computed GOTO on A register
  3067.      Entry:    A = index value (zero-relative)
  3068.      Exit:     None
  3069.      Affected: None
  3070.      Usage:    ┴ computeΣ GOT╧ baseΣ oε ß specifieΣ ╕-bi⌠ ávalue«  ì
  3071. áááááááááááááááN∩ árangσ o≥ limi⌠ checkinτ i≤ done¼ s∩ áyo⌡ ámus⌠ ì
  3072. áááááááááááááááinsurσ tha⌠ thσ computeΣ GOT╧ doe≤ no⌠ exceeΣ áthσ ì
  3073. ááááááááááááááátablσ limit.
  3074.      Example:
  3075.                          LD        A,INDEX        ; index value
  3076.                          CALL      AGOTO1
  3077.                          DEFW      ADDR0          ; go here if A = 0
  3078.                          DEFW      ADDR1          ; go here if A = 1
  3079.                          ...
  3080.                          DEFW      ADDRN          ; go here if A = N
  3081.  
  3082.      Routine:   AGOTO2
  3083.      Function║ Computed GOTO on A register
  3084.      Entry:    A = index value (zero-relative)
  3085.      Exit:     None
  3086.      Affected: None
  3087.      Usage:    ┴ computeΣ GOT╧ baseΣ oε ß specifieΣ ╕-bi⌠ ávalue«  ì
  3088. áááááááááááááááN∩ árangσ o≥ limi⌠ checkinτ i≤ done¼ s∩ áyo⌡ ámus⌠ ì
  3089. áááááááááááááááinsurσ tha⌠ thσ computeΣ GOT╧ doe≤ no⌠ exceeΣ áthσ ì
  3090. ááááááááááááááátablσ limit.
  3091.      Example:
  3092.                          LD        A,INDEX        ; index value
  3093.                          CALL      AGOTO2
  3094.                          JP        ADDR0          ; return to this JP if A = 0
  3095.                          JP        ADDR1          ; return to this JP if A = 1
  3096.                          ...
  3097.                          JP        ADDRN          ; return to this JP if A = N
  3098.                     [next instruction]            ; return here if A = N+1
  3099. .paè     Routine:   BGOTO1
  3100.      Function║ Computed GOTO on A register with limit check
  3101.      Entry:    A = index value (zero-relative)
  3102.                B = maximum index value allowed
  3103.      Exit:     None
  3104.      Affected: None
  3105.      Usage:    ┴ computeΣ GOT╧ baseΣ oε ß specifieΣ ╕-bi⌠ ávalue«  ì
  3106. ááááááááááááááá┴ seconΣ bytσ i≤ passeΣ specifyinτ ß limi⌠ ávalue«  ì
  3107. áááááááááááááááIµ áthσ tes⌠ valuσ exceed≤ thσ limit¼ ácontro∞ ái≤ ì
  3108. ááááááááááááááátransferreΣ át∩ afte≥ thσ las⌠ addres≤ iε thσ átaì
  3109. áááááááááááááááble.
  3110.      Example:
  3111.                          LD        A,INDEX        ; index value
  3112.                          L─        B,LIMI╘        ╗ maximuφ inde° value
  3113.                          CALL      BGOTO1
  3114.                          DEFW      ADDR0          ; go here if A = 0
  3115.                          DEFW      ADDR1          ; go here if A = 1
  3116.                          ...
  3117.                          DEFW      ADDRLIMIT      ; go here if A = LIMIT
  3118.                     [next instruction]            ; return here if A > LIMIT
  3119.  
  3120.      Routine:   BGOTO2
  3121.      Function║ Computed GOTO on A register with limit check
  3122.      Entry:    A = index value (zero-relative)
  3123.                B = maximum index value
  3124.      Exit:     None
  3125.      Affected: None
  3126.      Usage:    ┴ computeΣ GOT╧ baseΣ oε ß specifieΣ ╕-bi⌠ ávalue«  ì
  3127. ááááááááááááááá┴ seconΣ bytσ i≤ passeΣ specifyinτ ß limi⌠ ávalue«  ì
  3128. áááááááááááááááIµ áthσ tes⌠ valuσ exceed≤ thσ limit¼ ácontro∞ ái≤ ì
  3129. ááááááááááááááátransferreΣ át∩ afte≥ thσ las⌠ addres≤ iε thσ átaì
  3130. áááááááááááááááble.
  3131.      Example:
  3132.                          LD        A,INDEX        ; index value
  3133.                          L─        B,LIMI╘        ╗ maximuφ inde° value
  3134.                          CALL      BGOTO2
  3135.                          JP        ADDR0          ; return to this JP if A = 0
  3136.                          JP        ADDR1          ; return to this JP if A = 1
  3137.                          ...
  3138.                          JP        ADDRLIMIT      ; return to this JP if A=LIMIT
  3139.                     [next instruction▌            ; return here if A > LIMIT
  3140.  
  3141.      Routine║   HGOTO1
  3142.      Function║ Computed GOTO on HL register pair
  3143.      Entry:    HL = index value (zero-relative)
  3144.      Exit:     None
  3145.      Affected: None
  3146.      Usage:    ┴ computeΣ GOT╧ baseΣ oε ß specifieΣ 1╢-bi⌠ value«  ì
  3147. áááááááááááááááN∩ árangσ áo≥ limi⌠ check≤ arσ performed¼ ás∩ áyo⌡ ì
  3148. ááááááááááááááámus⌠ insurσ tha⌠ thσ rangσ oµ thσ computeΣ GOT╧ i≤ ì
  3149. áááááááááááááááno⌠ exceeded.
  3150.      Example:
  3151.                          L─        HL,INDEX       ; index value
  3152.                          CALL      HGOTO1
  3153.                          DEFW      ADDR0          ; go here if HL = 0è                         DEFW      ADDR1          ; go here if HL = 1
  3154.                          ...
  3155.                          DEFW      ADDRN          ; go here if HL = N
  3156.  
  3157.      Routine:   HGOTO2
  3158.      Function║ Computed GOTO on HL register pair
  3159.      Entry:    HL = index value (zero-relative)
  3160.      Exit:     None
  3161.      Affected: None
  3162.      Usage:    ┴ computeΣ GOT╧ baseΣ oε ß specifieΣ 1╢-bi⌠ value«  ì
  3163. áááááááááááááááN∩ árangσ áo≥ limi⌠ check≤ arσ performed¼ ás∩ áyo⌡ ì
  3164. ááááááááááááááámus⌠ insurσ tha⌠ thσ rangσ oµ thσ computeΣ GOT╧ i≤ ì
  3165. áááááááááááááááno⌠ exceeded.
  3166.      Example:
  3167.                          LD        HL,INDE╪       ; index value
  3168.                          CALL      HGOTO2
  3169.                          JP        ADDR0          ; return to this JP if HL = 0
  3170.                          JP        ADDR1          ; return to this JP if HL = 1
  3171.                          ...
  3172.                          JP        ADDRN          ; return to this JP if HL = N
  3173.                     [next instruction]            ; return here if HL = N+1
  3174.  
  3175.      Routine:   DGOTO1
  3176.      Function║ Computed GOTO on HL with limit check
  3177.      Entry:    HL = index value (zero-relative)
  3178.                DE = maximum index value allowed
  3179.      Exit:     None
  3180.      Affected: None
  3181.      Usage:    ┴ computeΣ GOT╧ baseΣ oε ß specifieΣ 1╢-bi⌠ value«  ì
  3182. ááááááááááááááá┴ áseconΣ á1╢-bi⌠ valuσ i≤ passeΣ áspecifyinτ áthσ ì
  3183. áááááááááááááááuppe≥ limi⌠ oµ computeΣ values«  Iµ thσ áspecifieΣ ì
  3184. ááááááááááááááátes⌠ ávaluσ exceed≤ thσ limi⌠ value¼ theε ácontro∞ ì
  3185. ááááááááááááááái≤ átransferreΣ t∩ afte≥ thσ las⌠ addres≤ áiε áthσ ì
  3186. ááááááááááááááátable.
  3187.      Example:
  3188.                          LD        HL,INDEX       ; index value
  3189.                          LD        DE,LIMIT       ; maximum index value
  3190.                          CALL      DGOTO1
  3191.                          DEFW      ADDR0          ; go here if HL = 0
  3192.                          DEFW      ADDR1          ; go here if HL = 1
  3193.                          ...
  3194.                          DEFW      ADDRLIMIT      ; go here if HL = LIMIT
  3195.                     [next instruction]            ; return here if HL > LIMIT
  3196.  
  3197.      Routine:   DGOTO2
  3198.      Function║ Computed GOTO on HL with limit check
  3199.      Entry:    HL = index value (zero-relative)
  3200.                DE = maximum index value
  3201.      Exit:     None
  3202.      Affected: None
  3203.      Usage:    ┴ computeΣ GOT╧ baseΣ oε ß specifieΣ 1╢-bi⌠ value«  ì
  3204. ááááááááááááááá┴ áseconΣ á1╢-bi⌠ valuσ i≤ passeΣ áspecifyinτ áthσ ì
  3205. áááááááááááááááuppe≥ limi⌠ oµ computeΣ values«  Iµ thσ áspecifieΣ ì
  3206. ááááááááááááááátes⌠ ávaluσ exceed≤ thσ limi⌠ value¼ theε ácontro∞ ì
  3207. ááááááááááááááái≤ átransferreΣ t∩ afte≥ thσ las⌠ addres≤ áiε áthσ ìèááááááááááááááátable.
  3208.      Example:
  3209.                          LD        HL,INDEX       ; index value
  3210.                          L─        DE,LIMI╘       ╗ maximuφ inde° value
  3211.                          CALL      DGOTO2
  3212.                          JP        ADDR0          ; return to this JP if HL = 0
  3213.                          JP        ADDR1          ; return to this JP if HL = 1
  3214.                          ...
  3215.                          JP        ADDRLIMIT      ; return to this JP if HL = LIMIT
  3216.                     [next instruction▌            ; return here if HL > LIMIT
  3217.  
  3218.      Routine║   AIF1
  3219.      Function║ Arithmetic IF on A register
  3220.      Entry:    A = test value
  3221.                B = key value
  3222.      Exit:     None
  3223.      Affected: None
  3224.      Usage:    Aε áarithmetiπ I╞ facilit∙ wherσ ß áspecifieΣ áke∙ ì
  3225. ááááááááááááááávaluσ (iε B⌐ i≤ compareΣ t∩ ß specifieΣ tes⌠ valuσ ì
  3226. ááááááááááááááá(iε áA)«  Branchinτ i≤ donσ dependinτ oε thσ áfolì
  3227. ááááááááááááááálowinτ tests║ ┴╝B¼ ┴╜B¼ anΣ ┴╛B.
  3228.      Example:
  3229.                          LD        A,TEST         ; test value
  3230.                          LD        B,KEY          ; key value
  3231.                          CALL      AIF1
  3232.                          DEFW      ALTB           ; go here if A<B
  3233.                          DEFW      AEQB           ; go here if A=B
  3234.                          DEFW      AGTB           ; go here if A>B
  3235.  
  3236.      Routine:   AIF2
  3237.      Function║ Arithmetic IF on A register
  3238.      Entry:    A = test value
  3239.                B = key value
  3240.      Exit:     None
  3241.      Affected: None
  3242.      Usage:    Aε áarithmetiπ I╞ facilit∙ wherσ ß áspecifieΣ áke∙ ì
  3243. ááááááááááááááávaluσ (iε B⌐ i≤ compareΣ t∩ ß specifieΣ tes⌠ valuσ ì
  3244. ááááááááááááááá(iε áA)«  Branchinτ i≤ donσ dependinτ oε thσ áfolì
  3245. ááááááááááááááálowinτ tests║ A<B¼ A=B¼ anΣ A>B.
  3246.      Example:
  3247.                          LD        A,TEST         ; test value
  3248.                          LD        B,KEY          ; key value
  3249.                          CALL      AIF2
  3250.                          JP        ALTB           ; resume at this JP if A<B
  3251.                          JP        AEQB           ; resume at this JP if A=B
  3252.                          JP        AGTB           ; resume at this JP if A>B
  3253. .paè     Routine║   HIF1
  3254.      Function║ Arithmetic IF on HL register pair
  3255.      Entry:    HL = test value
  3256.                DE = key value
  3257.      Exit:     None
  3258.      Affected: None
  3259.      Usage:    Aε áarithmetiπ I╞ facilit∙ wherσ ß áspecifieΣ áke∙ ì
  3260. ááááááááááááááávaluσ á(iε áDE⌐ i≤ compareΣ t∩ áß áspecifieΣ átes⌠ ì
  3261. ááááááááááááááávaluσ (iε HL)«  Branchinτ i≤ donσ dependinτ oε thσ ì
  3262. áááááááááááááááfollowinτ tests║ HL<DE¼ HL=DE¼ anΣ HL>DE.
  3263.      Example:
  3264.                          LD        HL,TEST        ; test value
  3265.                          LD        DE,KEY         ; key value
  3266.                          CALL      HIF1
  3267.                          DEFW      HLTD           ; go here if HL<DE
  3268.                          DEFW      HEQD           ; go here if HL=DE
  3269.                          DEFW      HGTD           ; go here if HL>DE
  3270.  
  3271.      Routine:   HIF2
  3272.      Function║ Arithmetic IF on HL register pair
  3273.      Entry:    HL = test value
  3274.                DE = key value
  3275.      Exit:     None
  3276.      Affected: None
  3277.      Usage:    Aε áarithmetiπ I╞ facilit∙ wherσ ß áspecifieΣ áke∙ ì
  3278. ááááááááááááááávaluσ á(iε áDE⌐ i≤ compareΣ t∩ áß áspecifieΣ átes⌠ ì
  3279. ááááááááááááááávaluσ (iε HL)«  Branchinτ i≤ donσ dependinτ oε thσ ì
  3280. áááááááááááááááfollowinτ tests║ HL<DE¼ HL=DE¼ anΣ HL>DE.
  3281.      Example:
  3282.                          LD        HL,TEST        ; test value
  3283.                          LD        DE,KEY         ; key value
  3284.                          CALL      HIF2
  3285.                          JP        HLTD           ; resume at this JP if HL<DE
  3286.                          JP        HEQD           ; resume at this JP if HL=DE
  3287.                          JP        HGTD           ; resume at this JP if HL>DE
  3288. .paèPARSIN╟ AIDS:
  3289.  
  3290. UNIX-STYLE ARGC/ARGV STRIN╟ PARSING:
  3291.  
  3292.      Routine║   ARGV
  3293.      Function║ UNIX-style ARGC/ARGV string parser
  3294.      Entry:    HL = address of NUL-terminated string to parse
  3295.                DE = address of token table
  3296.                A <> 0 if NUL is to be placed after each token
  3297.                A = 0 if NUL not to be placed after each token
  3298.      Exit:     A = 0, zero flag set (Z) if no error
  3299.                ┴ á<╛ 0¼ zer∩ flaτ rese⌠ (NZ⌐ iµ morσ token≤ áthaε ì
  3300. áááááááááááááááalloweΣ (las⌠ tokeε pointe≥ point≤ t∩ thσ res⌠ áoµ ì
  3301. áááááááááááááááthσ string)
  3302.      Affected: AF
  3303.      Usage:    Isolate≤ átoken≤ áwithiε ß strinτ áfo≥ ásubsequen⌠ ì
  3304. áááááááááááááááaction¼ ásucΦ áa≤ filenamσ áo≥ áargumen⌠ áparsing«  ì
  3305. áááááááááááááááToken≤ áarσ ádelimiteΣ b∙ space≤ áanΣ átabs« á Fo≥ ì
  3306. áááááááááááááááexample:
  3307.                     "  THIS     IS    FUN  "
  3308.                contain≤ threσ tokens¼ anΣ ARG╓ wil∞ returε pointì
  3309. áááááááááááááááer≤ t∩ thσ "Tó iε "THIS"¼ thσ "Ió iε "IS"¼ anΣ thσ ì
  3310. ááááááááááááááá"Fó iε "FUN"«  Iµ ┴ <╛ ░ oε input¼ ARG╓ wil∞ storσ ì
  3311. ááááááááááááááábinar∙ 0'≤ (NUL's⌐ ove≥ thσ firs⌠ spacσ afte≥ áthσ ì
  3312. ááááááááááááááá"Só áiε á"THIS"¼ thσ "Só iε "IS"¼ anΣ thσ á"Nó áiε ì
  3313. ááááááááááááááá"FUN"«  N∩ change≤ arσ madσ t∩ thσ strinτ iµ ┴ ╜ ░ ì
  3314. áááááááááááááááoε entry.
  3315.  
  3316.                ARG╓ i≤ calleΣ witΦ thσ addres≤ oµ ß tablσ ástrucì
  3317. ááááááááááááááátureΣ as:
  3318.                              DEFB      MAXEN╘  ; number of token pointers
  3319.                     filled / DEFS      1       ; number of tokens found by ARGV
  3320.                       in   | DEFS      2       ; pointer to token 1 (in string)
  3321.                       by   | DEFS      2       ; pointer to token 2 (in string)
  3322.                      ARGV  | ...
  3323.                            \ DEFS      2       ; Ptr to token MAXENT (in string)
  3324.                Iµ átherσ werσ morσ token≤ iε thσ strinτ thaε áalì
  3325. áááááááááááááááloweΣ áiε thσ tokeε table¼ ARG╓ return≤ witΦ áA<>░ ì
  3326. áááááááááááááááanΣ áthσ zer∩ flaτ rese⌠ (NZ)«  Iε thi≤ case¼ áthσ ì
  3327. ááááááááááááááálas⌠ átokeε pointe≥ point≤ t∩ thσ las⌠ átokeε áalì
  3328. ááááááááááááááálowed¼ anΣ extend≤ t∩ thσ enΣ oµ thσ string« á Thσ ì
  3329. áááááááááááááááNU╠ ái≤ áno⌠ placeΣ afte≥ thσ las⌠ token¼ ás∩ áthσ ì
  3330. áááááááááááááááres⌠ oµ thσ strinτ appear≤ a≤ ß singlσ tokeε á(anΣ ì
  3331. áááááááááááááááma∙ bσ parseΣ b∙ ARG╓ again).
  3332. .paèCAPITALIZATION:
  3333.  
  3334.      Routine║   CAPS
  3335.      Function║ Capitalize a character
  3336.      Entry:    A = character to capitalize
  3337.      Exit:     A = capitalized character
  3338.      Affected: AF
  3339.      Usage:    Return≤ áthσ áuppercasσ versioε oµ áan∙ álowercasσ ì
  3340. áááááááááááááááASCI╔ characte≥ specified«  Character≤ othe≥ áthaε ì
  3341. áááááááááááááááthosσ áiε thσ se⌠ [ß-z▌ arσ áreturneΣ áunaffected«  ì
  3342. áááááááááááááááIµ thσ characte≥ i≤ ß lowercasσ alphabetiπ charaπì
  3343. áááááááááááááááter¼ ái⌠ ái≤ áconverteΣ t∩ Uppercasσ áiε áthσ áse⌠ ì
  3344. ááááááááááááááá[A..Z]«  Onl∙ thσ lowe≥ seveε bit≤ oµ thσ bytσ arσ ì
  3345. áááááááááááááááconsidered¼ áanΣ áthσ ámos⌠ ásignifican⌠ ábi⌠ áái≤ ì
  3346. ááááááááááááááázeroed.
  3347.  
  3348.      Routine║   CAPSTR
  3349.      Function║ Capitalize a string
  3350.      Entry:    HL = pointer to first byte of a string
  3351.      Exit:     None (string is capitalized)
  3352.      Affected: None
  3353.      Usage:    Capitalize≤ áß NU╠-terminateΣ strinτ specifieΣ áiε ì
  3354. áááááááááááááááthσ callinτ parameters.
  3355.  
  3356. CHARACTE╥ TES╘ ROUTINES:é  Characte≥ tes⌠ routine≤ checδ thσ specì
  3357. ifieΣ ASCI╔ characte≥ (afte≥ maskinτ ofµ thσ higΦ bit⌐ t∩ seσ áiµ ì
  3358. i⌠ meet≤ ß specifieΣ condition«  Al∞ routine≤ conforφ t∩ thσ samσ ì
  3359. convention≤.
  3360.  
  3361.      Routines║  ISALNUM ¼  ISALPHA ¼  ISCTRL ¼  ISDIGIT ¼  ISGRAPH ¼  ISHEX ¼ ì
  3362. ááááááááááááááá ISPRINT ¼  ISPUN ¼  ISSP
  3363.      Function║ Tes⌠ fo≥ specifiπ type≤ oµ characters
  3364.      Entry:    A = character to test
  3365.      Exit║     ┴ ╜ character¼ zer∩ flaτ se⌠ (Z⌐ iµ conditioε true
  3366.                Zero flag reset (NZ) if condition false
  3367.      Affected: Flags
  3368.      Usage:    ISALNU═ test≤ fo≥ aε alphanumeriπ characte≥ á(┴-Z¼ ì
  3369. áááááááááááááááß-z¼ ░-9)¼ ISALPH┴ test≤ fo≥ aε alphabetiπ characì
  3370. áááááááááááááááte≥ (┴-Z¼ ß-z)¼ ISCTR╠ test≤ fo≥ ß contro∞ characì
  3371. áááááááááááááááte≥ á(les≤ thaε SP¼ o≥ DEL)¼ ISDIGI╘ test≤ áfo≥ áß ì
  3372. ááááááááááááááádigi⌠ (░-9)¼ ISGRAP╚ test≤ fo≥ ß graphiπ characte≥ ì
  3373. ááááááááááááááá(betweeε S╨ anΣ DEL)¼ ISHE╪ test≤ fo≥ ß áhexadeciì
  3374. áááááááááááááááma∞ characte≥ (░-9¼ ┴-F¼ ß-f)¼ ISPRIN╘ test≤ fo≥ ß ì
  3375. áááááááááááááááprintablσ characte≥ (betweeε S╨ anΣ DEL¼ includinτ ì
  3376. áááááááááááááááSP)¼ ISPU╬ test≤ fo≥ ß punctuatioε characte≥ á(beì
  3377. ááááááááááááááátweeε áS╨ anΣ DEL¼ inc∞ DEL¼ bu⌠ no⌠ ░-9¼ ┴-Z¼ áo≥ ì
  3378. áááááááááááááááß-z)¼ áISS╨ test≤ fo≥ ß spacσ characte≥ á(HT¼ áLF¼ ì
  3379. áááááááááááááááVT¼ FF¼ CR¼ anΣ SP)
  3380. .paèCHARACTE╥ áSKI╨ áROUTINES:é Thesσ routine≤ arσ useΣ t∩ áski≡ áove≥ ì
  3381. character≤ áiε thσ strinτ specifieΣ unti∞ eithe≥ ß ácharacte≥ áoµ ì
  3382. thσ átypσ áno⌠ ábeinτ skippeΣ i≤ encountereΣ o≥ thσ áenΣ áoµ áthσ ì
  3383. strinτ á(NU╠ character⌐ i≤ found«  The∙ al∞ conforφ t∩ áthσ ásamσ ì
  3384. parameter≤ as:
  3385.  
  3386.      Routines║  SKNPUN ¼  SKNSP ¼  SKPUN ¼  SKSP
  3387.      Function║ Ski≡ ove≥ specifiπ typσ oµ character
  3388.      Entry:    H╠ ╜ pointe≥ t∩ firs⌠ characte≥ iε áNU╠-terminateΣ ì
  3389. ááááááááááááááástring
  3390.      Exit:     HL = pointer to character which terminated skip
  3391.      Affected: HL
  3392.      Usage:    SKNPU╬ áskip≤ áove≥ ánoε-punctuatioε áácharacters¼ ì
  3393. áááááááááááááááSKNS╨ skip≤ ove≥ noε-spacσ characters¼ SKPU╬ skip≤ ì
  3394. áááááááááááááááove≥ punctuatioε characters¼ SKS╨ skip≤ ove≥ spacσ ì
  3395. ááááááááááááááácharacters« á Punctuatioε ácharacter≤ áarσ ááthosσ ì
  3396. ááááááááááááááábetweeε S╨ anΣ DE╠ whicΦ arσ no⌠ ░-9¼ ┴-Z¼ o≥ ß-z«  ì
  3397. áááááááááááááááSpacσ ácharacter≤ arσ an∙ oµ thσ se⌠ HT¼ áLF¼ áVT¼ ì
  3398. áááááááááááááááFF¼ CR¼ o≥ SP.
  3399.  
  3400. GENERA╠ áPURPOS┼ ARITHMETIC:é  Thesσ routine≤ arσ fo≥ á1╢-bi⌠ áunì
  3401. signeΣ arithmetic«  Al∞ usσ H╠ a≤ thσ accumulato≥ o≥ thσ áresult¼ ì
  3402. anΣ H╠ anΣ D┼ contaiε thσ operand≤ requireΣ (iµ onl∙ onσ áoperanΣ ì
  3403. i≤ needed¼ H╠ i≤ used).
  3404.  
  3405. The available routines are:
  3406.  
  3407.      ADDH─ -¡ HL = HL + DE
  3408.      SUBHD -¡ HL = HL - DE
  3409.      MULHD -¡ HL = HL * DE
  3410.      DIVHD -¡ HL = HL / DE
  3411.      NEGH -¡ HL = 2's complement of HL
  3412.      CMPH -¡ HL = 1's complement of HL
  3413.      ROTLH -¡ HL is rotated left one bit position
  3414.      ROTRH -¡ HL is rotated right one bit position
  3415.      SHFTLH -¡ HL is shifted left one bit position
  3416.      SHFTRH -¡ HL is shifted right one bit position
  3417.      ANDHD -¡ HL = HL AND DE
  3418.      ORHD -¡ HL = HL OR DE
  3419.      XORHD -¡ HL = HL XOR DE
  3420.  
  3421. The carry flag is frequently used to indicate overflow.
  3422.  
  3423.      Routine║   ADDHD
  3424.      Function║ 16-bit addition
  3425.      Entry:    HL = operand 1
  3426.                DE = operand 2
  3427.      Exit:     HL = operand 1 + operand 2
  3428.                Carry set (C) if overflow, otherwise clear (NC)
  3429.      Affected: F¼ HL
  3430.      Usage:    This routine is not really needed since a simple
  3431.                     AD─  HL,DE
  3432.                instructioε accomplishe≤ thσ samσ thinτ witΦ áonl∙ ì
  3433. áááááááááááááááonσ bytσ insteaΣ oµ ß │-bytσ call.
  3434. è     Routine║   SUBHD
  3435.      Function║ 16-bit subtraction
  3436.      Entry:    HL = minuend
  3437.                DE = subtrahend
  3438.      Exit:     HL = minuend - subtrahend
  3439.                Carry set (C) if DE > HL, otherwise clear (NC)
  3440.      Affected: F¼ HL
  3441.      Usage:    Thi≤ routinσ i≤ n∩ longe≥ needeΣ witΦ Z8░ áprocesì
  3442. ááááááááááááááásor≤ sincσ the
  3443.                     SB├  HL,DE
  3444.                operatioε áaccomplishe≤ thσ samσ functioε áwithou⌠ ì
  3445. áááááááááááááááresortinτ t∩ ß functioε call.
  3446.  
  3447.      Routine║   MULHD
  3448.      Function║ 16-bit multiplication
  3449.      Entry:    HL = operand 1
  3450.                DE = operand 2
  3451.      Exit:     HL = operand 1 times operand 2
  3452.                Carry set (C) if result is > 65535
  3453.      Affected: F¼ HL
  3454.      Usage:    Multiplie≤ átw∩ ánumbers« á I⌠ ái≤ áoptimizeΣ áfo≥ ì
  3455. áááááááááááááááspeed¼ áwitΦ áß mino≥ sacrificσ oε ásize¼ áanΣ ái⌠ ì
  3456. áááááááááááááááalway≤ átake≤ 1╢ loop≤ t∩ perforφ an∙ ámultiplicaì
  3457. ááááááááááááááátion.
  3458.  
  3459.      Routine║   DIVHD
  3460.      Function║ 16-bit division
  3461.      Entry:    HL = dividend
  3462.                DE = divisor
  3463.      Exit:     HL = HL / DE
  3464.      Affected: HL
  3465.      Usage:    Divide≤ átw∩ numbers«  I⌠ i≤ optimizeΣ fo≥ áspeed¼ ì
  3466. áááááááááááááááwitΦ áß mino≥ sacrificσ oε size¼ anΣ alway≤ átake≤ ì
  3467. ááááááááááááááá1╢ loop≤ t∩ perforφ an∙ division.
  3468.  
  3469.      Routine║   NEGH
  3470.      Function║ Two's complement (negate) a 16-bit number
  3471.      Entry:    HL = 16-bit operand
  3472.      Exit:     HL = two's complement of operand
  3473.      Affected: HL
  3474.      Usage:    Return≤ thσ 2'≤ complemen⌠ oµ ß 1╢-bi⌠ number.
  3475.  
  3476.      Routine║   CMPH
  3477.      Function║ One's complement a 16-bit number
  3478.      Entry:    HL = 16-bit operand
  3479.      Exit:     HL = one's complement of operand
  3480.      Affected: HL
  3481.      Usage:    Return≤ thσ 1'≤ complemen⌠ oµ ß 1╢-bi⌠ number.
  3482. .paè     Routine║   ANDHD
  3483.      Function║ Logically AND two 16-bit values
  3484.      Entry:    HL = operand 1
  3485.                DE = operand 2
  3486.      Exit:     HL = bitwise logical AND of two operands
  3487.      Affected: HL
  3488.      Usage:    Perform≤ áthσ specifieΣ Booleaε operatioε áoε áthσ ì
  3489. ááááááááááááááátw∩ supplieΣ 1╢-bi⌠ values¼ anΣ returε thσ result.
  3490.  
  3491.      Routine:   ORHD
  3492.      Function║ Logically OR two 16-bit values
  3493.      Entry:    HL = operand 1
  3494.                DE = operand 2
  3495.      Exit:     H╠ ╜ bitwise logical OR of two operands
  3496.      Affected: HL
  3497.      Usage:    Perform≤ áthσ specifieΣ Booleaε operatioε áoε áthσ ì
  3498. ááááááááááááááátw∩ supplieΣ 1╢-bi⌠ values¼ anΣ returε thσ result.
  3499.  
  3500.      Routine║   XORHD
  3501.      Function║ Logically XOR two 16-bit values
  3502.      Entry:    HL = operand 1
  3503.                DE = operand 2
  3504.      Exit:     H╠ ╜ bitwise logical XOR of two operands (XORHD)
  3505.      Affected: HL
  3506.      Usage:    Perform≤ áthσ specifieΣ Booleaε operatioε áoε áthσ ì
  3507. ááááááááááááááátw∩ supplieΣ 1╢-bi⌠ values¼ anΣ returε thσ result.
  3508.  
  3509.      Routines║  ROTLH ¼  ROTRH
  3510.      Function: ROTL╚ ádoe≤ áß onσ bi⌠ righ⌠ árotatioε áoµ á1╢-bi⌠ ì
  3511. ááááááááááááááávalue¼ áROTR╚ doe≤ ß onσ bi⌠ lef⌠ rotatioε oµ á1╢-ì
  3512. ááááááááááááááábi⌠ value
  3513.      Entry:    HL = 16-bit operand to rotate
  3514.      Exit:     HL = rotated operand left (ROTLH) or right (ROTRH)
  3515.      Affected: HL
  3516.      Usage:    Rotate≤ thσ furnisheΣ 1╢-bi⌠ valuσ lef⌠ (ROTLH⌐ o≥ ì
  3517. ááááááááááááááárigh⌠ (ROTRH⌐ onσ bi⌠ position«  Thesσ arσ ácircuì
  3518. ááááááááááááááála≥ rotates¼ iε whicΦ thσ mos⌠ significan⌠ bi⌠ áoµ ì
  3519. ááááááááááááááá╚ i≤ rotateΣ int∩ thσ leas⌠ significan⌠ bi⌠ áposiì
  3520. ááááááááááááááátioε oµ ╠ (ROTLH)¼ anΣ leas⌠ significan⌠ bi⌠ oµ á╠ ì
  3521. ááááááááááááááái≤ rotateΣ int∩ thσ mos⌠ significan⌠ bi⌠ ápositioε ì
  3522. áááááááááááááááoµ ╚ (ROTRH).
  3523.  
  3524.      Routines║  SHFTLH ¼  SHFTRH
  3525.      Function: SHFTL╚ doe≤ ß onσ bi⌠ righ⌠ shif⌠ oµ 1╢-bi⌠ value¼ ì
  3526. ááááááááááááááázer∩ fill¼ SHFTR╚ doe≤ ß onσ bi⌠ lef⌠ shif⌠ oµ 1╢-ì
  3527. ááááááááááááááábi⌠ value¼ zer∩ fill
  3528.      Entry:    HL = 16-bit operand to shift
  3529.      Exit:     HL = shifted operand left (SHFTLH) or right (SHFTRH)
  3530.      Affected: HL
  3531.      Usage:    Shift≤ thσ furnisheΣ 1╢-bi⌠ valuσ lef⌠ (SHFTLH⌐ o≥ ì
  3532. ááááááááááááááárigh⌠ á(SHFTRH⌐ áonσ ábi⌠ ápositioε áfillinτ ááthσ ì
  3533. ááááááááááááááácleareΣ ápositioε witΦ ß zero«  Iε SHFTLH¼ áH╠ ái≤ ì
  3534. áááááááááááááááshifteΣ lef⌠ onσ bi⌠ positioε witΦ thσ leas⌠ ásigì
  3535. ááááááááááááááánifican⌠ bi⌠ oµ ╠ filleΣ witΦ ß zero«  Iε áSHFTRH¼ ì
  3536. áááááááááááááááH╠ i≤ shifteΣ righ⌠ onσ bi⌠ positioε witΦ thσ mos⌠ ìèááááááááááááááásignifican⌠ ábi⌠ oµ ╚ filleΣ witΦ ß zero« á SHFTL╚ ì
  3537. ááááááááááááááái≤ equivalen⌠ t∩ thσ morσ efficien⌠ singlσ byte
  3538.                     AD─  HL,HL
  3539.                operatioε áanΣ áSHFTR╚ i≤ equivalen⌠ t∩ áthσ áfou≥ ì
  3540. ááááááááááááááábytσ Z8░ sequence:
  3541.                     SRL  H
  3542.                     RR   L
  3543.  
  3544. CR├ áCALCULATION:é  Thσ CR├ routine≤ ma∙ bσ useΣ t∩ checδ thσ ávaì
  3545. lidit∙ oµ aε incominτ seria∞ bytσ streaφ o≥ checδ fo≥ validit∙ oµ ì
  3546. datß ácopies« á Thesσ routine≤ computσ anΣ checδ áß átruσ á1╢-bi⌠ ì
  3547. cycliπ redundanc∙ codσ (CRC).
  3548.  
  3549. Thσ usσ oµ thesσ routine≤ wil∞ guaranteσ detectioε oµ al∞ singlσ-ì
  3550. bi⌠ anΣ doublσ-bi⌠ errors¼ al∞ error≤ witΦ aε odΣ numbe≥ oµ erro≥ ì
  3551. bits¼ al∞ burs⌠ error≤ oµ lengtΦ 1╢ o≥ less¼ 99.9969Ñ oµ al∞ á1╖-ì
  3552. bi⌠ áerro≥ ábursts¼ áanΣ 99.9984Ñ oµ al∞ ápossiblσ álonge≥ áerro≥ ì
  3553. bursts.
  3554.  
  3555. CR├ áanΣ CRC│ routine≤ usσ thσ X^1╢ ½ X^1▓ ½ X^╡ ½ á▒ ápolynomia∞ ì
  3556. commonl∙ useΣ iε flopp∙ disδ controller≤ anΣ modeφ programs«  Thσ ì
  3557. CRC▒ routinσ use≤ thσ X^1╢ ½ X^1╡ ½ X^▓ ½ ▒ polynomia∞ als∩ áuseΣ ì
  3558. iε synchronou≤ communications«  CRC▓ use≤ thσ X^1╢ ½ X^1╡ ½ áX^1│ ì
  3559. ½ X^╖ ½ X^┤ ½ X^▓ ½ ╪ ½ ▒ polynomia∞ founΣ iε publiπ-domaiε áfilσ ì
  3560. CR├ checkinτ programs.
  3561.  
  3562. Al∞ áfou≥ familie≤ oµ routine≤ arσ useΣ iε thσ samσ áway¼ áexcep⌠ ì
  3563. tha⌠ ß uniquσ initializatioε routine¼ CRC3INIT¼ i≤ requireΣ áwitΦ ì
  3564. CRC│ ábeforσ áan∙ processinτ i≤ performed«  Thi≤ i≤ ábecausσ áthσ ì
  3565. CRC│ updatσ routinσ i≤ tablσ-driveε compareΣ t∩ thσ other≤ áwhicΦ ì
  3566. calculatσ áthσ áCR├ "oε thσ fly"«  Thσ addeΣ routinσ ábuild≤ áthσ ì
  3567. tablσ oµ prσ-computeΣ remainders«  Typica∞ usσ is:
  3568. 
  3569.      CRCMAKE:                                ; call CRC3INIT here if using CRC3
  3570.                CAL╠      CRCCL╥              ; clear the CRC
  3571.           [loop CALLing CRCUPD]              ; ..acquire values
  3572.                CALL      CRCDONE             ; get the finished value
  3573.                LD        (CRCVAL),HL         ; ..and save
  3574.      CRCCK:                                  ; routine to check incoming CRC
  3575.                CALL      CRCCLR              ; clear CRC
  3576.           [loop CALLing CRCUPD]              ; ..acquire new set of values
  3577.                CALL      CRCDONE             ; get the finished value in HL
  3578.                LD        DE,(CRCVAL)         ; get the first value in DE
  3579.                CALL      COMPHD              ; compare HL to DE
  3580.                JR        NZ,ERROR            ; ..error if CRC's don't match
  3581. 
  3582.      Routines║  CRCCLR ,  CRC1CLR ,  CRC2CLR ,  CRC3CLR
  3583.      Function║ Clear CRC accumulator
  3584.      Entry:    None
  3585.      Exit:     None
  3586.      Affected: None
  3587.      Usage:    Mus⌠ bσ executeΣ beforσ beginninτ ß ne≈ áoperatioε ì
  3588. áááááááááááááááoε ß file¼ block¼ o≥ secto≥ oµ data«  D∩ no⌠ ácal∞ ì
  3589. áááááááááááááááthesσ routine≤ beforσ completinτ calculation≤ oε ß ì
  3590. áááááááááááááááblocδ o≥ thσ accumulateΣ datß wil∞ bσ incorrect.è
  3591.      Routine:   CRC3INIT
  3592.      Function║ Initialize CRC3 table for use
  3593.      Entry:    HL = pointer to 512-byte space for table
  3594.      Exit:     None
  3595.      Affected: AF¼ BC¼ DE
  3596.      Usage:    Mus⌠ ábσ executeΣ beforσ usinτ thσ áCRC│ áupdatinτ ì
  3597. ááááááááááááááároutine¼ áo≥ incorrec⌠ result≤ wil∞ ábσ áobtained«  ì
  3598. áááááááááááááááI⌠ áinitialize≤ ß tablσ witΦ prσ-computeΣ CR├ áreì
  3599. ááááááááááááááámainder≤ fo≥ usσ b∙ thσ updatinτ routine.
  3600.  
  3601.      Routine║   CRCUPD ,  CRC1UPD ,  CRC2UPD ,  CRC3UPD
  3602.      Function║ Update CRC accumulator count
  3603.      Entry:    A = byte to be included in CRC
  3604.      Exit:     None
  3605.      Affected: None
  3606.      Usage:    CalleΣ áoncσ fo≥ ever∙ bytσ t∩ bσ includeΣ iε áthσ ì
  3607. áááááááááááááááCR├ calculation.
  3608.  
  3609.      Routines║  CRCDONE ,  CRC1DONE ,  CRC2DONE ,  CRC3DONE
  3610.      Function║ Return CRC value
  3611.      Entry:    None
  3612.      Exit:     HL = calculated CRC value
  3613.      Affected: HL
  3614.      Usage:    Thi≤ routinσ i≤ useΣ t∩ terminatσ CR├ accumulatioε ì
  3615. áááááááááááááááanΣ returε thσ calculateΣ 1╢-bi⌠ CR├ value.
  3616.  
  3617. RANDO═ NUMBE╥ GENERATION:
  3618.  
  3619.      Routine║   RNDINIT
  3620.      Function║ Initialize random number generator seed
  3621.      Entry:    None
  3622.      Exit:     None
  3623.      Affected: None
  3624.      Usage:    Versioε á┤ oµ thσ librarie≤ change≤ thi≤ áfunctioε ì
  3625. áááááááááááááááfroφ áthσ keyboard/loo≡ counte≥ useΣ áiε ápreviou≤ ì
  3626. áááááááááááááááversion≤ t∩ onσ wherσ thσ refresΦ registe≥ oµ áthσ ì
  3627. áááááááááááááááZ80/Z18░ i≤ reaΣ t∩ forφ thσ initia∞ seed¼ requirì
  3628. áááááááááááááááinτ n∩ use≥ action«  Thi≤ methoΣ wil∞ no⌠ worδ áoε ì
  3629. áááááááááááááááthσ Z28░ wherσ refresΦ i≤ jus⌠ anothe≥ register.
  3630.  
  3631.      Routine:   RNDSEED
  3632.      Function║ Set known seed value
  3633.      Entry:    A = 8-bit seed value
  3634.      Exit:     None
  3635.      Affected: None
  3636.      Usage:    Allow≤ yo⌡ t∩ providσ ß seeΣ valuσ fo≥ thσ árandoφ ì
  3637. ááááááááááááááánumbe≥ ágenerato≥ insteaΣ oµ usinτ áthσ áautomatiπ ì
  3638. ááááááááááááááámethoΣ iε RNDINIT.
  3639. .paè     Routine║   RND
  3640.      Function║ Return 8-bit pseudo-random number
  3641.      Entry:    None
  3642.      Exit:     A = random number
  3643.      Affected: AF
  3644.      Usage:    Provide≤ ß pseud∩-randoφ byte«  Thσ returneΣ ávalì
  3645. áááááááááááááááue≤ áarσ ábetweeε zer∩ anΣ 255«  Yo⌡ mus⌠ ád∩ áan∙ ì
  3646. áááááááááááááááscalinτ needeΣ fo≥ you≥ application.
  3647.  
  3648. STRIN╟ AN─ VALU┼ COMPARISON:
  3649.  
  3650.      Routines║  COMPB ¼  COMPBC
  3651.      Function║ Comparσ vectors
  3652.      Entry:    HL, DE = pointers to vectors to compare
  3653.                B├ á(fo≥ COMPBC)¼ ┬ (fo≥ COMPB⌐ ╜ numbe≥ oµ ábyte≤ ì
  3654. ááááááááááááááát∩ compare
  3655.      Exit:     zero flag set (Z)║  HL = DE
  3656.                carry flag set (C)║  HL < DE
  3657.                zero and carry reset (NZ and NC)║  HL > DE
  3658.      Affected: AF
  3659.      Usage:    Mos⌠ commonl∙ useΣ t∩ d∩ strinτ comparison«  Sincσ ì
  3660. áááááááááááááááal∞ eigh⌠ bit≤ arσ useΣ iε thσ comparσ logic¼ the∙ ì
  3661. áááááááááááááááarσ als∩ suitablσ fo≥ ra≈ binar∙ element≤ a≤ well«  ì
  3662. áááááááááááááááCOMP┬ use≤ onl∙ aε ╕-bi⌠ counte≥ (┬ register⌐ áanΣ ì
  3663. ááááááááááááááácaε comparσ onσ t∩ 25╢ bytes¼ whilσ COMPB├ use≤ áß ì
  3664. ááááááááááááááá1╢-bi⌠ ácounte≥ (B├ pair⌐ anΣ caε comparσ áonσ át∩ ì
  3665. ááááááááááááááá65,53╢ bytes«  Thσ maximuφ count≤ oµ 25╢ anΣ 6553╢ ì
  3666. áááááááááááááááarσ áachieveΣ b∙ settinτ thσ counte≥ register≤ át∩ ì
  3667. ááááááááááááááázero.
  3668.  
  3669.      Routine║   @FNCMP
  3670.      Function║ Unambiguous 7-bit filenamσ comparison
  3671.      Entry:    HL = pointer to first string to match
  3672.                DE = pointer to second string to match
  3673.                B = number of characters to check (0 checks 256)
  3674.      Exit:     zero flag set (Z) if strings match
  3675.                zero flag reset (NZ) if no match
  3676.                carry flag set (C) if (DE) is less than (HL)
  3677.      Affected: AF¼ BC¼ DE¼ HL
  3678.      Usage:    Mos⌠ áofteε áuseΣ t∩ comparσ filename≤ áanΣ áfileì
  3679. ááááááááááááááátypes« á I⌠ perform≤ ╖-bi⌠ ácomparisons¼ áignorinτ ì
  3680. áááááááááááááááan∙ áattributσ bit≤ (bi⌠ 7)«  Iε genera∞ áuse¼ ái⌠ ì
  3681. ááááááááááááááácompare≤ átw∩ string≤ oµ onσ t∩ 25╢ character≤ áiε ì
  3682. ááááááááááááááálength«  Iε additioε t∩ equality¼ thσ inequalitie≤ ì
  3683. áááááááááááááááoµ ágreate≥ thaε anΣ les≤ thaε arσ als∩ ásupporteΣ ì
  3684. áááááááááááááááb∙ als∩ sensinτ thσ carr∙ flag.
  3685. .paè     Routine║   @AFNCMP
  3686.      Function║ Perform ambiguous 7-bit filenamσ comparison
  3687.      Entry:    HL = pointer to possibly ambiguous string
  3688.                DE = pointer to second string to match
  3689.                B = number of characters to check (0 checks 256)
  3690.      Exit:     zero flag set (Z) if match
  3691.                zero flag reset (NZ) if no match
  3692.      Affected: AF¼ BC¼ DE¼ HL
  3693.      Usage:    Mos⌠ áofteε áuseΣ t∩ comparσ filename≤ áanΣ áfileì
  3694. ááááááááááááááátypes¼ áwherσ onσ namσ ma∙ bσ ambiguou≤ á(questioε ì
  3695. ááááááááááááááámarks¼ "?"¼ matcΦ an∙ character)«  HigΦ bit≤ á(bi⌠ ì
  3696. ááááááááááááááá7⌐ oµ botΦ string≤ arσ maskeΣ witΦ onl∙ thσ áleas⌠ ì
  3697. ááááááááááááááásignifican⌠ ábit≤ beinτ compared«  I⌠ ma∙ als∩ ábσ ì
  3698. áááááááááááááááuseΣ a≤ ß genera∞ ╖-bi⌠ utilit∙ comparσ string≤ oµ ì
  3699. áááááááááááááááonσ t∩ 25╢ character≤ iε length.
  3700.      Examples:
  3701.                          EXT       @AFNCMP,@FNCM╨ ; declare the routines
  3702.                          ...                      ; ..preceeding code
  3703.                          LD        HL,AMBIG       ; set ptr to ambiguous name
  3704.                          LD        DE,FNAME       ; set to name to check
  3705.                          LD        B,11           ; match filename and type only
  3706.                          CALL      @AFNCMP        ; ..call the routine
  3707.                          JR        Z,OK           ; jump if match
  3708.                          ...                      ; else here if mismatch
  3709.                          ...
  3710.                          LD        HL,ENTRY1      ; set ptr to first name
  3711.                          LD        DE,ENTRY2      ; ..and name to check
  3712.                          LD        B,11           ; mMatch filename and type only
  3713.                          CALL      @FNCMP         ; ..call the routine
  3714.                          JR        Z,EQUAL        ; jump if same
  3715.                          JR        C,ONEMORE      ; ..jump here if ENTRY1>ENTRY2
  3716.                          ...                      ; else here if ENTRY1 < ENTRY2
  3717. 
  3718.      Routine║   COMPHD
  3719.      Function║ 16-bit value comparision
  3720.      Entry:    HL, DE = values to compare
  3721.      Exit:     Zero flag set (Z)║  HL = DE
  3722.                Carry flag set (C)║  HL < DE
  3723.                Carry and zero reset (NZ and NC)║  HL > DE
  3724.      Affected: AF
  3725.      Usage:    Commonl∙ useΣ t∩ comparσ tw∩ 1╢-bi⌠ value≤ sucΦ a≤ ì
  3726. áááááááááááááááaddresse≤ o≥ intege≥ values.
  3727.  
  3728.      Routine║   INSTR
  3729.      Function║ Substring search (NUL-terminated character strings)
  3730.      Entry:    HL = pointer to NUL-terminated string to be scanned
  3731.                DE = pointer to NUL-terminated substring to locate
  3732.      Exit:     H╠ á╜ pointe≥ t∩ beginninτ oµ substrinτ iε ástrinτ ì
  3733. áááááááááááááááiµ founΣ (unaffecteΣ iµ no⌠ found)
  3734.                A = 0, zero flag set (Z) if found
  3735.                A <> 0, zero flag clear if not found
  3736.      Affected: AF¼ HL
  3737.      Usage:    Mos⌠ ofteε useΣ t∩ locatσ ß characte≥ strinτ withì
  3738. áááááááááááááááiε ß large≥ bod∙ oµ text¼ sucΦ a≤ withiε ß ásimplσ ì
  3739. ááááááááááááááátex⌠ editor«  Automatiπ succes≤ iµ substrinτ i≤ oµ ìèááááááááááááááázer∩-lengtΦ (nul∞ string).
  3740.  
  3741.      Routine║   SCANNER
  3742.      Function║ Vector search
  3743.      Entry:    HL = pointer to vector to be scanned
  3744.                DE = pointer to vector to locate
  3745.                BC = vector lengths:
  3746.                     B = number of bytes in HL-vector
  3747.                     C = number of bytes in DE-vector
  3748.      Exit:     H╠ á╜ pointe≥ t∩ locateΣ vecto≥ (unchangeΣ iµ áno⌠ ì
  3749. áááááááááááááááfound)
  3750.                Zero flag set (Z) if found (A indeterminate)
  3751.                A <> 0, zero flag reset (NZ) if not found
  3752.      Affected: AF¼ HL
  3753.      Usage:    Locate≤ ß strinτ oµ byte≤ iε ß blocδ oµ u≡ t∩ á25╡ ì
  3754. ááááááááááááááábytes«  Sincσ onl∙ ╕-bit≤ arσ availablσ fo≥ lengtΦ ì
  3755. ááááááááááááááávalue≤ áfo≥ ábotΦ thσ searcΦ anΣ átarge⌠ ávectors¼ ì
  3756. áááááááááááááááneithe≥ álengtΦ ácaε exceeΣ 256«  Becausσ áoµ áthσ ì
  3757. ááááááááááááááálogiπ áused¼ áthσ blocδ t∩ bσ scanneΣ mus⌠ ábσ áoµ ì
  3758. ááááááááááááááánoε-zer∩ álengtΦ át∩ áavoiΣ aε áerro≥ áfo≥ ásearcΦ ì
  3759. ááááááááááááááálength≤ les≤ thaε 25╢ (░ lengtΦ byte)« á Automatiπ ì
  3760. áááááááááááááááfailurσ áiµ scanneΣ vecto≥ i≤ shorte≥ thaε ávecto≥ ì
  3761. ááááááááááááááát∩ locatσ (┬ ╝ C).
  3762.  
  3763. MEMOR┘ áALLOCATION:é  Thσ concep⌠ oµ memor∙ allocatioε witΦ áthesσ ì
  3764. routine≤ i≤ relativel∙ simple╗ SYSLI┬ routine≤ providσ áprimativσ ì
  3765. memor∙ áallocation/dσ-allocatioε ácapabilities¼ bu⌠ yo⌡ ásta∙ áiε ì
  3766. control.
  3767.  
  3768. Thσ ábasiπ áideß i≤ t∩ reservσ ß buffe≥ iε memor∙ froφ áwhicΦ át∩ ì
  3769. takσ ábit≤ anΣ piece≤ froφ a⌠ ß time«  Thσ boundinτ addresse≤ áoµ ì
  3770. thi≤ buffe≥ arσ specifieΣ (o≥ se⌠ b∙ default⌐ b∙ thσ IALLO├ árouì
  3771. tine¼ áanΣ áthσ ALLO├ routinσ i≤ useΣ t∩ obtaiε ásubbuffer≤ áfroφ ì
  3772. thi≤ álarge≥ buffe≥ wheε needed«  ALLO├ constantl∙ check≤ t∩ áseσ ì
  3773. iµ áthσ buffe≥ ha≤ enougΦ spacσ lef⌠ t∩ gran⌠ thσ reques⌠ áfo≥ áß ì
  3774. subbuffer¼ anΣ iµ i⌠ does¼ thσ subbuffe≥ i≤ provided.
  3775.  
  3776. Thσ larges⌠ buffe≥ whicΦ ma∙ bσ reserveΣ b∙ thσ IALLO├ routinσ i≤ ì
  3777. tha⌠ ábuffe≥ áwhicΦ extend≤ froφ thσ enΣ oµ thσ prograφ át∩ ájus⌠ ì
  3778. belo≈ thσ CCP«  Thi≤ buffe≥ i≤ selecteΣ iµ IALLO├ i≤ calleΣ áwitΦ ì
  3779. A=0.
  3780.  
  3781. The following illustrates use of the largest buffer possible:
  3782.                XOR       A                   ; select full buffer
  3783.                CALL      IALLOC
  3784.                ...
  3785.                LD        DE,1024             ; request 1K
  3786.                CALL      ALLOC
  3787.                JR        Z,MEMOVFL           ; abort if memory overflow
  3788.                LD        (BUF1),HL           ; set pointer to 1st subbuffer
  3789.                ...
  3790.                LD        DE,36               ; request 36 bytes
  3791.                CALL      ALLOC
  3792.                JR        Z,MEMOVFL           ; abort if memory overflow
  3793.                LD        (BUF2),HL           ; set pointer to 2nd subbufferè               ...
  3794.  
  3795. Thi≤ memor∙ allocatioε schemσ als∩ permit≤ thσ divisioε oµ memor∙ ì
  3796. int∩ áß grou≡ oµ buffers«  Onσ buffe≥ ma∙ bσ allocated¼ áit≤ áadì
  3797. dres≤ ápreserved¼ áanothe≥ buffe≥ ma∙ bσ allocated¼ áit≤ áaddres≤ ì
  3798. preserved¼ áanΣ átheε subsequen⌠ call≤ t∩ IALLO├ ma∙ bσ áuseΣ át∩ ì
  3799. selec⌠ áonσ buffe≥ o≥ thσ other«  EacΦ cal∞ t∩ IALLO├ áfree≤ áthσ ì
  3800. entirσ ábuffe≥ area¼ s∩ carσ shoulΣ bσ takeε iε doinτ this« á Fo≥ ì
  3801. example:
  3802.                ...
  3803.                CALL      CODEND              ; use CODEND as first buffer
  3804.                LD        (BUF1),HL
  3805.                EX        DE,HL               ; address in DE
  3806.                LD        HL,1024             ; 1K for this buffer
  3807.                ADD       HL,DE               ; HL pts to after this buffer
  3808.                EX        DE,HL               ; HL is start, DE is end
  3809.                LD        A,3                 ; select start and end
  3810.                CALL      IALLOC
  3811.                ...
  3812.                ...
  3813.                CALL      ALLOC               ; calls to ALLOC
  3814.                ...
  3815.                LD        HL,(BUF1)           ; pt to 1st buffer
  3816.                LD        DE,1024             ; set 2nd buffer
  3817.                ADD       HL,DE               ; pt to 2nd buffer
  3818.                LD        (BUF2),HL
  3819.                EX        DE,HL
  3820.                ADD       HL,DE               ; pt to end of 2nd 1K buffer
  3821.                EX        DE,HL               ; HL is start, DE is end
  3822.                LD        A,3                 ; select start and end
  3823.                CALL      IALLOC
  3824.                ...
  3825.                CALL      ALLOC               ; calls to ALLOC
  3826.                ...
  3827.  
  3828.      Routine║   ALLOC
  3829.      Function║ Allocate a block of memory
  3830.      Entry:    DE = number of bytes requested
  3831.      Exit:     HL = address of first byte allocated
  3832.                A <> 0, zero flag reset (NZ) if request granted
  3833.                A = 0, zero flag set (Z) if not enough space
  3834.      Affected: AF¼ HL
  3835.      Usage:    Allocate≤ ß blocδ oµ memor∙ froφ thσ large≥ áblocδ ì
  3836. áááááááááááááááreserveΣ áb∙ IALLOC«  Blocδ size≤ ma∙ bσ a≤ ásmal∞ ì
  3837. áááááááááááááááa≤ onσ byte¼ o≥ a≤ largσ a≤ thσ entirσ buffer«  Iµ ì
  3838. áááááááááááááááthσ ámemor∙ reques⌠ i≤ granted¼ thσ ástartinτ áadì
  3839. ááááááááááááááádres≤ i≤ returned«  ┴ cal∞ t∩ IALLO├ mus⌠ bσ ámadσ ì
  3840. ááááááááááááááábeforσ callinτ ALLOC.
  3841. .paè     Routine║   IALLOC
  3842.      Function║ Initialize memory allocation buffer
  3843.      Entry:    HL = possible starting address of buffer
  3844.                DE = possible ending address of buffer
  3845.                A = selection code:
  3846.                     b░ - 1 = use HL as starting address
  3847.                          0 = use CODEND value
  3848.                     b1 - 1 = use DE as ending address
  3849.                          0 = use CCP-1
  3850.      Exit:     None
  3851.      Affected: None
  3852.      Usage:    Initialize≤ thσ buffe≥ froφ whicΦ memor∙ i≤ áalloì
  3853. ááááááááááááááácateΣ áviß ácall≤ t∩ ALLOC«  Yo⌡ ma∙ áspecif∙ áthσ ì
  3854. ááááááááááááááábound≤ áoµ thi≤ buffer¼ o≥ usσ defaul⌠ bound≤ áse⌠ ì
  3855. áááááááááááááááb∙ IALLOC.
  3856.  
  3857.      Routine║   GETMTOP
  3858.      Function║ Return the highest TPA byte below the CCP
  3859.      Entry:    None
  3860.      Exit:     HL = addres≤ oµ the highest byte below CCP
  3861.      Affected: HL¼ AF
  3862.      Usage:    Determine≤ thσ to≡ oµ availablσ memor∙ iε routine≤ ì
  3863. áááááááááááááááwhicΦ áexi⌠ bacδ t∩ thσ commanΣ processo≥ áwitΦ áß ì
  3864. ááááááááááááááásimplσ returε instructioε insteaΣ oµ ß warφ áboot«  ì
  3865. áááááááááááááááThi≤ routinσ return≤ thσ highes⌠ availablσ ámemor∙ ì
  3866. ááááááááááááááálocatioε ábeneatΦ thσ commanΣ processo≥ át∩ áavoiΣ ì
  3867. áááááááááááááááoverwritinτ áit«  Iµ yo⌡ arσ writinτ fo≥ áß áZCPR│ ì
  3868. áááááááááááááááenvironment¼ usσ thσ correspondinτ GZMTO╨ ároutinσ ì
  3869. áááááááááááááááiε Z3LIB.
  3870.  
  3871. SOR╘ áROUTINES:é  Tw∩ routine≤ arσ provideΣ whicΦ givσ yo⌡ áacces≤ ì
  3872. t∩ áß áver∙ flexiblσ sortinτ system«  Thσ maiε routinσ ái≤ áSORT¼ ì
  3873. providinτ áß utilit∙ whicΦ sort≤ iε-memor∙ ß se⌠ oµ áfixeΣ-lengtΦ ì
  3874. records« á Thσ ásortinτ techniquσ useΣ i≤ ß Shel∞ ásort¼ áadapteΣ ì
  3875. froφ áthσ ábooδ "Softwarσ Toolsó b∙ Kernigaε anΣ áPlaugher¼ ápubì
  3876. lisheΣ áb∙ áAddisoε-Wesley¼ 1976¼ pagσ 106«  Thi≤ ásor⌠ ái≤ ámucΦ ì
  3877. faste≥ thaε thσ simplσ bubblσ sort.
  3878.  
  3879. ┴ áShel∞ ásor⌠ caε bσ donσ iε tw∩ ways║  witΦ áo≥ áwithou⌠ áusinτ ì
  3880. pointers« á Sortinτ áwithou⌠ usinτ pointer≤ i≤ átypicall∙ áslowe≥ ì
  3881. thaε ásortinτ witΦ pointers¼ anΣ thσ onl∙ advantagσ t∩ no⌠ áusinτ ì
  3882. pointer≤ i≤ thσ spacσ saving≤ froφ no⌠ havinτ pointer≤ (▓ ¬ ánumì
  3883. be≥ áoµ entrie≤ bytes)«  Iµ pointer≤ arσ useΣ fo≥ thσ sort¼ átheε ì
  3884. wheneve≥ aε exchangσ i≤ done¼ thσ pointer≤ arσ simpl∙ áexchanged¼ ì
  3885. rathe≥ áthaε áthσ ful∞ records¼ thereb∙ decreasinτ sor⌠ átimσ áiε ì
  3886. mos⌠ casts.
  3887.  
  3888. Thσ áSOR╘ ároutinσ i≤ controlleΣ b∙ passinτ ß pointe≥ t∩ áß áSor⌠ ì
  3889. Specificatioε áBlocδ (SSB)«  Thi≤ Sor⌠ Specificatioε Blocδ ái≤ áß ì
  3890. serie≤ oµ ▓-bytσ word≤ organizeΣ a≤ follows:
  3891.      Bytes ░ ª ▒ ╜  starting address of 1st record
  3892.      Bytes ▓ ª │ =  number of records to sort
  3893.      Bytes ┤ ª ╡ =  size of each record (in bytes)
  3894.      Bytes 6 & 7 =  addres≤ áoµ áuse≥-supplieΣ ácomparσ ároutine¼ ì
  3895. ááááááááááááááááááááwhicΦ compare≤ tw∩ records¼ onσ pointeΣ t∩ b∙ ìèááááááááááááááááááááH╠ áanΣ thσ othe≥ pointeΣ t∩ b∙ DE« á Iµ áthσ ì
  3896. áááááááááááááááááááárecorΣ ápointeΣ t∩ b∙ D┼ i≤ les≤ áiε ásortinτ ì
  3897. ááááááááááááááááááááorde≥ áthaε tha⌠ pointeΣ t∩ b∙ HL¼ thi≤ ácomì
  3898. ááááááááááááááááááááparσ routinσ i≤ t∩ returε witΦ carr∙ se⌠ (C)«  ì
  3899. ááááááááááááááááááááIµ áthσ record≤ arσ equa∞ iε ásortinτ áorder¼ ì
  3900. ááááááááááááááááááááthi≤ ácomparσ routinσ i≤ t∩ returε witΦ ázer∩ ì
  3901. ááááááááááááááááááááse⌠ á(Z)«  Onl∙ thσ A╞ i≤ t∩ bσ áaffecteΣ áb∙ ì
  3902. ááááááááááááááááááááthσ comparσ routine.
  3903.      Bytes ╕ ª ╣ =  address of pointer table
  3904.      Byte 1░ =      flag (0FFh means to use pointers, 0 means not)
  3905.      Byte 1▒ =      unused
  3906.  
  3907. A≤ mentioneΣ previously¼ tw∩ routine≤ arσ availablσ iε thi≤ ásor⌠ ì
  3908. module«  Thσ firs⌠ routine¼ SSBINIT¼ look≤ a⌠ thσ beginninτ oµ áß ì
  3909. scratcΦ áareß áanΣ thσ initia∞ content≤ oµ aε SS┬ áanΣ áallocate≤ ì
  3910. spacσ fo≥ thσ pointe≥ table«  I⌠ als∩ check≤ t∩ seσ iµ thσ buffe≥ ì
  3911. requireΣ overflow≤ thσ transien⌠ prograφ area.
  3912.  
  3913. Thσ seconΣ routine¼ SORT¼ perform≤ thσ sort¼ anΣ i≤ controlleΣ b∙ ì
  3914. thσ SS┬ pointe≥ passeΣ t∩ i⌠ iε DE.
  3915.  
  3916.      Routine║   SSBINIT
  3917.      Function║ Sor⌠ Specificatioε Block initializer
  3918.      Entry:    HL = pointer to start of scratch RAM area
  3919.                DE = pointer to SSB
  3920.      Exit:     A <> 0, zero flag reset (NZ) if OK
  3921.                A = 0, zero flag set (Z) if TPA overflow
  3922.      Affected: AF
  3923.      Usage:    Thi≤ routinσ ma∙ bσ useΣ a≤ describeΣ abovσ beforσ ì
  3924. áááááááááááááááan∙ árecord≤ arσ loadeΣ int∩ memor∙ fo≥ thσ ásort¼ ì
  3925. áááááááááááááááo≥ ái⌠ ma∙ bσ useΣ afte≥ thσ record≤ havσ áalread∙ ì
  3926. ááááááááááááááábeeε loaded«  Iε thσ latte≥ case¼ yo⌡ shoulΣ ásavσ ì
  3927. áááááááááááááááthσ ástar⌠ áaddres≤ oµ thσ firs⌠ recorΣ áanΣ ácal∞ ì
  3928. áááááááááááááááSSBINI╘ áwitΦ thσ addres≤ oµ thσ firs⌠ bytσ áafte≥ ì
  3929. áááááááááááááááthσ álas⌠ árecord«  Oncσ SSBINI╘ áha≤ áloadeΣ áthσ ì
  3930. ááááááááááááááábuffer≤ iε thσ SS┬ anΣ checkeΣ fo≥ ß TP┴ áoverflo≈ ì
  3931. ááááááááááááááá(notσ tha⌠ thi≤ i≤ donσ fo≥ thσ pointer≤ only)¼ i⌠ ì
  3932. áááááááááááááááwil∞ áreturε át∩ áthσ caller¼ a⌠ áwhicΦ átimσ áyo⌡ ì
  3933. áááááááááááááááshoulΣ árestorσ thσ firs⌠ tw∩ byte≤ oµ thσ SS┬ át∩ ì
  3934. áááááááááááááááthei≥ áprope≥ values¼ thσ actua∞ star⌠ addres≤ áoµ ì
  3935. áááááááááááááááthσ firs⌠ record.
  3936.  
  3937.                SSBINI╘ áload≤ byte≤ ░ ª ▒ (addres≤ oµ firs⌠ árecì
  3938. áááááááááááááááord⌐ áanΣ ╕ ª ╣ (addres≤ oµ pointe≥ table⌐ áoµ áaε ì
  3939. áááááááááááááááSSB¼ checkinτ fo≥ TP┴ overflow«  I⌠ set≤ thσ poinì
  3940. áááááááááááááááte≥ átablσ t∩ star⌠ a⌠ thσ specifieΣ áscratcΦ áRA═ ì
  3941. áááááááááááááááarea¼ áexamine≤ thσ recorΣ sizσ anΣ árecorΣ ácoun⌠ ì
  3942. áááááááááááááááentrie≤ áoµ aε SSB¼ anΣ add≤ thσ produc⌠ oµ áthesσ ì
  3943. ááááááááááááááátw∩ t∩ thσ startinτ addres≤ oµ thσ pointe≥ átable«  ì
  3944. áááááááááááááááThσ áresultinτ addres≤ i≤ returneΣ a≤ thσ áaddres≤ ì
  3945. áááááááááááááááoµ thσ firs⌠ record.
  3946. .paè     Routine║   SORT
  3947.      Function║ Sort set of fixed length records
  3948.      Entry:    DE = pointer to sort specification block (SSB)
  3949.      Exit:     None (records are sorted)
  3950.      Affected: None
  3951.      Usage:    Sort≤ thσ se⌠ oµ fixeΣ lengtΦ record≤ accordinτ t∩ ì
  3952. áááááááááááááááthσ contro∞ informatioε iε thσ Sor⌠ áSpecificatioε ì
  3953. áááááááááááááááBlocδ (SSB⌐ addresseΣ b∙ DE«  N∩ specia∞ actioε i≤ ì
  3954. ááááááááááááááárequired¼ áno≥ possiblσ iε it≤ operation«  Iε áthσ ì
  3955. áááááááááááááááunlikel∙ áeven⌠ oµ aε erro≥ withiε thσ áSOR╘ árouì
  3956. ááááááááááááááátine¼ áthσ erro≥ messagσ "SOR╘ Pointe≥ Erroró áma∙ ì
  3957. ááááááááááááááábσ áprinted«  Thi≤ indicate≤ ß fla≈ ha≤ ádevelopeΣ ì
  3958. áááááááááááááááwitΦ áthσ SOR╘ routinσ anΣ i⌠ coulΣ no⌠ áSOR╘ áthσ ì
  3959. áááááááááááááááse⌠ oµ record≤ a≤ desired«  Thi≤ i≤ fata∞ anΣ wil∞ ì
  3960. áááááááááááááááabor⌠ t∩ CP/M.
  3961.  
  3962. MISCELLANEOU╙ ROUTINES:é  Thσ followinτ routine≤ arσ describeΣ áiε ì
  3963. thi≤ section:
  3964.      BDOS -¡ direct BDOS interface
  3965.      BIOS -¡ direct BIOS interface
  3966.      CAPS -¡ character capitalization
  3967.      CAPSTR -¡ string capitalization
  3968.      CATH -¡ convert ASCII character to hexadecimal
  3969.      @B2HH,@B2HL -¡ convert high and low nybbles of byte to hex
  3970.      CLINE -¡ command line extraction
  3971.      CODEND -¡ provide end of code/data area
  3972.      EN -¡ exchange nybbles in A
  3973.      FILLB -¡ fill memory (up to 255 bytes)
  3974.      FILLBC -¡ fill memory (up to 65,535 bytes)
  3975.      HFILB -¡ fill memory (up to 255 bytes)
  3976.      HFILBC -¡ fill memory (up to 65,535 bytes)
  3977.      MOVEB -¡ move memory (up to 255 bytes)
  3978.      MOVEBC -¡ move memory (up to 65,535 bytes)
  3979.      HMOVB -¡ move memory (up to 255 bytes)
  3980.      HMOVBC -¡ move memory (up to 65,535 bytes)
  3981.      PAUSE -¡ delay n 10ths of a second
  3982.      VERSION -¡ return version number of SYSLIB
  3983.  
  3984.      Routine║   BDOS
  3985.      Function║ Call a BDOS function
  3986.      Entry:    DE = arguments (if needed for function)
  3987.                C = BDOS function number
  3988.      Exit:     A = return statu≤ o≥ parameter (if returned)
  3989.                HL = return parameter (if returned)
  3990.      Affected: AF¼ HL
  3991.      Usage:    ┴ wa∙ oµ callinτ thσ BDO╙ whilσ preservinτ thσ áB├ ì
  3992. áááááááááááááááanΣ áD┼ registers«  Thi≤ i≤ ofteε oµ benefi⌠ áwheε ì
  3993. ááááááááááááááádealinτ witΦ FC┬ addresse≤ iε D┼ and/o≥ loo≡ counì
  3994. áááááááááááááááter≤ iε thσ ┬ register.
  3995. .paè     Routine║   BIOS
  3996.      Function║ Call a BIOS function directly
  3997.      Entry:    A = offset to BIOS function entry in jump table
  3998.                BC = function parameters (if needed)
  3999.      Exit:     A¼ BC = return parameters (if returned)
  4000.      Affected: AF¼ BC¼ DE¼ HL
  4001.      Usage:    Provide≤ áver∙ fas⌠ responsσ wherσ áBDO╙ áoverheaΣ ì
  4002. ááááááááááááááácanno⌠ ábσ tolerated«  Thi≤ routinσ áprovide≤ áyo⌡ ì
  4003. áááááááááááááááwitΦ ß direc⌠ interfacσ int∩ thσ CP/═ BIOS«  I⌠ i≤ ì
  4004. ááááááááááááááácalleΣ áwitΦ áaε inde° offse⌠ int∩ thσ áBIO╙ ájum≡ ì
  4005. ááááááááááááááátable« á N∩ register≤ arσ preserveΣ b∙ áthi≤ árouì
  4006. ááááááááááááááátine.
  4007.  
  4008.                Thσ followinτ tablσ summarize≤ thσ offset≤ oµ áthσ ì
  4009. áááááááááááááááBIO╙ jum≡ tablσ entries:
  4010.  
  4011.                     ░    Cold start
  4012.                     1    Warm boot
  4013.                     2    Consolσ status╗ return≤ A=0FFΦ iµ ácharì
  4014. áááááááááááááááááááááááááacte≥ ready¼ A=░ iµ not
  4015.                     3    Console input; returns character in A
  4016.                     4    Console output; character passed in C
  4017.                     5    List output; character passed in C
  4018.                     6    Punch output; character passed in C
  4019.                     7    Reader input; returns character in A
  4020.                     8    Home disk head
  4021.                     9    Selec⌠ ádisk╗ ádisδ numbe≥ á(A=0¼ áetc.⌐ ì
  4022. ááááááááááááááááááááááááápasseΣ iε C
  4023.                    10    Se⌠ tracδ number╗ tracδ numbe≥ passeΣ iε ì
  4024. áááááááááááááááááááááááááC
  4025.                    11    Se⌠ secto≥ number╗ secto≥ numbe≥ ápasseΣ ì
  4026. áááááááááááááááááááááááááiε C
  4027.                    12    Set DMA address; DMA address passed in BC
  4028.                    13    ReaΣ blocδ froφ disk╗ return≤ A=░ iµ OK¼ ì
  4029. áááááááááááááááááááááááááA=▒ iµ error
  4030.                    14    Writσ blocδ t∩ disk╗ return≤ A=░ iµ áOK¼ ì
  4031. áááááááááááááááááááááááááA=▒ iµ error
  4032.                    15    Lis⌠ ástatus╗ return≤ A=0FFΦ áiµ áready¼ ì
  4033. áááááááááááááááááááááááááA=░ iµ not
  4034.                    16    Secto≥ translation¼ logica∞-t∩-physical╗ ì
  4035. ááááááááááááááááááááááááálogica∞ ásecto≥ ánumbe≥ ápasseΣ áiε áBC¼ ì
  4036. ááááááááááááááááááááááááátranslatσ átablσ addres≤ iε DE╗ áreturn≤ ì
  4037. áááááááááááááááááááááááááphysica∞ secto≥ numbe≥ iε HL
  4038.  
  4039.      Routine║   CATH
  4040.      Function║ Convert ASCII to hexadecimal
  4041.      Entry:    A = ASCII hex character ("0"-"9", "A"-"F")
  4042.      Exit:     A = binary value represented by character
  4043.      Affected: AF
  4044.      Usage:    Usefu∞ áiε numeriπ conversioε anΣ entr∙ ároutines«  ì
  4045. áááááááááááááááI⌠ simpl∙ convert≤ thσ ASCI╔ hexadecima∞ characte≥ ì
  4046. áááááááááááááááprovideΣ át∩ áit≤ binar∙ árepresentation« á Iµ áaε ì
  4047. áááááááááááááááinvaliΣ he° characte≥ i≤ passed¼ ß spacσ (20h⌐ ái≤ ì
  4048. áááááááááááááááreturneΣ iε A.
  4049. .paè     Routines║  @B2HH ¼  @B2HL
  4050.      Function║ Conver⌠ binar∙ t∩ hexadecimal
  4051.      Entry:    A = data byte to convert
  4052.      Exit:     A = hex character (0..9¼ A..F) for specified nybble
  4053.      Affected: AF
  4054.      Usage:    Perform≤ conversion≤ froφ binar∙ nybble≤ t∩ áhexaì
  4055. ááááááááááááááádecima∞ áASCI╔ ácharacters«  @B2H╚ áconvert≤ áhigΦ ì
  4056. ááááááááááááááánybblσ áoµ bytσ t∩ he° digit¼ whilσ @B2H╠ áconver⌠ ì
  4057. ááááááááááááááálo≈ nybblσ oµ bytσ t∩ he° digit.
  4058.      Example:
  4059.                          EX╘       @B2HH,@B2HL
  4060.                          ...                      ; enter with byte in A
  4061.                          PUSH      AF             ; save the byte
  4062.                          CALL      @B2HH          ; call the routine
  4063.                          ...                      ; do something with high nybble
  4064.                          POP       AF             ; restore original byte
  4065.                          CALL      @B2HL          ; now have hex char of low nybble
  4066.                          ...                      ; do something with it
  4067.  
  4068.      Routine║   CLINE
  4069.      Function║ Command line tail extraction
  4070.      Entry:    H╠ á╜ áaddres≤ oµ commanΣ linσ ábuffe≥ á(characte≥ ì
  4071. ááááááááááááááácount)
  4072.      Exit:     HL = address of command line string (1st character)
  4073.                A <> 0, zero flag clear (NZ) if buffer OK
  4074.                A = 0, zero flag set (Z) if buffer truncated
  4075.      Affected: AF¼ HL
  4076.      Usage:    Free≤ áthσ ádefaul⌠ buffe≥ a⌠ 80Φ b∙ ácopyinτ áthσ ì
  4077. ááááááááááááááácontent≤ át∩ ß loca∞ buffer«  Thσ ápreserveΣ ácop∙ ì
  4078. áááááááááááááááma∙ átheε bσ parseΣ o≥ evaluateΣ a⌠ ß late≥ átime«  ì
  4079. áááááááááááááááThσ linσ ma∙ bσ u≡ t∩ 25╡ character≤ lonτ anΣ wil∞ ì
  4080. ááááááááááááááábσ truncateΣ iµ longer«  Thσ strinτ wil∞ bσ termiì
  4081. ááááááááááááááánateΣ áb∙ áß <NUL╛ a≤ pe≥ thσ áSYSLI┬ áconcep⌠ áoµ ì
  4082. ááááááááááááááástrings.
  4083.  
  4084.      Routine║   CODEND
  4085.      Function║ End of code
  4086.      Entry:    None
  4087.      Exit:     HL = address of page above last byte used in program
  4088.      Affected: HL
  4089.      Usage:    UseΣ t∩ determinσ thσ basσ addres≤ oµ freσ ámemor∙ ì
  4090. áááááááááááááááfo≥ áusσ iε sorting¼ director∙ listing¼ anΣ áothe≥ ì
  4091. áááááááááááááááprograms« á ScratcΦ memor∙ extend≤ froφ thσ ávaluσ ì
  4092. áááááááááááááááreturneΣ b∙ CODEN─ t∩ thσ basσ oµ thσ CC╨ o≥ BDOS.
  4093.  
  4094. .ix $MEMRY (g)
  4095.      Global:   $MEMRY ¡¡ Contain≤ thσ addres≤ oµ thσ nex⌠ áavailì
  4096. áááááááááááááááablσ ábytσ oµ memor∙ afte≥ thσ las⌠ modulσ áloadeΣ ì
  4097. áááááááááááááááanΣ áresolveΣ b∙ MicroSoft'≤ LIN╦-8░ álinker¼ áSL╥ ì
  4098. áááááááááááááááSystemsº áSLRNK¼ o≥ Mitek'≤ ZLINK«  Thi≤ áreserveΣ ì
  4099. ááááááááááááááágloba∞ variablσ shoulΣ bσ accesseΣ as:
  4100.                          ...
  4101.                          EXT       $MEMRY
  4102.                          ...
  4103.                          LD        HL,($MEMRY)    ; get value
  4104.                          ...è
  4105.      Routine║   EN
  4106.      Function║ Exchange nybbles
  4107.      Entry:    A = byte to manipulate
  4108.      Exit:     A = manipulated Byte
  4109.      Affected: AF
  4110.      Usage:    Exchange≤ áthσ ánybble≤ iε thσ ┴ áregister╗ áhigΦ-ì
  4111. áááááááááááááááorde≥ fou≥ bit≤ arσ exchangeΣ witΦ lo≈-orde≥ áfou≥ ì
  4112. ááááááááááááááábits.
  4113.  
  4114.      Routines║  FILLB ,  FILLBC ,  HFILB ,  HFILBC
  4115.      Function║ Memory fill routines
  4116.      Entry:    HL = pointer to first byte of memory area to fill
  4117.                BC (FILLBC and HFILBC) = number of bytes to fill
  4118.                B (FILLB and HFILB) = number of bytes to fill
  4119.                A = value to store in buffer
  4120.      Exit:     H╠ (HFIL┬ anΣ HFILB├ only⌐ ╜ pointe≥ t∩ bytσ afte≥ ì
  4121. ááááááááááááááálast
  4122.      Affected: HL (HFILB and HFILBC only)
  4123.      Usage:    Fill≤ aε areß oµ memor∙ witΦ ß constan⌠ bytσ ávalì
  4124. áááááááááááááááue« á FILL┬ caε fil∞ u≡ t∩ ß 25╢-bytσ buffer¼ áanΣ ì
  4125. áááááááááááááááFILLB├ ácaε fil∞ u≡ t∩ ß 65,53╢-bytσ (withiε áreaì
  4126. áááááááááááááááson⌐ buffer.
  4127.  
  4128.                FILL┬ anΣ FILLB├ havσ n∩ effect≤ oε an∙ registers«  ì
  4129. áááááááááááááááHFIL┬ anΣ HFILB├ botΦ affec⌠ thσ H╠ registe≥ pair¼ ì
  4130. áááááááááááááááanΣ the∙ returε witΦ H╠ pointinτ t∩ thσ bytσ afte≥ ì
  4131. áááááááááááááááthσ las⌠ bytσ filled«  HFIL┬ anΣ HFILB├ arσ usefu∞ ì
  4132. áááááááááááááááwheε furthe≥ processinτ froφ thσ las⌠ poin⌠ filleΣ ì
  4133. ááááááááááááááái≤ desired.
  4134.  
  4135.      Routines║  MOVEB ,  MOVEBC ,  HMOVB ,  HMOVBC
  4136.      Function║ Memory move routines
  4137.      Entry:    HL = pointer to first byte of source buffer
  4138.                DE = pointer to first byte of destination buffer
  4139.                BC (MOVEBC & HMOVBC) = number of bytes to move
  4140.                B (MOVEB & HMOVB) = number of bytes to move
  4141.      Exit:     H╠ á(HMOV┬ ª HMOVBC⌐ ╜ pointe≥ t∩ bytσ afte≥ álas⌠ ì
  4142. ááááááááááááááásource
  4143.                D┼ á(HMOV┬ ª HMOVBC⌐ ╜ pointe≥ t∩ bytσ afte≥ álas⌠ ì
  4144. ááááááááááááááádestination
  4145.      Affected: HL¼ DE (HMOVB & HMOVBC only)
  4146.      Usage:    Move≤ thσ blocδ oµ memor∙ specifieΣ b∙ thσ ásourcσ ì
  4147. áááááááááááááááaddres≤ t∩ thσ specifieΣ destinatioε memor∙ álocßì
  4148. ááááááááááááááátion«  MOVE┬ caε movσ u≡ t∩ ß 25╢-bytσ buffer¼ anΣ ì
  4149. áááááááááááááááMOVEB├ caε movσ u≡ t∩ ß 65,53╢-bytσ buffer«  MOVE┬ ì
  4150. áááááááááááááááanΣ áMOVEB├ áhavσ án∩ effect≤ áoε áan∙ áregisters«  ì
  4151. áááááááááááááááHMOV┬ anΣ HMOVB├ botΦ affec⌠ thσ H╠ registe≥ pair¼ ì
  4152. áááááááááááááááanΣ áthe∙ áreturε witΦ H╠ anΣ D┼ pointinτ át∩ áthσ ì
  4153. ááááááááááááááábytσ afte≥ thσ las⌠ bytσ moved«  HMOV┬ anΣ  HMOVB├ ì
  4154. áááááááááááááááarσ áusefu∞ wheε furthe≥ processinτ froφ thσ álas⌠ ì
  4155. ááááááááááááááápoin⌠ filleΣ i≤ desired.
  4156. .paè     Routine║   PAUSE
  4157.      Function║ Delay routine
  4158.      Entry:    HL = number of 10ths of a second delay desired
  4159.                B = processor speed in MHz (1¼ 2¼ 3¼ ...)
  4160.      Exit:     None
  4161.      Affected: None
  4162.      Usage:    Fo≥ delay≤ froφ onσ t∩ 65,53╢ tenth≤ oµ ß ásecond«  ì
  4163. áááááááááááááááCalculation≤ arσ approximatσ anΣ depenΣ oε accuraì
  4164. ááááááááááááááác∙ áoε áclocδ specificatioε anΣ ánumbe≥ áoµ áclocδ ì
  4165. ááááááááááááááácycle≤ ápe≥ opcodσ iε thσ dela∙ code« á(i.e.¼ áthσ ì
  4166. áááááááááááááááZ180/6418░ executσ iε fewe≥ clocδ cycle≤ thaε áthσ ì
  4167. áááááááááááááááZ80).
  4168.  
  4169.      Routine║   VERSION
  4170.      Function║ Version number of SYSLIB
  4171.      Entry:    None
  4172.      Exit:     HL = version (H=major, L=minor); H=4, L=2 for 4.2
  4173.      Affected: HL
  4174.      Usage:    Return≤ áthσ álibrar∙ versioε áanΣ áidentificatioε ì
  4175. ááááááááááááááátex⌠ string.
  4176. .paè