home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol107 / syslibug.ws < prev    next >
Encoding:
Text File  |  1985-02-10  |  122.3 KB  |  2,905 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.       SYSLIB -- An Integrated Library of Assembly Language
  15.   Utility Subroutines for use with the Microsoft M80 Assembler
  16.  
  17.                    User's Guide for SYSLIB 2.3
  18.  
  19.                                by
  20.                           Richard Conn
  21.  
  22.  
  23.  
  24.  
  25.                    Revision B of User's Guide
  26.  
  27.  
  28.                         14 December 1982
  29.  
  30.  
  31.  
  32.  
  33.  
  34.      Thi≤ User'≤ Guideô i≤ ß supplemen⌠ t∩ thσ SYSLI┬ 2.3 Use≥ anΣ ì
  35. Referencσ Manual¼ dateΣ 14 December 1982.
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.     The SYSLIB Library is Copyrighted, 1982, by Richard Conn
  45.  
  46. .he                    User's Guide for SYSLIB 2.3
  47. .pn 1
  48. .fo Table of Contents                             TOC - #
  49.  
  50.  
  51.       SYSLIB -- An Integrated Library of Assembly Language
  52.   Utility Subroutines for use with the Microsoft M80 Assembler
  53.  
  54.                    User's Guide for SYSLIB 2.3
  55.  
  56.  
  57.                         Table of Contents
  58.  
  59.      1.0 Introduction and Purpose of the User's Guide  1
  60.          1.01 What is SYSLIB?                          1
  61.          1.02 SYSLIB Documentation                     2
  62.  
  63.      2.0 SYSLIB Output, Math, and Some Misc Routines   3
  64.          2.01 Printing Stuff with SYSLIB               3
  65.          2.02 Math with SYSLIB                        10
  66.          2.03 Some Miscellaneous Routines             11
  67.          2.04 The CODEND Routine                      14
  68.  
  69.      3.0 SYSLIB Input Line Editors                    16
  70.          3.01 What Is an Input Line Editor?           16
  71.          3.02 The BDOS-Based Input Line Editors       16
  72.          3.03 The INLINE Input Line Editor            18
  73.   
  74.      4.0 SYSLIB Disk Input/Output                     19
  75.          4.01 Directory Manipulation Routines         20
  76.          4.02 Block-Oriented File Input/Output        28
  77.          4.03 Byte-Oriented File Input/Output         29
  78.          4.04 File Control Block (FCB) Manipulation   31
  79.          4.05 ZCPR2-Specific Functions                33
  80.                Multiple Commands and SYSLIB           36
  81.                External Paths and SYSLIB              37
  82.                Named Directories and SYSLIB           44
  83.  
  84.      5.0 Numeric String Evaluation, CRC Check, and
  85.                Sort Routines                          48
  86.          5.01 Numeric String Evaluation               48
  87.          5.02 Cyclic Redundancy Checking              50
  88.          5.03 The SYSLIB Sort Routines                51
  89.    
  90.      6.0 What is SYSLIB?  SYSLIB Overview             54
  91.          6.01 Functional Overview of SYSLIB           54
  92.          6.02 SYSLIB Documentation and Files and
  93.               SYSLIB Availability                     56
  94.          6.03 Distribution Statement for SYSLIB       56
  95.  
  96. .pn 1
  97. .fo Alphabetical Listing of SYSLIB Routines            AList - #
  98.  
  99.  
  100.       SYSLIB -- An Integrated Library of Assembly Language
  101.   Utility Subroutines for use with the Microsoft M80 Assembler
  102.  
  103.              Alphabetical Listing of SYSLIB Routines
  104.  
  105.  
  106. A    ADDHD     10   |    ANDHD     10
  107.  
  108. B    BBLINE    16   |    BIOS      11
  109.      BDOS      11   |    BLINE     16
  110.  
  111. C    CAPS      11   |    COMPB     13   |    CRC2CLR   50
  112.      CAPSTR    11   |    COMPBC    13   |    CRC2DONE  50
  113.      CATH      11   |    COMPHD    13   |    CRC2UPD   50
  114.      CCOUT      3   |    CONDIN     4   |    CRCCLR    50
  115.      CIN        3   |    COUT       3   |    CRCDONE   50
  116.      CLINE     11   |    CPOUT      3   |    CRCUPD    50
  117.      CLOUT      3   |    CRC1CLR   50   |    CRLF       3
  118.      CMPH      10   |    CRC1DONE  50   |    CST        4
  119.      CODEND    14   |    CRC1UPD   50
  120.  
  121. D    DBUFFER   20   |    DIRFS     27   |    DIRSEL    23
  122.      DFREE     28   |    DIRLOAD   22   |    DIRSLOAD  22
  123.      DIRALPHA  25   |    DIRNPACK  24   |    DIVHD     10
  124.      DIRF      27   |    DIRPACK   24   |    DPARAMS   21
  125.  
  126. E    EN        11   |    EVAL16    48
  127.      EVAL      48   |    EVAL2     48
  128.      EVAL10    48   |    EVAL8     48
  129.  
  130. F    F$CLOSE   28   |    F$OPEN    28
  131.      F$DELETE  28   |    F$READ    28
  132.      F$EXIST   28   |    F$RENAME  28
  133.      F$MAKE    28   |    F$WRITE   28
  134.      F$MOPEN   28
  135.  
  136.      Fn$GET    30   |    FILLBC    12
  137.      Fn$PUT    30   |    FNAME     31
  138.      FIn$CLOSE 30   |    FOn$CLOSE 30
  139.      FIn$OPEN  30   |    FOn$OPEN  30
  140.      FILLB     12   |    FSIZE     28
  141.  
  142. G    GETUD     41
  143.  
  144. H    HFILB     12   |    HMOVB     12
  145.      HFILBC    12   |    HMOVBC    12
  146.  
  147. I    INITFCB   31   |    INSTR     13
  148.      INLINE    18
  149.  
  150.                  Listing Continued on Next Page
  151.  
  152.          Alphabetical Listing of SYSLIB Routines, Con't
  153.  
  154. L    LA2HC      6   |    LHLDC      6
  155.      LA3DC      6   |    LOGUD     41
  156.      LADC       6   |    LOUT       3
  157.      LCRLF      3   |    LPRINT     4
  158.      LHL4HC     6   |    LPSTR      4
  159.      LHL5DC     6
  160.  
  161. M    MA2HC      9   |    MHLDC      9
  162.      MA3DC      9   |    MOVEB     12
  163.      MADC       9   |    MOVEBC    12
  164.      MHL4HC     9   |    MULHD     10
  165.      MHL5DC     9
  166.  
  167. N    NEGH      10
  168.  
  169. O    ORHD      10
  170.  
  171. P    PA2HC      6   |    PHLDC      6
  172.      PA3DC      6   |    POUT       3
  173.      PADC       6   |    PRINT      4
  174.      PAUSE     12   |    PSTR       4
  175.      PHL4HC     6   |    PUTUD     41
  176.      PHL5DC     6
  177.  
  178. R    RETUD     41   |    RND       13
  179.      RIN        3   |    RNDINIT   13
  180.      ROTLH     10   |    RNDSEED   13
  181.      ROTRH     10
  182.  
  183. S    SCANNER   13   |    SORT      52
  184.      SHFTLH    10   |    SSBINIT   52
  185.      SHFTRH    10   |    SUBHD     10
  186.  
  187. V    VERSION   12
  188.  
  189. X    XORHD     10
  190.  
  191. Z    ZCPRQ     43   |    ZGPINS    43
  192.      ZCPRQ2    43   |    ZINICI    42
  193.      ZDNAME    45   |    ZINIDMA   42
  194.      ZDNFIND   46   |    ZINIEXT   40
  195.      ZFNAME    47   |    ZINIMC    36
  196.      ZFNINIT   45   |    ZMCPTR    36
  197.      ZFSTAT    43   |    ZPFIND    40
  198.  
  199. .fo 1 - Introduction                                   Page #
  200. .pn 1
  201.       SYSLIB -- An Integrated Library of Assembly Language
  202.   Utility Subroutines for use with the Microsoft M80 Assembler
  203.  
  204.                    User's Guide for SYSLIB 2.3
  205.  
  206. 1.0  Introduction
  207.  
  208. 1.01 What is SYSLIB?
  209.  
  210.      SYSLI┬ (SYSteφ LIBrary⌐ i≤ ß collectioε oµ ove≥ 13░á subrouì
  211. tine≤ whicΦ arσ designeΣ t∩ providσ t∩ thσ CP/═ 8080/Z8░ assembl∙ ì
  212. languagσá programme≥á ß se⌠ oµ function≤ upoε whicΦ hσ caεá builΣ ì
  213. hi≤ programs«  Thi≤ librar∙ i≤ intendeΣ t∩ relievσ thσ programme≥ ì
  214. oµ thσ tasδ oµ frequentl∙ "reinventinτ thσ wheeló anΣ t∩á providσ ì
  215. hiφ witΦ ß too∞ environmen⌠ whicΦ encourage≤ structureΣ programmì
  216. inτ a⌠ thσ assembl∙ languagσ level.
  217.  
  218.      EacΦá subroutinσá withiε SYSLI┬ caε bσ vieweΣ a≤ ßá reliablσ ì
  219. "blacδ box.ó  Thσ subroutine≤ iε SYSLI┬ arσ completel∙ documenteΣ ì
  220. withiεá thσ SYSLI┬ Use≥ anΣ Referencσ Manua∞ fo≥á SYSLI┬á Versioε ì
  221. 2.3¼á thσá companioε documen⌠ t∩ thi≤ guide¼á anΣ thσ SYSLIBx.HL╨ ì
  222. files«á  Thσ programme≥ i≤ consistentl∙ provideΣ witΦ thσ followì
  223. inτ informatioε oε eacΦ subroutinσ withiε SYSLIB:
  224.  
  225.           1.  Name of Subroutine
  226.           2.  Function it performs
  227.           3.  What its inputs are
  228.           4.  What its outputs are
  229.           5.  What registers are affected by it
  230.           6.  What other library routines it calls upon
  231.           7.  What errors can occur and how it handles them
  232.  
  233.      Thσ routine≤ withiε SYSLI┬ arσ designeΣ t∩ worδ togethe≥ anΣ ì
  234. complemen⌠ eacΦ other«á  Paramete≥ passinτ i≤ consisten⌠á betweeε ì
  235. thσ variou≤ subroutines«á  Fo≥ instance¼á al∞ routine≤ whicΦ neeΣ ì
  236. t∩á bσá passeΣ ß pointe≥ t∩ ß Filσ Contro∞ Blocδ arσ passeΣá tha⌠ ì
  237. pointe≥ iε thσ D┼ registe≥ pair«á  Also¼á a≤ ß genera∞ rule¼ iµ ß ì
  238. registe≥ i≤ no⌠ returneΣ a≤ aε outpu⌠ froφ thσ SYSLI┬ subroutine¼ ì
  239. theεá it≤ valuσ i≤ no⌠ affecteΣ (i⌠ ha≤ thσ samσ valuσá wheεá thσ ì
  240. routine is exited as it had when the routine was called).
  241.  
  242.      SYSLI┬á itselµá i≤ ß librar∙ oµ relocatablσá objec⌠á module≤ ì
  243. createΣá iεá thσ Microsof⌠ M8░ relocatablσá objec⌠á format«á  Al∞ ì
  244. subroutine≤ withiε SYSLI┬ arσ groupeΣ withiε functionally-relateΣ ì
  245. modules«á  Oncσá ß routinσ i≤ referenceΣ (b∙ thσ EX╘ statemen⌠ iε ì
  246. thσ M8░ assembl∙ languagσ program)¼á it≤ modulσ i≤ loadeΣ anΣá i⌠ ì
  247. i≤á availablσá t∩ thσ programme≥ b∙ mean≤ oµ ß simplσá subroutinσ ì
  248. call«á  Al∞á othe≥ subroutine≤ withiε tha⌠ particula≥ modulσá arσ ì
  249. als∩ loaded¼á bu⌠ the∙ arσ no⌠ availablσ t∩ thσ programme≥ unles≤ ì
  250. hσá ha≤ als∩ referenceΣ theφ b∙ EX╘ statements«á  Thσá modulσá i≤ ì
  251. loadeΣá onl∙á once¼á regardles≤ oµ ho≈ man∙ routine≤á withiεá thσ ì
  252. modulσá arσ referenced«á  Fo≥ thi≤ reason¼á ╔ havσ designeΣá eacΦ ì
  253. modulσá t∩ contaiε routine≤ whicΦ arσ frequentl∙ useΣ togethe≥ o≥ ì
  254. arσá calleΣá b∙ eacΦ othe≥ (onσ routinσ withiε thσá modulσá call≤ ì
  255. anothe≥ routinσ withiε thσ module).è1.02 SYSLIB Documentation
  256.  
  257.      Thσ followinτ document≤ arσ associateΣ witΦ SYSLI┬ --
  258.  
  259.           ∩ SYSLI┬ Use≥ anΣ Referencσ Manua∞ fo≥ SYSLI┬ Version
  260.                2.3ô b∙ RicharΣ Conn¼ 14 Decembe≥ 1982, 112+ pages
  261.                (I occasionally refer to this as SYSLIB User and
  262.                 Reference Manual)
  263.  
  264.           ∩  User'≤ Guidσ fo≥ SYSLI┬ 2.3ô b∙ RicharΣ Conn¼ 14 
  265.                December 1982, 57+ pages
  266.  
  267.           o  SYSLIBx.HLP files by Richard Conn
  268.                (SYSLIB.HLP, SYSLIB1.HLP-SYSLIB9.HLP,
  269.                 SYSLIBA.HLP-SYSLIBC.HLP)
  270.  
  271.      Thσá SYSLI┬ Use≥ anΣ Referencσ Manua∞ fo≥ SYSLI┬ Versioε 2.3ô  ì
  272. i≤á divideΣ int∩ 2▒ chapters«á  Thi≤ documen⌠ provide≤ aεá introì
  273. ductioεá t∩ SYSLIB¼á explaininτ wha⌠ i⌠ i≤ anΣ wha⌠ i⌠á buy≤á thσ ì
  274. user¼á anΣá theεá proceed≤ t∩ describσ al∞ oµ thσ SYSLI┬á subrouì
  275. tines¼ groupeΣ b∙ function¼ iε detail«  Thσ las⌠ chapte≥ contain≤ ì
  276. seveε samplσ program≤ whicΦ usσ SYSLIB¼á anΣ i⌠ show≤ thσá sourcσ ì
  277. listinτ oµ thesσ programs¼á thσ assembl∙ process¼ anΣ run≤ oµ thσ ì
  278. programs.
  279.  
  280.      Thσá SYSLIBx.HL╨á file≤ arσ intendeΣ t∩ bσá useΣá a≤á onlinσ ì
  281. referencσá manual≤ fo≥ SYSLIB«á  Thσ HEL╨ commanΣ give≤ thσá use≥ ì
  282. acces≤ t∩ thσ content≤ oµ thσ HL╨ file≤ iε aε indexeΣ manner¼á s∩ ì
  283. thσá use≥ ma∙ quickl∙ identif∙ thσ routinσ hσ need≤ anΣ determinσ ì
  284. ho≈ t∩ usσ it«á  Thσ informatioε iε thσ SYSLI┬ Use≥ anΣ Referencσ ì
  285. Manua∞á fo≥ SYSLI┬ Versioε 2.3ô oε thσ SYSLI┬ subroutine≤ i≤á dupì
  286. licateΣ iε thesσ HL╨ files.
  287.  
  288.      Thi≤ i≤ thσ User'≤ Guidσ fo≥ SYSLI┬ 2.3«á  I⌠ i≤ designeΣ t∩ ì
  289. bσá useΣá a≤ aε instructiona∞ supplemen⌠ t∩ thσ SYSLI┬á Use≥á anΣ ì
  290. Referencσá Manua∞ fo≥ SYSLI┬ Versioε 2.3«á  Thσ Referencσá Manua∞ ì
  291. present≤á thσá "harΣ factsó oε thσ SYSLI┬ subroutines¼á anΣá thi≤ ì
  292. User'≤á Guidσá present≤ thσ philosoph∙ behinΣ thσ desigεá oµá thσ ì
  293. SYSLI┬ subroutine≤ anΣ aε explanatioε oµ ho≈ the∙ arσ intendeΣ t∩ ì
  294. interac⌠ witΦ eacΦ othe≥ anΣ worδ togethe≥ t∩ providσ ß flexible¼ ì
  295. powerfu∞á too∞á se⌠ fo≥ thσ assembl∙á languagσá programmer«á  Thσ ì
  296. Referencσá Manua∞ i≤ jus⌠ tha⌠ -- ß booδ t∩ refe≥ t∩ iε orde≥á t∩ ì
  297. answe≥á specifiπ question≤ abou⌠ thσ detail≤ oµ thσá SYSLI┬á rouì
  298. tines«  Thσ User'≤ Guide¼ oε thσ othe≥ hand¼ i≤ ß tutorial.
  299.  
  300.  
  301.  
  302.  
  303. .fo 2 - SYSLIB Output, Math, and Some Misc Routines    Page #
  304.  
  305. 2.0 SYSLIB Output, Math, and Some Misc Routines
  306.  
  307. 2.01 Printing Stuff Using SYSLIB
  308.  
  309.      ┴á pai≥ oµ SYSLI┬ Subroutine≤ perforφ ß simplσ functioεá fo≥ ì
  310. thσá programme≥á anΣ havσ n∩ ne⌠ effec⌠ oε an∙ register≤á whatsoì
  311. ever«á  Hence¼ the∙ caε bσ useΣ a⌠ wil∞ withou⌠ an∙ concerε whatì
  312. soeve≥ oε sidσ effects«  Thi≤ pai≥ oµ routine≤ includes:
  313.  
  314.           o CRLF   -- Output CR LF to the Console
  315.           o LCRLF  -- Output CR LF to the LST: Device
  316.  
  317.      Thσá pai≥ oµ SYSLI┬ Subroutine≤ jus⌠ discusseΣá i≤á probabl∙ ì
  318. thσá simples⌠ oµ thσ entirσ library«á  Nex⌠ t∩ theφ iε complexit∙ ì
  319. arσ thσ singlσ characte≥ input/outpu⌠ routines:
  320.  
  321.           o CIN     -- Input Character from Console in A
  322.           o RIN     -- Input Character from Reader in A
  323.  
  324.           o COUT    -- Output Character in A to Console
  325.           o LOUT    -- Output Character in A to LST: Device
  326.           o POUT    -- Output Character in A to PUN: Device
  327.  
  328.           o CCOUT   -- Output Character in A to Console with
  329.                          Control Character Processing
  330.           o CLOUT   -- Output Character in A to LST: Device with
  331.                          Control Character Processing
  332.           o CPOUT   -- Output Character in A to PUN: Device with
  333.                          Control Character Processing
  334.  
  335.      Notσá tha⌠á thesσ routines¼á likσá al∞á SYSLI┬á subroutines¼ ì
  336. perforφá exactl∙á thσá functioε a≤ documenteΣ anΣá nothinτá else«  ì
  337. CIN¼ fo≥ example¼ onl∙ input≤ ß character¼ anΣ doe≤ no⌠ ech∩ thi≤ ì
  338. character.  To input and then echo a character, a sequence like
  339.  
  340.           CALL CIN  ; input ch
  341.           CALL COUT ; echo ch
  342.  
  343. woulΣá bσá used«á  Onl∙ thσ ┴ registe≥ i≤ affecteΣ b∙á thσá inpu⌠ ì
  344. routines¼ anΣ n∩ registe≥ i≤ affecteΣ b∙ thσ outpu⌠ routines.
  345.  
  346.      Thσá outpu⌠á routine≤ caε outpu⌠ character≤ witΦ o≥á withou⌠ ì
  347. contro∞ characte≥ processing«  Thσ routine≤ whicΦ proces≤ contro∞ ì
  348. character≤ wil∞ outpu⌠ character≤ likσ control-├ (binar∙ 3⌐ a≤ ^├ ì
  349. anΣ thσ routine≤ whicΦ d∩ no⌠ d∩ sucΦ processinτ woulΣ outpu⌠ thσ ì
  350. exact binary code.
  351.  
  352.  
  353.      Thσ Consolσ Statu≤ routine¼á CST¼á return≤ thσ statu≤ oµ thσ ì
  354. consolσ iε registe≥ A¼á sayinτ iµ ß ke∙ ha≤ beeε presseΣ o≥á not«  ì
  355. Iµá datßá i≤á available¼á A=0«á  I⌠ woulΣ typicall∙á bσá useΣá a≤ ì
  356. follows:
  357.  
  358.           CALL CST  ; get status
  359.           ORA  A    ; see if A=0
  360.           JNZ  NOIN ; routine to process if no input
  361.           CALL CIN  ; get character and process
  362.  
  363.      Thσáá Conditiona∞á Inpu⌠á routine¼áá CONDIN¼áá provide≤á thσ ì
  364. function≤á jus⌠ describeΣ iε ß somewha⌠ simple≥ anΣá morσá usefu∞ ì
  365. form«á  CONDI╬á wil∞á samplσá thσ consolσ inpu⌠á anΣá returεá thσ ì
  366. characte≥ iµ onσ i≤ availablσ witΦ ß flaτ sayinτ tha⌠ ß characte≥ ì
  367. i≤ returned«  Iµ ß characte≥ i≤ no⌠ available¼ CONDI╬ wil∞ simpl∙ ì
  368. returεá witΦ thσ appropriatσ flag«á  Thσ samσ routinσ implementeΣ ì
  369. using CONDIN looks like this:
  370.  
  371.           CALL CONDIN    ; get conditional input
  372.           JZ   NOIN      ; routine to process if no input
  373.           ...            ; process char in A from CONDIN
  374.  
  375.      A≤á thσ reade≥ caε see¼á wσ alread∙ havσ takeε ßá nicσá ste≡ ì
  376. forwarΣá froφ conventiona∞ assembl∙ languagσ programminτá withou⌠ ì
  377. thσ usσ oµ ß librar∙ likσ SYSLIB«  ╔ thinδ tha⌠ simplσ character-ì
  378. orienteΣ input/outpu⌠ i≤ handleΣ nicel∙ now¼ anΣ thσ nex⌠ logica∞ ì
  379. ste≡ i≤ t∩ outpu⌠ ß grou≡ oµ character≤ easily«á  Thi≤ i≤ donσ b∙ ì
  380. the print routines:
  381.  
  382.           o PRINT   -- Print String Pointed to by Return Address
  383.                          on Console
  384.           o LPRINT  -- Print String Pointed to by Return Address
  385.                          on LST: Device
  386.  
  387.           o PSTR    -- Print String Pointed to by HL on Console
  388.           ∩ LPST╥   -- Prin⌠ Strinτ PointeΣ t∩ b∙ H╠ oε LST║ 
  389.                          Device
  390.  
  391.      Thi≤á i≤ thσ firs⌠ introductioε oµ thσ concep⌠ oµ ßá string«  ì
  392. Iε thσ SYSLI┬ terminology¼á ß stringô i≤ ß sequencσ oµá character≤ ì
  393. terminateΣá b∙ ß binar∙ 0«á  Thσ programme≥ coulΣ definσ ß strinτ ì
  394. iε thσ followinτ ways:
  395.  
  396.           DB   'This is a string',0
  397.           DB   0dh,0ah,'This is another string',0dh,0ah,0
  398.  
  399.      PRIN╘á anΣ LPRIN╘ prin⌠ string≤ pointeΣ t∩ b∙á thei≥á returε ì
  400. addresses¼á anΣ the∙ returε t∩ thσ bytσ followinτ thσ strinτ the∙ ì
  401. just printed.  They would typically be used as follows:
  402.  
  403.           CALL PRINT     ; Print the following string
  404.           DB   'This is a test',0
  405.           ...            ; Continue processing
  406. è     PST╥á anΣá LPST╥á requirσ tha⌠ H╠ point≤ t∩ ßá valiΣá strinτ ì
  407. before they are called.  An example of the use of PSTR is:
  408.  
  409.           LXI  H,MYNAME  ; point to string
  410.           CALL PSTR      ; print it
  411.           ...            ; continue processing
  412. MYNAME:   DB   'Rick',0  ; string to be printed
  413.  
  414.      Warning║á  PST╥ anΣ LPST╥ affec⌠ thσ H╠ registe≥ pair«  Upoε ì
  415. exit¼á H╠á point≤á t∩ thσ bytσ followinτ thσá indicateΣá strings«  ì
  416. Thesσá routine≤á werσá designeΣá iεá thi≤á wa∙á t∩á easil∙á allo≈ ì
  417. successive calls to them to print one string after another:
  418.  
  419.           LXI  H,LIST    ; point to first string
  420.           MVI  B,0       ; init counter
  421. LOOP:     MOV  A,M       ; get first character
  422.           OR┴  ┴         ╗ checδ t∩ seσ iµ lis⌠ enΣ (nex⌠ ch=0)
  423.           JZ   DONE      ; continue processing
  424.           INR  B         ; increment count
  425.           MOV  A,B       ; get count
  426.           CALL PADC      ; print number
  427.           MVI  A,' '     ; print space
  428.           CALL COUT
  429.           CALL PSTR      ; print string
  430.           CALL CRLF      ; print new line
  431.           JMP  LOOP      ; continue until end of list
  432. DONE:                    ; continue processing
  433.           ...
  434. LIST:
  435.           DB   'Rick',0       ; first name in list
  436.           DB   'Olivia',0     ; second name in list
  437.           DB   'Carolyn',0    ; third name in list
  438.           DB   0         ; end of list
  439.  
  440.      The output from this code segment will be:
  441.  
  442.   1 Rick
  443.   2 Olivia
  444.   3 Carolyn
  445.  
  446.      Thi≤ examplσ i≤ intendeΣ t∩ drivσ severa∞ ke∙ point≤ homσ t∩ ì
  447. the reader:
  448.           1«á  SYSLI┬ routine≤ arσ designeΣ t∩ perforφ ß functioε ì
  449. anΣ havσ minima∞ sidσ effects«á  Notσ tha⌠ thσ ┬ registe≥ i≤ useΣ ì
  450. a≤ ß counte≥ iε thi≤ routine¼ anΣ ╔ don'⌠ savσ i⌠ anywhere«  Nonσ ì
  451. of these SYSLIB routines have any effect on B.
  452.           2«á  SYSLI┬ routine≤ arσ designeΣ t∩ bσ cohesive«  The∙ ì
  453. "bonΣ togetheró t∩ forφ ß functiona∞ modulσ anΣ ma∙ bσ calleΣ onσ ì
  454. after the other to collectively provide a function for the user.
  455.           3«á  SYSLI┬á ha≤á beeε designeΣ t∩ eliminatσ ßá lo⌠á oµ ì
  456. overheaΣ iε assembl∙ languagσ programming«  Imaginσ ho≈ mucΦ morσ ì
  457. oµá ß programminτ tasδ i⌠ woulΣ bσ iµ yo⌡ haΣ t∩ writσá thσá PAD├ ì
  458. (Print A as Decimal Characters with Leading Spaces) routine.
  459.  
  460.      Which leads us into the next set of routines ...è     ┴á numbe≥ oµ SYSLI┬ routine≤ arσ designeΣ t∩ outpu⌠á number≤ ì
  461. t∩á thσá user«á  BotΦá 8-bi⌠ number≤ anΣ 16-bi⌠á number≤á ma∙á bσ ì
  462. output¼á anΣá iεá al∞ cases¼á thσ ┴ registe≥ contain≤á thσá 8-bi⌠ ì
  463. numbe≥á t∩á outpu⌠ anΣ thσ H╠ registe≥ pai≥ contain≤á thσá 16-bi⌠ ì
  464. number to output.  These routines are:
  465.  
  466.           o PADC, LADC        -- Print the number in the A
  467.                                    register as up to 3 digits in
  468.             PADC = Print           a 3-character field.  If 3
  469.                    A as            significant digits are not
  470.                    Decimal         required (there are leading
  471.                    Characters      zeroes), print spaces in their
  472.             LADC = List            places.  PADC prints to the
  473.                    A as D.C.       Console, LADC prints to the
  474.                                    LST: Device
  475.  
  476.           o PA3DC, LA3DC      -- Like PADC and LADC, but print
  477.                                    3 digits, including the
  478.             PA3DC = Print          leading zeroes
  479.                     A as
  480.                     3
  481.                     Decimal
  482.                     Characters
  483.  
  484.           o PA2HC, LA2HC      -- Like PA3DC and LA3DC, but print
  485.                                    2 hexadecimal digits,
  486.             PA2HC = Print          including the leading zeroes
  487.                     A as
  488.                     2
  489.                     Hexadecimal
  490.                     Characters
  491.  
  492.           o PHLDC, LHLDC      -- Print the number in the HL
  493.                                    register pair as up to 5
  494.             PHLDC = Print          digits in a 5-character
  495.                     H and          field.  If 5 significant
  496.                     L as           digits are not required
  497.                     Decimal        (there are leading zeroes),
  498.                     Characters     print spaces in their places.
  499.                                    PHLDC prints to the Console,
  500.                                    LHLDC prints to the LST:
  501.                                    Device
  502.  
  503.           o PHL5DC, LHL5DC    -- Like PHLDC and LHLDC, but
  504.                                    print 5 digits, including
  505.             PHL5DC = Print         the leading zeroes
  506.                      HL as
  507.                      5 D.C.
  508.  
  509.           o PHL4HC, LHL5HC    -- Like PHL5DC and LHL5DC, but
  510.                                    print 4 hexadecimal digits,
  511.             PHL4HC = Print         including the leading zeroes
  512.                      HL as
  513.                      4 Hex Chars
  514. è     Nonσá oµá thesσá prin⌠á routine≤ havσá an∙á effect≤á oεá an∙ ì
  515. registersíá  Yo⌡á ma∙ usσ theφ freel∙ t∩ prin⌠ ou⌠á values«á  Thσ ì
  516. followinτ table≤ providσ example≤ oµ wha⌠ output≤ woulΣ looδ likσ ì
  517. from these routines:
  518.  
  519.  
  520.                       8-Bit Numeric Outputs
  521.  
  522. A Register     PADC, LADC     PA3DC, LA3DC   PA2HC, LA2HC
  523. ----------     ----------     ------------   ------------
  524.      0            __0             000             00
  525.     16            _16             016             10
  526.    100            100             100             64
  527.    255            255             255             FF
  528.  
  529.  
  530.  
  531.                      16-Bit Numeric Outputs
  532.  
  533. HL Register    PHLDC, LHLDC   PHL5DC, LHL5DC   PHL4HC, LHL4HC
  534. -----------    ------------   --------------   --------------
  535.        0           ____0          00000             0000
  536.       16           ___16          00016             0010
  537.      100           __100          00100             0064
  538.      256           __256          00256             0100
  539.     4096           _4096          04096             1000
  540.    16536           16536          16536             4000
  541.  
  542. Note: _ denotes a space.
  543.  
  544.  
  545.  
  546.      This sample code segment:
  547.  
  548.           LXI  H,100     ; set value
  549.  
  550.           CALL PRINT     ; print text
  551.           DB   'HL = ',0
  552.  
  553.           CALL PHLDC     ; print HL as decimal chars
  554.  
  555.           CALL PRINT     ; print more text
  556.           DB   ' Decimal or ',0
  557.  
  558.           CALL PHL4HC    ; print HL as hexadecimal chars
  559.  
  560.           CALL PRINT     ; print ending text
  561.           DB   ' Hexadecimal',0
  562.  
  563.           ...
  564.  
  565. prints this text:
  566.  
  567. HL_=___100_Decimal_or_0064_Hexadecimal
  568.  
  569.      (Note: _ denotes a space)
  570.  
  571.      Thσá reade≥ caε seσ tha⌠ SYSLI┬ come≤ througΦ again¼á makinτ ì
  572. thσá joΓá nicσ anΣ easy«á  Notσ tha⌠ H╠ i≤ NO╘á AFFECTE─á b∙á thσ ì
  573. numeriπá prin⌠á routine≤ (PHLDC¼á PHL4HC⌐ o≥ b∙ thσ strinτá prin⌠ ì
  574. routinσ (PRINT)«  Fo≥ tha⌠ matter¼ N╧ registe≥ i≤ affecteΣ b∙ thσ ì
  575. calls to these routines.
  576.  
  577.      Thi≤á example¼á likσ thσ previou≤ example¼á i≤á intendeΣá t∩ ì
  578. drivσ severa∞ ke∙ point≤ homσ t∩ thσ reader:
  579.  
  580.           1«á  SYSLI┬ routine≤ arσ designeΣ t∩ perforφ ß functioε ì
  581. anΣ havσ minima∞ sidσ effects«
  582.  
  583.           2«á  SYSLI┬ routine≤ arσ designeΣ t∩ bσ cohesive«  The∙ ì
  584. "bonΣ togetheró t∩ forφ ß functiona∞ modulσ anΣ ma∙ bσ calleΣ onσ ì
  585. after the other to collectively provide a function for the user.
  586.  
  587.           3«á  SYSLI┬á ha≤á beeε designeΣ t∩ eliminatσ ßá lo⌠á oµ ì
  588. overheaΣ iε assembl∙ languagσ programming«
  589.  
  590.           4«á  SYSLI┬á routine≤ arσ frequentl∙ nameΣ t∩ servσá a≤ ì
  591. mnemoniπá aid≤ iε orde≥ t∩ hel≡ thσ programme≥ remembe≥ wha⌠á thσ ì
  592. routinσ does.
  593.  
  594.  
  595.      Flexibilit∙ i≤ ß ke∙ worΣ fo≥ SYSLIB¼á anΣ onσ gooΣ questioε ì
  596. t∩á asδ i≤ wha⌠ capabilit∙ doe≤ SYSLI┬ givσ mσ t∩ outpu⌠ m∙á numì
  597. ber≤á iε an∙ wa∙ ╔ desirσ (likσ H╠ a≤ u≡ t∩ ┤ decima∞á character≤ ì
  598. insteaΣ oµ 5)┐  Thσ nex⌠ se⌠ oµ routine≤ solve≤ thi≤ problem:
  599.  
  600.           o MADC    -- Place up to 3 ASCII digit characters
  601.                          into memory which represent the number
  602.           MADC = Memory  in the A register and use leading
  603.                  (store) spaces.  The first byte of a three-
  604.                  A as    byte memory buffer is pointed to by
  605.                  Dec     the DE register pair.
  606.                  Chars
  607.  
  608.           o MA3DC   -- Like MADC, but including leading zeroes
  609.  
  610.           o MA2HC   -- Like MA3DC, but hexadecimal digits
  611.  
  612.           o MHLDC   -- 5 ASCII digits characters stored in
  613.                          memory to represent the value in HL
  614.  
  615.           o MHL5DC  -- Like MHLDC, but including leading zeroes
  616.  
  617.           o MHL4HC  -- Like MHL5DC, but hexadecimal digits
  618.  
  619.  
  620.      Note║á  D┼á i≤ affecteΣ b∙ thesσá routinesíá  Oεá entry¼á D┼ ì
  621. point≤á t∩ thσ firs⌠ bytσ oµ thσ buffe≥ useΣ t∩ storσ thσ desireΣ ì
  622. characters¼á and¼á oε exit¼ D┼ point≤ t∩ thσ firs⌠ bytσ afte≥ thσ ì
  623. las⌠á characte≥ stored«á  Thesσ routine≤ arσ se⌠ u≡ thi≤á wa∙á s∩ ì
  624. tha⌠á wholσ string≤ oµ tex⌠ caε bσ sequentiall∙ storeΣ iεá memor∙ ì
  625. with some ease.
  626.  
  627.      Sample Code:
  628.  
  629.           LXI  D,NUM3    ; 3-byte buffer
  630.           MVI  A,10      ; Number 10
  631.           CALL MADC      ; Store in Buffer
  632.           LXI  H,400     ; Number 400
  633.           CALL MHLDC     ; Store in 5-byte buffer
  634.           ...
  635. NUM3:     DS   3         ; reserve 3 bytes
  636. NUM5:     DS   5         ; reserve 5 bytes
  637.  
  638.      Results:
  639.  
  640.                Address   ASCII Char     Address   ASCII Char
  641.                -------   ----------     -------   ----------
  642.                NUM3        (space)      NUM5        (space)
  643.                NUM3+1         1         NUM5+1      (space)
  644.                NUM3+2         0         NUM5+2         4
  645.                                         NUM5+3         0
  646.                                         NUM5+4         0
  647.  
  648. 2.02 Math with SYSLIB
  649.  
  650.      MatΦá function≤ arσ particularl∙ eas∙ witΦá SYSLIB«á  SYSLI┬ ì
  651. contain≤á ß wholσ modulσ oµ 16-bi⌠ matΦ function≤ whicΦ worδ witΦ ì
  652. jus⌠ thσ H╠ registe≥ pai≥ iµ onl∙ onσ argumen⌠ i≤ requireΣ o≥ thσ ì
  653. H╠ anΣ D┼ registe≥ pair≤ iµ tw∩ argument≤ arσ necessary«á  Iε al∞ ì
  654. cases, the HL register pair contains the final result.
  655.  
  656.      Followinτá thσá genera∞ philosoph∙ oµ thσá SYSLI┬á routines¼ ì
  657. thesσ matΦ function≤ affec⌠ ONL┘ thσ H╠ registe≥ pai≥ anΣ havσ n∩ ì
  658. effec⌠ oε an∙ othe≥ registers¼á includinτ thσ ┴ registe≥ anΣá thσ ì
  659. condition code flags, unless so noted.
  660.  
  661.      The math functions provided in SYSLIB are:
  662.  
  663.           o ADDHD   HL = HL + DE
  664.           o SUBHD   HL = HL - DE
  665.           o MULHD   HL = HL * DE
  666.           o DIVHD   HL = HL / DE
  667.  
  668.           o NEGH    HL = 2's Complement of HL
  669.           o CMPH    HL = 1's Complement of HL
  670.  
  671.           o ANDHD   HL = HL (Logical AND) DE
  672.           o ORHD    HL = HL (Logical OR) DE
  673.           o XORHD   HL = HL (Logical XOR) DE
  674.  
  675.           o ROTLH   HL is Rotated Left one Bit
  676.                          The old MSB is rotated into the LSB
  677.           o ROTRH   HL is Rotated Right one Bit
  678.                          The old LSB is rotated into the MSB
  679.           o SHFTLH  HL is Shifted Left one Bit
  680.                          The LSB becomes 0
  681.           o SHFTRH  HL is Shifted Right one Bit
  682.                          The MSB becomes 0
  683.  
  684.      Note║á  MS┬á anΣ LS┬ refe≥ t∩ Mos⌠ Significan⌠ Bi⌠ anΣ Leas⌠ ì
  685. Significant Bit, resp.
  686.  
  687.      Note║á  Erro≥á Condition≤ arσ handleΣ iε ßá logica∞á manner«  ì
  688. Thσ completσ description≤ oµ thesσ routine≤ founΣ iε thσ Use≥ anΣ ì
  689. Referencσ Manua∞ anΣ thσ SYSLIBx.HL╨ file≤ exactl∙ statσ wha⌠ thσ ì
  690. error conditions and return codes are.
  691.  
  692.  
  693. 2.03 Some Miscellaneous Routines
  694.  
  695.      Some miscellaneous routines contained within SYSLIB include:
  696.  
  697.           ∩ BDO╙ anΣ BIO╙ -- routine≤ t∩ allo≈ thσ SYSLI┬ 
  698.                programme≥ t∩ directl∙ acces≤ thσ CP/═ BDO╙ o≥ 
  699.                BIOS with minimum effect on the registers
  700.  
  701.           o CAPS -- capitalize the character in the A register;
  702.                if a <= A reg <= z, then the capital is returned,
  703.                else no change; the Most Significant Bit of A is
  704.                masked out in this process and ignored
  705.  
  706.           o CAPSTR -- capitalize the string pointed to by HL
  707.                in place:
  708.  
  709.                     LXI  H,CSTR    ; point to string
  710.                     CALL CAPSTR    ; capitalize it
  711.                     ...
  712.                CSTR: DB  'test',0  ; initial string
  713.  
  714.                results in:
  715.  
  716.                CSTR: DB  'TEST',0  ; resulting string
  717.  
  718.  
  719.           o CATH -- Convert ASCII to Hexadecimal; if the
  720.                register A contains any one of the following
  721.                ASCII characters
  722.  
  723.                     '0'-'9', 'A'-'F', 'a'-'f'
  724.  
  725.                the representative hexadecimal value (binary
  726.                0-F) is returned in A; if an error occurs,
  727.                the number 20 Hex is returned
  728.  
  729.           o CLINE -- Save the command line pointed to by HL
  730.                away in an internal buffer as a string.  The
  731.                command line starts with a character count which
  732.                is followed by the characters of the line.  This
  733.                is exactly the format of the line returned by
  734.                ZCPR2 in the buffer at 80H and by the BDOS Fct 10.
  735.                CLINE is useful when you want to work with the
  736.                linσ a≤ ß strinτ anΣ no⌠ havσ t∩ worr∙ abou⌠ 
  737.                saving it from becoming garbaged by disk I/O.
  738.                Also, CLINE returns a pointer to this line as
  739.                a string terminated by a binary 0 (you don't
  740.                have to worry about the character count).  HL
  741.                points to the first character of this string.
  742.  
  743.           o EN -- Exchange Nybbles in the A register; the
  744.                low-order 4 bits of A are switched with the
  745.                high-order 4 bits of A
  746. è          o VERSION -- Return the Version Number of SYSLIB
  747.                in the HL register pair
  748.  
  749.           o PAUSE -- Delay so many tenths of a second; inputs
  750.                to this routine are the number of 1/10 secs
  751.                to delay in HL and the speed of your processor
  752.                in B
  753.  
  754.           o FILL Routines -- These routines serve to fill
  755.                an area of memory pointed to by HL with a
  756.                constant byte value contained in the A
  757.                register; no registers are affected by
  758.                FILLB and FILLBC, and only HL is affected
  759.                by HFILB and HFILBC; the FILL Routines are:
  760.  
  761.                     FILLB -- number of bytes to fill
  762.                          is in the B register
  763.                     FILLBC -- number of bytes to fill
  764.                          is in the BC register pair
  765.                     HFILB -- like FILLB, but HL is
  766.                          affected, and HL points to
  767.                          the byte following the last
  768.                          byte filled when done
  769.                     HFILBC -- like FILLBC, but HL is
  770.                          affected as in HFILB
  771.  
  772.           o MOVE Routines -- These routines copy a block of
  773.                memory starting at the address contained in
  774.                HL to another place in memory starting at the
  775.                address contained in DE; these routines auto-
  776.                matically determine if the move is forwards
  777.                or backwards and compensate for any overlap;
  778.                no registers are affected by MOVEB and MOVEBC,
  779.                and HL and DE are affected by HMOVB and HMOVBC;
  780.                the MOVE Routines are:
  781.  
  782.                     MOVEB -- number of bytes to move in
  783.                          the B register
  784.                     MOVEBC -- number of bytes to move in
  785.                          the BC register pair
  786.                     HMOVB -- like MOVEB, but HL and DE are
  787.                          affected, pointing to after the
  788.                          last byte copied in each block
  789.                     HMOVBC -- like MOVEBC, but HL and DE
  790.                          are affected as in HMOVB
  791.  
  792.  
  793.           o Compare Routines -- These routines are used for
  794.                various types of comparisons, including simple
  795.                HL-to-DE comparison, fixed-length byte compare,
  796.                and subgroup comparisons.  The compare routines
  797.                are:
  798.                     COMPHD -- Compare HL to DE; on return,
  799.                          Zero Flag Set means HL=DE, Carry
  800.                          Flag Set means HL<DE
  801.                     COMPB and COMPBC -- Compare the group
  802.                          of bytes pointed to by HL to the
  803.                          group of bytes pointed to by DE;
  804.                          the groups are of equal length,
  805.                          being B bytes long for COMPB and
  806.                          BC bytes long for COMPBC; on return,
  807.                          Zero Flag Set means (HL)=(DE),
  808.                          Carry Flag Set means (HL)<(DE)
  809.                     SCANNER -- Scan the group of bytes
  810.                          pointed to by HL to see if it
  811.                          contains the group of bytes
  812.                          pointed to by DE; the HL group
  813.                          is B bytes long, and the DE
  814.                          group is C bytes long; if found,
  815.                          HL points to first byte of sub-
  816.                          group and Zero Flag is Set (Z); if not
  817.                          found, Zero Flag is Clear (NZ) and HL
  818.                          is not affected
  819.                     INSTR -- Scan the string pointed to by
  820.                          HL for the string pointed to by DE;
  821.                          if found, Zero Flag is Set (Z) and
  822.                          HL points to first byte of substring
  823.  
  824.           o Random Number Generator Routines -- Two routines
  825.                arσ provideΣ t∩ initializσ thσ SYSLI┬ randoφ num-
  826.                be≥ generato≥ anΣ onσ routinσ return≤ aε 8-bi⌠ 
  827.                randoφ numbe≥ froφ thσ generator.  These routines
  828.                are:
  829.                     RNDINIT -- Enters a counting loop and waits
  830.                          for a keypress from the user.  The count
  831.                          value at the keypress sets the random
  832.                          seed.
  833.                     RNDSEED -- Allows the programmer to provide
  834.                          a seed value.  This is input in the A
  835.                          register.
  836.                     RND -- Returns a random number in the A
  837.                          register, and uses this number as the
  838.                          seed value for the next call to RND.
  839.  
  840.  
  841.  
  842. 2.04 The CODEND Routine
  843.  
  844.      Therσ arσ man∙ time≤ wheε i⌠ i≤ necessar∙ t∩ kno≈ wherσ you≥ ì
  845. prograφá anΣ datß area≤ enΣ anΣ thσ beginninτ oµ thσ scratcΦ areß ì
  846. whicΦ extend≤ froφ thσ enΣ oµ you≥ program/datß area≤ t∩ thσá enΣ ì
  847. oµ thσ Transien⌠ Prograφ Areß (TPA⌐ i≤ located«  Thσ followinτ i≤ ì
  848. ß memor∙ ma≡ oµ thσ situatioε described:
  849.  
  850.           Top of Memory       --------------------------
  851.                               |  CP/M BIOS and Buffers |
  852.                               --------------------------
  853.                               |  CP/M BDOS             |
  854.                             / --------------------------
  855.                            /  |  CP/M CCP              |
  856.                           /   --------------------------
  857.                           T   |  Unused Memory Space   |
  858.                           P   |  above your program    |
  859.                           A   |  and its data areas    |
  860.                           \   |    ----------------    |
  861.                            \  |  Your Program          |
  862.           100H              \ --------------------------
  863.                               |  CP/M Buffers and JMPs |
  864.           Bottom of Memory    --------------------------
  865.  
  866.  
  867.      Thσá routinσá CODEN─á iε SYSLI┬ provide≤ yo⌡á witΦá thσá enΣ ì
  868. addres≤á oµá you≥á program/datß area≤ anΣ thσá beginninτá oµá thσ ì
  869. UnuseΣ Memor∙ Spacσ diagrammeΣ above«  CODEN─ i≤ ß routinσ locatì
  870. eΣ iε thσ SCODE╬ modulσ oµ SYSLIB¼á anΣ thi≤ modulσ i≤ ALWAY╙ thσ ì
  871. las⌠ modulσ iε thσ library«á  Durinτ thσ linkinτ process¼á SYSLI┬ ì
  872. i≤á t∩ bσ thσ las⌠ librar∙ specifieΣ t∩ L8░ fo≥á thσá link¼á and¼ ì
  873. sincσ SCODE╬ i≤ thσ las⌠ modulσ iε SYSLIB¼á iµ thσ CODEN─ routinσ ì
  874. i≤ referenceΣ b∙ thσ program¼ theε i⌠ wil∞ bσ loaded¼ anΣ i⌠ wil∞ ì
  875. ALWAY╙á bσá thσ las⌠ subroutinσ iε you≥ program«á  CODEN─á simpl∙ ì
  876. return≤á thσ addres≤ oµ thσ nex⌠ pagσ followinτ thσ las⌠ bytσá oµ ì
  877. code.
  878.  
  879.      Diagrammatically, the situation described looks like this:
  880.  
  881.           End of BDOS         --------------------------
  882.                               | BDOS                   |
  883.           Start of BDOS/      --------------------------
  884.             End of Scratch    | Scratch Space for your |
  885.                               | work area, as desired  |
  886.      -->  Next Page After Pgm --------------------------
  887.      |                        | Dead Space (Not Used)  |
  888.      |    End of Your Program --------------------------
  889.      |                        | CODEND Routine         |
  890.      |                        --------------------------
  891.      CODEND Returns This      | Other SYSLIB Routines  |
  892.      Address                  --------------------------
  893.                               | Your Program Code      |
  894.           100H                --------------------------
  895. è
  896.      A≤ iε thσ norma∞ CP/═ environment¼á thσ basσ oµ thσ BDO╙ caε ì
  897. bσ determineΣ b∙ loadinτ thσ addres≤ oµ thσ BDO╙ cal∞ a⌠ locatioε ì
  898. 5 into HL:
  899.  
  900.           LHLD 6    ; load address of BDOS call
  901.  
  902. Note║  A⌠ locatioε ╡ i≤ ß CAL╠ instructioε (CAL╠ Address)¼ s∩ thσ ì
  903. desireΣá Addres≤á i≤á a⌠ location≤ ╢ anΣá 7¼á low-orde≥á bytσá a⌠ ì
  904. location 6.
  905.  
  906.      CODEN─á caεá bσ useΣ t∩ determinσ thσ star⌠ oµá thσá scratcΦ ì
  907. area¼á s∩á thσ followinτ codσ segmen⌠ illustrate≤ ß techniquσá t∩ ì
  908. determine the size of the scratch area.
  909.  
  910.      ;
  911.      ;  SYSLIB EXTERNAL REFERENCES -- NOTE THAT ORDER OF THESE
  912.      ;  EXT PSEUDO-OPS IS NOT IMPORTANT
  913.      ;
  914.                EXT  CODEND    ; CODEND ROUTINE
  915.                EXT  SUBHD     ; HL=HL-DE
  916.                EXT  PRINT     ; PRINT STRING
  917.                EXT  PHLDC     ; PRINT HL AS UP TO 5 DEC CHARS
  918.                ...
  919.      ENTRY     EQU  5         ; BDOS ENTRY CALL
  920.                ...
  921.                CALL CODEND    ; GET ADDRESS IN HL
  922.                XCHG           ; ... ADDRESS IN DE
  923.                LHLD ENTRY+1   ; GET ADDRESS OF BDOS BASE
  924.                MVI  L,0       ; SET ON PAGE BOUNDARY
  925.                CALL SUBHD     ; HL=HL-DE (SIZE OF SCRATCH AREA)
  926.                CALL PRINT
  927.                DB   'The size of the scratch area is ',0
  928.                CALL PHLDC     ; PRINT IN DECIMAL
  929.                CALL PRINT
  930.                DB   ' bytes',0
  931.                ...
  932.  
  933. .fo 3 - SYSLIB Input Line Editors                      Page #
  934.  
  935. 3.0 SYSLIB Input Line Editors
  936.  
  937. 3.01 What is an Input Line Editor?
  938.  
  939.      Aε Inpu⌠ Linσ Edito≥ i≤ ß routinσ whicΦ i≤ ver∙á fundamenta∞ ì
  940. t∩á mos⌠á user-interactivσ program≤ anΣ timesharinτ o≥á dedicateΣ ì
  941. operatinτ systems«  Thi≤ routinσ caε bσ calleΣ b∙ aε application≤ ì
  942. prograφ anΣ allo≈ thσ use≥ t∩ ente≥ ß linσ oµ tex⌠ (whicΦ i≤á wh∙ ì
  943. ╔á cal∞ i⌠ ß lineô edito≥ a≤ opposeΣ t∩ ß filσ editor⌐ anΣ correc⌠ ì
  944. hi≤ typinτ mistake≤ a≤ hσ goes.
  945.  
  946.      CP/═á provide≤ thσ use≥ witΦ aε inpu⌠ linσ edito≥ whicΦá ma∙ ì
  947. bσ calleΣ b∙ BDO╙ Functioε 10«  Thi≤ inpu⌠ linσ edito≥ i≤ useΣ b∙ ì
  948. thσá CP/═ Consolσ CommanΣ Processo≥ (CCP⌐ itself¼á anΣá i⌠á come≤ ì
  949. int∩á pla∙ wheε thσ A╛ (o≥ whateve≥ disk⌐ promp⌠á appears«á  Wheε ì
  950. thσ use≥ type≤ hi≤ CP/═ command¼ hσ i≤ withiε thσ BDO╙ inpu⌠ linσ ì
  951. editor¼á and¼á a≤á thσ reade≥ i≤ probabl∙ wel∞ aware¼á hσ ha≤ thσ ì
  952. abilit∙á t∩ deletσ thσ previou≤ character¼á erasσ thσ wholσá linσ ì
  953. anΣ star⌠ ove≥ again¼á retypσ thσ linσ a≤ entereΣ s∩ far¼á anΣ s∩ ì
  954. on.
  955.  
  956.      Thi≤á i≤ ß ver∙ importan⌠ kinΣ oµ function¼á and SYSLI┬ conì
  957. tain≤ threσ subroutine≤ whicΦ servσ a≤ inpu⌠ linσá editors«á  Tw∩ ì
  958. oµá them¼á BLIN┼ anΣ BBLINE¼á turε arounΣ anΣ cal∞ thσ BDO╙ inpu⌠ ì
  959. linσá edito≥á anΣ mainl∙ servσ a≤ ß shel∞ arounΣ thσá BDO╙á inpu⌠ ì
  960. linσ edito≥ whicΦ preserve≤ register≤ anΣ set≤ u≡á buffers«á  Thσ ì
  961. thirΣ inpu⌠ linσ editor¼á INLINE¼ i≤ ß completσ inpu⌠ linσ edito≥ ì
  962. iε it≤ owε right¼á anΣ i⌠ i≤ intendeΣ t∩ bσ useΣ wheε securit∙ i≤ ì
  963. important.
  964.  
  965.  
  966. 3.02 The BDOS-Based Input Line Editors
  967.  
  968.      Thσá tw∩á BDOS-BaseΣ inpu⌠ linσ editor≤ iε SYSLI┬ arσá BLIN┼ ì
  969. anΣ BBLINE«á  The∙ diffe≥ mainl∙ iε thσ wa∙ the∙ handlσá buffers¼ ì
  970. and¼á iεá botΦ cases¼á the∙ returε witΦ H╠ pointinτ t∩ thσá firs⌠ ì
  971. characte≥á oµá thσá strinτ inpu⌠ b∙ thσ use≥ anΣ thσá ┴á registe≥ ì
  972. containinτá ßá coun⌠á oµá thσ numbe≥á oµá character≤á typeΣá (no⌠ ì
  973. countinτ thσ endinτ zero)«á  Notσ tha⌠ H╠ i≤ returneΣ a≤ ß strinτ ì
  974. pointer¼ anΣ thσ inpu⌠ linσ i≤ storeΣ a≤ ß NULL-terminateΣ strinτ ì
  975. of characters in the standard SYSLIB sense.
  976.  
  977.      BBLIN┼á contain≤ ß 200-bytσ buffe≥ internall∙ iεá whicΦá thσ ì
  978. linσ t∩ bσ inpu⌠ i≤ stored«  Thi≤ i≤ probabl∙ thσ mos⌠ frequentl∙ ì
  979. useΣá oµá thσ SYSLI┬ inpu⌠ linσ editor≤ sincσ i⌠ i≤ s∩ simplσá t∩ ì
  980. use«á  It≤á onl∙ inpu⌠ i≤ ß flaτ iε thσ ┴ registe≥ -- iµ ┴ i≤á 0¼ ì
  981. thσ inpu⌠ linσ i≤ no⌠ capitalized¼á anΣ iµ ┴ i≤ no⌠ 0¼á thσ inpu⌠ ì
  982. linσ i≤ capitalized.  Example:
  983.  
  984.  
  985.                EXT  BBLINE    ; Reference BBLINE
  986.                EXT  PRINT     ; PRINT STRING ROUTINE
  987.                EX╘  PST╥      ╗ PRIN╘ STRIN╟ PTE─ T╧ B┘ HL
  988.                ...
  989.                CALL PRINT
  990.                DB   'What Is Your Name? ',0
  991.                XRA  A         ; A=0 SO DON'T CAPITALIZE LINE
  992.                CALL BBLINE    ; GET LINE FROM USER
  993.                               ; ON RETURN, HL PTS TO FIRST CHAR
  994.                               ;   AND A IS NUMBER OF CHARS TYPED
  995.                CALL PRINT
  996.                DB   0DH,0AH   ; NEW LINE
  997.                DB   'Your Name is: ',0
  998.                CALL PSTR      ; PRINT STRING PTED TO BY HL
  999.                               ; ... HL WAS SET BY BBLINE
  1000.                ...
  1001.  
  1002.  
  1003.      Thσ BLIN┼ routinσ i≤ simila≥ t∩ BBLINE¼ witΦ thσ onσ differì
  1004. encσ tha⌠ thσ use≥ provide≤ aε externa∞ buffer«  Thσ onl∙ advantì
  1005. agσ oµ BLIN┼ ove≥ BBLIN┼ i≤ tha⌠ i⌠ i≤ smalle≥ (doe≤ no⌠á contaiε ì
  1006. tha⌠ 200-bytσ buffer)¼ bu⌠ witΦ BLIN┼ thσ programme≥ ha≤ t∩ worr∙ ì
  1007. abou⌠ allocatinτ buffe≥ space«  Thσ samσ prograφ usinτ BLINE:
  1008.  
  1009.                EXT  BLINE     ; Reference BLINE
  1010.                EXT  PRINT     ; PRINT STRING ROUTINE
  1011.                EX╘  PST╥      ╗ PRIN╘ STRIN╟ PTE─ T╧ B┘ HL
  1012.                ...
  1013.                CALL PRINT
  1014.                DB   'What Is Your Name? ',0
  1015.                XRA  A         ; A=0 SO DON'T CAPITALIZE LINE
  1016.                LXI  H,INLINE  ; PT TO BUFFER
  1017.                CALL BLINE     ; GET LINE FROM USER
  1018.                               ; ON RETURN, HL PTS TO BUFF AND
  1019.                               ;   A IS NUMBER OF CHARS TYPED
  1020.                CALL PRINT
  1021.                DB   0DH,0AH   ; NEW LINE
  1022.                DB   'Your Name is: ',0
  1023.                CALL PSTR      ; PRINT STRING PTED TO BY HL
  1024.                               ; ... HL WAS SET BY BBLINE
  1025.                ...
  1026.      INLINE:   DB   40        ; SIZE OF BUFFER
  1027.                DB   0         ; RETURNED SIZE OF LINE
  1028.      BUFF:     DS   41        ; BUFFER SPACE + 1 FOR ENDING 0
  1029.  
  1030.  
  1031.  
  1032. 3.03 The INLINE Input Line Editor
  1033.  
  1034.      INLINE¼á a≤á mentioneΣ earlier¼á i≤ intendeΣ t∩ bσ useΣá fo≥ ì
  1035. securσá applications«á  I⌠á ha≤ tw∩ ke∙ feature≤ whicΦ comσá int∩ ì
  1036. play for such applications:
  1037.  
  1038.           1«á  INLIN┼ canno⌠ bσ aborteΣ b∙ ^C╗á thσ ^├ i≤á simpl∙ ì
  1039. stored in the input line buffer if the user types it
  1040.  
  1041.           2«á  INLIN┼á caε bσ madσ t∩ ech∩ it≤ inpu⌠ o≥ no⌠á ech∩ ì
  1042. it≤ input╗ iµ somethinτ likσ ß passworΣ i≤ beinτ entered¼ theε i⌠ ì
  1043. may be desirable not to echo the password back to the user
  1044.  
  1045.  
  1046.      INLIN┼á doe≤á no⌠ perforφ optiona∞ capitalizatioεá likσá thσ ì
  1047. othe≥ two¼ and¼ iµ capitalizatioε i≤ required¼ thσ CAPST╥ routinσ ì
  1048. caεá bσ useΣ immediatel∙ afte≥ thσ cal∞ t∩ INLIN┼ t∩ correc⌠ thi≤ ì
  1049. problem.
  1050.  
  1051.      A≤ ß tradeoff¼á INLIN┼ take≤ u≡ morσ spacσ thaε eithe≥ BLIN┼ ì
  1052. o≥ BBLINE¼á anΣ thσ use≥ stil∞ ha≤ t∩ providσ aε externa∞ buffer«  ì
  1053. INLIN┼ wil∞ no⌠ permi⌠ morσ thaε 25╢ character≤ t∩ bσ stored¼á s∩ ì
  1054. the buffer size should generally be 256+1 for the ending 0.
  1055.  
  1056.      Fo≥ inputs¼ INLIN┼ require≤ H╠ t∩ poin⌠ t∩ thσ firs⌠ bytσ oµ ì
  1057. thσ buffe≥ anΣ ┴ t∩ contaiε ß ░ iµ n∩ ech∩ i≤ desireΣ o≥ no⌠ ░ iµ ì
  1058. ech∩á i≤ desired«á  Notσ tha⌠ INLIN┼ require≤ H╠ t∩ poin⌠ t∩á thσ ì
  1059. firs⌠á bytσ oµ thσ buffe≥ itself¼á anΣ NO╘ ß buffe≥á sizσá value«  ì
  1060. Thσ examplσ abovσ implementeΣ witΦ INLIN┼ look≤ likσ this:
  1061.  
  1062.                EXT  INLINE    ; Reference INLINE
  1063.                EXT  PRINT     ; PRINT STRING ROUTINE
  1064.                EX╘  PST╥      ╗ PRIN╘ STRIN╟ PTE─ T╧ B┘ HL
  1065.                ...
  1066.                CALL PRINT
  1067.                DB   'What Is Your Password? ',0
  1068.                XRA  A         ; A=0 SO DON'T ECHO USER INPUT
  1069.                LXI  H,BUFF    ; PT TO BUFFER
  1070.                CALL INLINE    ; GET LINE FROM USER
  1071.                               ; ON RETURN, HL PTS TO BUFF
  1072.                CALL CAPSTR    ; CAPITALIZE INPUT STRING
  1073.                CALL PRINT
  1074.                DB   0DH,0AH   ; NEW LINE
  1075.                DB   'Your Password is: ',0
  1076.                CALL PSTR      ; PRINT STRING PTED TO BY HL
  1077.                               ; ... HL WAS SET BY BBLINE
  1078.                ...
  1079.      BUFF:     DS   257       ; BUFFER SPACE + 1 FOR ENDING 0
  1080.  
  1081. .fo 4 - SYSLIB Disk Input/Output                       Page #
  1082.  
  1083. 4.0 SYSLIB Disk Input/Output
  1084.  
  1085.      SYSLI┬á provide≤ ß numbe≥ oµ convenience≤ t∩ thσá programme≥ ì
  1086. wheεá i⌠ come≤ t∩ manipulatinτ thσ disδ unde≥ CP/M«á  Thσ librar∙ ì
  1087. provide≤ fivσ group≤ oµ utilitie≤ fo≥ disδ input/output:
  1088.  
  1089.           1.  Directory Manipulation Routines
  1090.                -- Allocate Buffer Space
  1091.                -- Extract Disk Parameter Information
  1092.                -- Determine Amount of Free Space on Disk
  1093.                -- Determine the Size of a Disk File
  1094.                -- Load a Disk Directory into Memory
  1095.                -- Alphabetize a Loaded Disk Directory
  1096.                -- Select Files from a Loaded Disk Directory
  1097.                -- Pack (Compress) a Loaded Disk Directory
  1098.                -- Combination Utility (Load, Select, Alphabetize,
  1099.                     and Pack a Disk Directory)
  1100.  
  1101.           2.  Block-Oriented File Input/Output
  1102.                -- Open, Create, and Close a File
  1103.                -- Delete a File
  1104.                -- Rename a File
  1105.                -- See if a File Exists
  1106.                -- Read and Write Blocks from and to a File
  1107.  
  1108.           3.  Byte-Oriented File Input/Output
  1109.                -- Open and Close a File
  1110.                -- Read and Write a Byte from and to a File
  1111.  
  1112.           4.  File Control Block (FCB) Manipulation
  1113.                -- Set Up an FCB from a String
  1114.                -- Initialize an FCB
  1115.  
  1116.           5.  ZCPR2-Specific Functions
  1117.                -- Initialize ZCPR2 SYSLIB Buffers
  1118.                -- Return Pointer to Next Character in Multiple
  1119.                     Command Line
  1120.                -- Return Status of a ZCPR2 File
  1121.                -- Search for a File Along the ZCPR2 Command
  1122.                     Path
  1123.                -- Determine User and Disk Referred to by a
  1124.                     ZCPR2 Named Directory
  1125.                -- Find a ZCPR2 Named Directory Index File
  1126.                -- Set Up an FCB from a String with ZCPR2
  1127.                     Named Directories Permitted
  1128.  
  1129.  
  1130.      Notσ tha⌠ thσ las⌠ se⌠ oµ routine≤ appl∙ t∩ ZCPR2«  ZCPR▓ i≤ ì
  1131. ßá replacemen⌠á fo≥á thσá CP/═ CC╨á tha⌠á ╔á aφá designinτá whicΦ ì
  1132. significantl∙á enhance≤á thσ powe≥ oµ thσ CC╨ anΣ give≤á i⌠á man∙ ì
  1133. capabilities similar to some found in the UNIX Operating System.
  1134.  
  1135.  
  1136. 4.01 Directory Manipulation Routines
  1137.  
  1138.      Thσá director∙ manipulatioε routine≤ oµ SYSLI┬ arσá designeΣ ì
  1139. witΦ ß maximuφ oµ generalit∙ anΣ flexibilit∙ iε mind«á  Actinτ t∩ ì
  1140. relievσá thσá programme≥á oµ thσ tasδ oµ writinτá routine≤á whicΦ ì
  1141. acces≤ thσ director∙ informatioε oε disk¼á thesσ routine≤á acces≤ ì
  1142. thσá disδá director∙ fo≥ hiφ anΣ loaΣ it≤ content≤ int∩ ßá memor∙ ì
  1143. buffer in a form which is relatively easy to use.
  1144.  
  1145.      Thσ imagσ oµ ß disδ director∙ a≤ placeΣ iε memor∙ b∙á SYSLI┬ ì
  1146. is a series of 16-byte entries organized as follows:
  1147.  
  1148.      ----------------------------------------------------------
  1149.      | 1 Byte | 8 Bytes | 3 Bytes | 1 Byte | 2 Bytes | 1 Byte |
  1150.      ----------------------------------------------------------
  1151.          ^         ^         ^         ^        ^         ^
  1152.          |         |         |         |        |         |
  1153.      ----------------------------------------------------------
  1154.      |User Num|File Name|File Type| Extent |  Unused | Rec Cnt|
  1155.      ----------------------------------------------------------
  1156.  
  1157.      Notσá tha⌠á thi≤ i≤ identica∞ t∩ thσ firs⌠ 1╢ byte≤á oµá thσ ì
  1158. CP/═ director∙ entr∙ a≤ i⌠ exist≤ oε disδ anΣ i≤ specifieΣ iε thσ ì
  1159. Filσ Contro∞ Blocδ (FCB)«á  Notσ als∩ tha⌠ thσ firs⌠ bytσ i≤ useΣ ì
  1160. t∩ indicatσ thσ Use≥ Numbe≥ associateΣ witΦ thσ file¼ anΣ NO╘ thσ ì
  1161. disδ numbe≥ (a≤ thi≤ bytσ i≤ useΣ fo≥ iε thσ FCB).
  1162.  
  1163.      Beforσ thσ disδ director∙ i≤ accessed¼ however¼ i⌠ i≤ usualì
  1164. l∙á ßá gooΣ ideß t∩ usσ thσ SYSLI┬ DBUFFE╥á routinσá t∩á allocatσ ì
  1165. memor∙ spacσ fo≥ thσ loadeΣ director∙ entries¼á especiall∙ iµ thσ ì
  1166. alphabetizatioε routinσ i≤ t∩ bσ useΣ later«  Thσ DBUFFE╥ routinσ ì
  1167. i≤ passeΣ ß pointe≥ t∩ ß scratcΦ memor∙ areß whicΦ extend≤ t∩ thσ ì
  1168. to≡á oµ thσ TPA¼á anΣ i⌠ accesse≤ thσ disδ paramete≥ information¼ ì
  1169. allocate≤ pointe≥ spacσ fo≥ thσ alphabetizatioεá routine¼á check≤ ì
  1170. fo≥ Transien⌠ Prograφ Areß (TPA⌐ overflow¼á anΣ return≤ ß pointe≥ ì
  1171. t∩ thσ nex⌠ availablσ bytσ afte≥ thσ pointe≥ spacσ int∩ whicΦ thσ ì
  1172. director∙ i≤ t∩ bσ late≥ loaded.
  1173.  
  1174.      Thσá memor∙á addres≤ requireΣ b∙ DBUFFE╥ caεá bσá frequentl∙ ì
  1175. provideΣá b∙ thσ CODEN─ routinσ (unles≤ thσ scratcΦ areßá i≤á alì
  1176. read∙ beinτ useΣ b∙ thσ program¼ iε whicΦ casσ thσ programme≥ ha≤ ì
  1177. t∩ providσ thi≤ valuσ froφ withiε hi≤ code)«á  DBUFFE╥ anΣ CODEN─ ì
  1178. fi⌠á nicel∙ togethe≥ fo≥ thi≤ purpose«á  Thσ typica∞ callinτá seì
  1179. quencσ look≤ likσ this:
  1180.  
  1181.                ...
  1182.                CALL CODEND
  1183. ;  HL now points to the bottom of the scratch area
  1184.                CALL DBUFFER
  1185. ;  HL now points to the bottom of the directory load area
  1186. ;    and A = 0 and Zero Flag is Set (Z) if TPA Overflow
  1187.                JZ   TPAOVFL   ; Handle Error and Abort
  1188.                ...
  1189.      The memory map for directory access looks like this:
  1190.  
  1191.                          -------------------------------
  1192.                          | CP/M BDOS                   |
  1193.      Top of TPA/Bottom   -------------------------------
  1194.        of BDOS           | Unused Space                |
  1195.                          -------------------------------
  1196.      DIRLOAD or DIRSLOAD | Directory Entries (16 Bytes)|
  1197.        Load This ----->  |   are loaded here           |
  1198.                          -------------------------------
  1199.      DBUFFER Computes    | Pointer Space for Alphabet- |
  1200.        This ---------->  |   ization                   |
  1201.      Beginning of        -------------------------------
  1202.        Scratch Area      | Dead Space                  |
  1203.      End of Program      -------------------------------
  1204.                          | CODEND Routine              |
  1205.                          -------------------------------
  1206.                          | Other SYSLIB Routines       |
  1207.                          -------------------------------
  1208.                          | Programmer's Code           |
  1209.      100H                -------------------------------
  1210.  
  1211.      Note║á  I⌠ i≤ assumeΣ tha⌠ thσ programme≥ ha≤ alread∙ loggeΣ ì
  1212. iε thσ requireΣ disδ beforσ DBUFFE╥ i≤ called«á  Iµ not¼ thσ disδ ì
  1213. paramete≥ informatioε ma∙ bσ iεá error¼á and¼á consequently¼á inì
  1214. sufficien⌠ pointe≥ spacσ ma∙ bσ allocated.
  1215.  
  1216.      DBUFFE╥ call≤ thσ routinσ DPARAM╙ t∩ determinσ thσ specific≤ ì
  1217. oεá thσá CP/═ disδ structurσ anΣ thσ informatioε i⌠á require≤á t∩ ì
  1218. allocatσ thσ pointe≥ space«á  Iε particular¼á DPARAM╙ return≤ thσ ì
  1219. maximuφ numbe≥ oµ disδ director∙ entries¼á anΣ DBUFFE╥á allocate≤ ì
  1220. enougΦ pointe≥ spacσ t∩ loaΣ al∞ director∙ entrie≤ iµ necessary.
  1221.  
  1222.      DPARAM╙á extract≤ mucΦ necessar∙ informatioε fo≥ usσ b∙ SYSì
  1223. LI┬ iε dealinτ witΦ disδ directories«  Thσ programme≥ neeΣ no⌠ bσ ì
  1224. concerneΣá witΦ exactl∙ wha⌠ thi≤ informatioεá is¼á sincσá SYSLI┬ ì
  1225. use≤ i⌠ internall∙ anΣ provide≤ thσ programme≥ witΦ wha⌠ hσ need≤ ì
  1226. t∩ kno≈ througΦ it≤ subroutines«  Fo≥ thσ interes⌠ oµ thσ reader¼ ì
  1227. however¼á thσá followinτ informatioε i≤ extracteΣ b∙ DPARAM╙á fo≥ ì
  1228. interna∞ SYSLI┬ use:
  1229.  
  1230.           o Block Shift Factor
  1231.           o Block Mask
  1232.           o Extent Mask
  1233.           o Maximum Number of Blocks on Disk
  1234.           o Maximum Number of Directory Entries
  1235.  
  1236.      Thosσ reader≤ familia≥ witΦ CP/═ internal≤ ma∙ bσ interesteΣ ì
  1237. t∩á kno≈ tha⌠ thi≤ i≤ al∞ oµ thσ informatioε requireΣ t∩á perforφ ì
  1238. thesσá disδ functions«á  DPARAM╙ als∩ determine≤ wha⌠ versioεá oµ ì
  1239. CP/═ i≤ beinτ useΣ (1.┤ o≥ 2.▓ o≥ MP/M)¼ anΣ extract≤ thi≤ inforì
  1240. matioεá froφ thσ BDO╙ internal≤ iµ CP/═ 1.┤ i≤ beinτ useΣ o≥ froφ ì
  1241. thσ BDO╙ Functioε Call≤ iµ CP/═ 2.▓ o≥ MP/═ i≤ beinτ used«  Thosσ ì
  1242. reall∙ interesteΣ iε pursuinτ morσ detai∞ arσ inviteΣ t∩ reaΣ thσ ì
  1243. SYSLI┬ sourcσ code.è     No≈ tha⌠ thσ preliminarie≤ arσ overwitΦ anΣ thσ buffer≤ havσ ì
  1244. beeε properl∙ initialized¼á thσ nex⌠ logica∞ ste≡ i≤ t∩ loaΣá thσ ì
  1245. disδá directory«á  Tw∩á SYSLI┬ routine≤ arσ provideΣ t∩ d∩á this║  ì
  1246. DIRLOAD and DIRSLOAD.
  1247.  
  1248.      BotΦ DIRLOA─ anΣ DIRSLOA─ loaΣ thσ director∙ buffe≥á pointeΣ ì
  1249. t∩á b∙á H╠ witΦ thσ entrie≤ oµ al∞ uneraseΣ file≤ oε thσ disδá iε ì
  1250. al∞á use≥ area≤ oµ thσ disk«á  Also¼á botΦ DIRLOA─á anΣá DIRSLOA─ ì
  1251. returεá ßá flaτá iε thσ ┴ registe≥ iµ TP┴á Overflo≈á occur≤á (no⌠ ì
  1252. enougΦá rooφ t∩ storσ al∞ thσ director∙ entries)¼á and¼á iµ ß TP┴ ì
  1253. overflo≈ ha≤ no⌠ occurred¼ theε thσ B├ registe≥ pai≥ contain≤ thσ ì
  1254. numbe≥ oµ director∙ entrie≤ loadeΣ int∩ memory.
  1255.  
  1256.      Thσá tradeofµá betweeεá DIRLOA─ anΣ DIRSLOA─á lie≤á iεá wha⌠ ì
  1257. informatioεá i≤á requireΣ b∙ thσá programmer«á  DIRLOA─á execute≤ ì
  1258. faste≥ thaε DIRSLOAD¼á anΣ i⌠ load≤ onl∙ thσ firs⌠ entr∙ fo≥ eacΦ ì
  1259. file«  DIRSLOAD¼ however¼ load≤ thσ LAS╘ entr∙ fo≥ eacΦ file¼ anΣ ì
  1260. iµá thσá programme≥á wishe≤á t∩ late≥ computσá thσá sizσá oµá hi≤ ì
  1261. selected files, DIRSLOAD must be used instead of DIRLOAD.
  1262.  
  1263.      T∩á recap¼á DIRLOA─ anΣ DIRSLOA─ providσ thσá "proces≤á boxó ì
  1264. whicΦá load≤ ß director∙ froφ disδ int∩ memory«á  Ou≥á developinτ ì
  1265. program now looks like this:
  1266.  
  1267.                ...
  1268.                CALL CODEND
  1269. ;  HL now points to the bottom of the scratch area
  1270.                CALL DBUFFER
  1271. ;  HL now points to the bottom of the directory load area
  1272. ;    and A = 0 and Zero Flag is Set (Z) if TPA Overflow
  1273.                JZ   TPAOVFL   ; Handle Error and Abort
  1274.                CALL DIRLOAD   ; Load Disk Directory
  1275. ;  DIRLOAD/DIRSLOAD only affect BC, so, at this point:
  1276. ;    HL = address of first directory entry loaded
  1277. ;    BC = number of directory entries loaded if no error
  1278. ;    A = error flag (A=0 and Zero Flag Set if TPA Overflow)
  1279.                JZ   TPAOVFL   ; Handle Error and Abort
  1280.                ...
  1281.  
  1282.      No≈á tha⌠á thσ disδ director∙ ha≤ beeε loadeΣá int∩á memory¼ ì
  1283. wha⌠ type≤ oµ thing≤ woulΣ onσ wan⌠ t∩ d∩ witΦ it┐  Unde≥ SYSLIB¼ ì
  1284. routine≤ arσ provideΣ t∩ d∩ thσ following:
  1285.  
  1286.           o Select Entries (Match Target FCB)
  1287.           o Pack Directory Image (Get Rid of Unselected Entries)
  1288.           o Alphabetize the Directory Image
  1289.           o Compute Sizes of Files
  1290.  
  1291.  
  1292.      DIRSE╠á i≤ thσ routinσ useΣ t∩ selec⌠ entrie≤ froφ ßá loadeΣ ì
  1293. disk directory.  DIRSEL requires the following information:
  1294.  
  1295.           HL = address of first entry
  1296.           DE = address of FCB containing of desired files
  1297.                - only the file name and file type fields are
  1298.                  used, so a full FCB need not be allocated
  1299.                - only the first 12 bytes of an FCB are required
  1300.                  by DIRSEL, and the first byte is ignored
  1301.           BC = number of files in the directory
  1302.           A  = selection flag, organized as follows:
  1303.                - Bit 7 = Select Non-System Files if Set
  1304.                - Bit 6 = Select System Files if Set
  1305.                - Bit 5 = Select Files in All User Areas if Set
  1306.                - Bits 4-0 = If Bit 5 is 0, user number (5 bits)
  1307.                     of user area to select files from
  1308.  
  1309.      Ou≥ evolvinτ prograφ no≈ contain≤ ß DIRSE╠ cal∞ a≤ thσá nex⌠ ì
  1310. logica∞ step:
  1311.  
  1312.                ...
  1313.                CALL CODEND
  1314. ;  HL now points to the bottom of the scratch area
  1315.                CALL DBUFFER
  1316. ;  HL now points to the bottom of the directory load area
  1317. ;    and A = 0 and Zero Flag is Set (Z) if TPA Overflow
  1318.                JZ   TPAOVFL   ; Handle Error and Abort
  1319.                CALL DIRLOAD   ; Load Disk Directory
  1320. ;  DIRLOAD/DIRSLOAD only affect BC, so, at this point:
  1321. ;    HL = address of first directory entry loaded
  1322. ;    BC = number of directory entries loaded if no error
  1323. ;    A = error flag (A=0 and Zero Flag Set if TPA Overflow)
  1324.                JZ   TPAOVFL   ; Handle Error and Abort
  1325. ;  Prepare for DIRSEL Call
  1326. ;  HL and BC already contained values required by DIRSEL
  1327.                LXI  D,FCB     ; Point to FCB
  1328.                MVI  A,11100000B    ; Select Non-System and System
  1329.                                    ;   Files in All User Areas
  1330.                CALL DIRSEL
  1331. ;  No Error Code is Returned, and
  1332. ;  All Registers are Unchanged; Hence, the following important
  1333. ;  values are retained:
  1334. ;    HL = address of first directory entry loaded
  1335. ;    BC = number of directory entres loaded
  1336.                ...
  1337. ;
  1338. ;  Data Buffer Area
  1339. ;
  1340. FCB:
  1341.      DB   0    ; Just Filler
  1342.      DB   'ANYFIL? TXT'  ; File Spec, may include wild card of ?
  1343.  
  1344.  
  1345.      DIRSE╠ select≤ it≤ file≤ b∙ settinτ thσ Mos⌠ Significan⌠ Bi⌠ ì
  1346. oµá thσ Use≥ Numbe≥ fielΣ oµ thσ selecteΣ director∙ entrie≤ t∩á ß ì
  1347. 1«á  Hence¼ sincσ thi≤ i≤ al∞ tha⌠ i≤ changed¼ DIRSE╠ ma∙ bσ useΣ ì
  1348. repeatedl∙á t∩ selec⌠ severa∞ group≤ oµ files¼á anΣ thesσá group≤ ì
  1349. ma∙ includσ thσ samσ file≤ (MYF?┐á anΣ MYF┐ ma∙ matcΦ somσ oµ thσ ì
  1350. samσ files)«á  Sincσ DIRSE╠ change≤ n∩ registers¼á onσ cal∞ afte≥ ì
  1351. another may be made:
  1352.  
  1353.           ...
  1354.           LXI  D,FCB1    ; Match first set
  1355.           MVI  A,11100000B    ; Non-Sys, Sys, and All Users
  1356.           CALL DIRSEL
  1357.           LXI  D,FCB2    ; Match 2nd set
  1358.           CALL DIRSEL
  1359.           ...
  1360.  
  1361.      Oncσá al∞ thσ desireΣ file≤ havσ beeε selected¼á DIRPAC╦ anΣ ì
  1362. DIRNPAC╦ arσ useΣ t∩ pacδ thσ director∙ buffer¼á leavinτ iεá onl∙ ì
  1363. thosσ entrie≤ desired«  Iµ DIRPAC╦ i≤ used¼ entrie≤ NO╘ markeΣ b∙ ì
  1364. DIRSE╠á arσ discarded¼á anΣ thσ buffe≥ i≤ reorganizeΣ t∩á contaiε ì
  1365. onl∙á thosσ entrie≤ markeΣ b∙ DIRSEL«á  Iµ DIRNPAC╦ i≤ used¼á enì
  1366. trie≤á markeΣ b∙ DIRSE╠ arσ discardeΣ (negativσá selection)¼á anΣ ì
  1367. thσá buffe≥á i≤á reorganizeΣ t∩ contaiε onl∙á thosσá entrie≤á NO╘ ì
  1368. markeΣ b∙ DIRSEL.
  1369.  
  1370.      DIRPACK and DIRNPACK require the following inputs:
  1371.           HL = address of first entry in directory buffer
  1372.           BC = number of entries in directory buffer
  1373.  
  1374.      DIRPACK and DIRNPACK return the following values:
  1375.           HL = address of first entry in directory buffer
  1376.           BC = number of desired entries left in directory buffer
  1377.  
  1378.      Notσ tha⌠ onl∙ thσ B├ registe≥ pai≥ ma∙ bσ changed¼á anΣ al∞ ì
  1379. othe≥ register≤ arσ no⌠ affected«  Again¼ ou≥ prograφ no≈ evolve≤ ì
  1380. as indicated:
  1381.  
  1382.  
  1383.                ...
  1384.                CALL CODEND
  1385. ;  HL now points to the bottom of the scratch area
  1386.                CALL DBUFFER
  1387. ;  HL now points to the bottom of the directory load area
  1388. ;    and A = 0 and Zero Flag is Set (Z) if TPA Overflow
  1389.                JZ   TPAOVFL   ; Handle Error and Abort
  1390.                CALL DIRLOAD   ; Load Disk Directory
  1391. ;  DIRLOAD/DIRSLOAD only affect BC, so, at this point:
  1392. ;    HL = address of first directory entry loaded
  1393. ;    BC = number of directory entries loaded if no error
  1394. ;    A = error flag (A=0 and Zero Flag Set if TPA Overflow)
  1395.                JZ   TPAOVFL   ; Handle Error and Abort
  1396. ;  Prepare for DIRSEL Call
  1397. ;  HL and BC already contained values required by DIRSEL
  1398.                LXI  D,FCB     ; Point to FCB
  1399.                MVI  A,11100000B    ; Select Non-System and System
  1400.                                    ;   Files in All User Areas
  1401.                CALL DIRSEL
  1402. ;  No Error Code is Returned, and
  1403. ;  All Registers are Unchanged; Hence, the following important
  1404. ;  values are retained:
  1405. ;    HL = address of first directory entry loaded
  1406. ;    BC = number of directory entries loaded
  1407.                CALL DIRPACK   ; Pack Directory
  1408. ;  Only BC is changed, and now:
  1409. ;    BC = number of remaining (desired) directory entries
  1410. ;  This is typically followed by a test to see if BC=0 (no
  1411. ;  entries selected
  1412.                MOV  A,B       ; See if BC=0
  1413.                ORA  C
  1414.                JZ   EMPTY     ; Process No Selected File Routine
  1415.                ...
  1416. ;
  1417. ;  Data Buffer Area
  1418. ;
  1419. FCB:
  1420.      DB   0    ; Just Filler
  1421.      DB   'ANYFIL? TXT'  ; File Spec, may include wild card of ?
  1422.  
  1423.  
  1424.      Finally¼á no≈á tha⌠ wσ havσ loadeΣ thσ director∙ froφá disk¼ ì
  1425. selecteΣ thσ files¼á anΣ finall∙ packeΣ thσ loadeΣ directory¼á wσ ì
  1426. ma∙á wisΦ t∩ alphabetizσ thi≤ loadeΣ director∙ fo≥ easσ oµ acces≤ ì
  1427. anΣ user-friendlines≤ iε ou≥ prograφ (lis⌠ thσ file≤ t∩ thσá use≥ ì
  1428. alphabetically)«  DIRALPH┴ i≤ thσ SYSLI┬ routinσ whicΦ doe≤ this.
  1429.  
  1430.      DIRALPH┴á require≤ thσ followinτ input≤ anΣ ha≤ n∩ effec⌠ oε ì
  1431. any registers:
  1432.  
  1433.           HL = address of first directory entry
  1434.           BC = number of directory entries to sort
  1435.           A  = sort flag; if A=0, sort first by file name and
  1436.                then by file type (HISFILE.TXT comes before
  1437.                MYFILE.MAC), else sort first by file type and
  1438.                then by file name (MYFILE.MAC comes before
  1439.                HISFILE.TXT)
  1440.  
  1441.      Our program has finally evolved into the following:
  1442.  
  1443.                ...
  1444.                CALL CODEND
  1445. ;  HL now points to the bottom of the scratch area
  1446.                CALL DBUFFER
  1447. ;  HL now points to the bottom of the directory load area
  1448. ;    and A = 0 and Zero Flag is Set (Z) if TPA Overflow
  1449.                JZ   TPAOVFL   ; Handle Error and Abort
  1450.                CALL DIRLOAD   ; Load Disk Directory
  1451. ;  DIRLOAD/DIRSLOAD only affect BC, so, at this point:
  1452. ;    HL = address of first directory entry loaded
  1453. ;    BC = number of directory entries loaded if no error
  1454. ;    A = error flag (A=0 and Zero Flag Set if TPA Overflow)
  1455.                JZ   TPAOVFL   ; Handle Error and Abort
  1456. ;  Prepare for DIRSEL Call
  1457. ;  HL and BC already contained values required by DIRSEL
  1458.                LXI  D,FCB     ; Point to FCB
  1459.                MVI  A,11100000B    ; Select Non-System and System
  1460.                                    ;   Files in All User Areas
  1461.                CALL DIRSEL
  1462. ;  No Error Code is Returned, and
  1463. ;  All Registers are Unchanged; Hence, the following important
  1464. ;  values are retained:
  1465. ;    HL = address of first directory entry loaded
  1466. ;    BC = number of directory entries loaded
  1467.                CALL DIRPACK   ; Pack Directory
  1468. ;  Only BC is changed, and now:
  1469. ;    BC = number of remaining (desired) directory entries
  1470. ;  This is typically followed by a test to see if BC=0 (no
  1471. ;  entries selected
  1472.                MOV  A,B       ; See if BC=0
  1473.                ORA  C
  1474.                JZ   EMPTY     ; Process No Selected File Routine
  1475.                CALL DIRALPHA  ; Alphabetize Directory
  1476. ;  No error codes are returned, and the following registers are
  1477. ;  significant:
  1478. ;    HL = address of first directory entry loaded
  1479. ;    BC = number of directory entries loaded
  1480. ;  The programmer may now continue with his specific application
  1481.                ...
  1482. ;
  1483. ;  Data Buffer Area
  1484. ;
  1485. FCB:
  1486.      DB   0,'ANYFIL? TXT'  ; File Spec, may include wild card of ?è
  1487.      A≤á thσ reade≥ caε see¼á thσ SYSLI┬ routine≤á arσá certainl∙ ì
  1488. cohesivel∙ designeΣ anΣ worδ togethe≥ witΦ ß minimuφ oµ overheadí  ì
  1489. Sincσ thσ abovσ sequencσ oµ instruction≤ arσ s∩ frequentl∙ needeΣ ì
  1490. iε exactl∙ thσ samσ order¼ ╔ havσ toppeΣ ofµ thσ SYSLI┬ director∙ ì
  1491. manipulation routine module with the DIRF and DIRFS routines.
  1492.  
  1493.      DIR╞ anΣ DIRF╙ perforφ thσ followinτ operation≤ iε thσ orde≥ ì
  1494. indicated:
  1495.  
  1496.           1.  Initialize Buffer Area (DBUFFER call)
  1497.           2.  Load the Disk Directory into the Buffer
  1498.                (DIRF calls DIRLOAD, DIRFS calls DIRSLOAD)
  1499.           3.  Select a Set of Files (DIRSEL call)
  1500.           4.  Pack the Files in the Memory Buffer (DIRPACK call)
  1501.           5.  Alphabetize the Files in the Memory Buffer
  1502.                (DIRALPHA call) by file name and then file type
  1503.  
  1504.      DIRF and DIRFS require the following input parameters:
  1505.  
  1506.           H╠ ╜ basσ oµ dynamiπ buffe≥ areß (a≤ returneΣ b∙
  1507.                CODEND)
  1508.           DE = address of FCB containing file spec to match
  1509.                (only 1st 12 bytes required)
  1510.           A  = selection flag, as for DIRSEL
  1511.  
  1512.      DIRF and DIRFS return the following output parameters:
  1513.  
  1514.           HL = address of first file entry
  1515.           BC = number of file entries
  1516.           A  = error flag; A=0 and Zero Flag Set (Z) if TPA
  1517.                Overflow occurred
  1518.  
  1519.      The DIRF/DIRFS calling sequence is typically:
  1520.  
  1521.           ...
  1522.           EXT  CODEND    ; Use CODEND
  1523.           EXT  DIRF      ; Use DIRF
  1524.           ...
  1525.           CALL CODEND    ; Get Scratch Area Address
  1526.           LXI  D,FCB     ; Pt to FCB
  1527.           MVI  A,11100000B    ; Non-Sys, Sys, in all User Areas
  1528.           CALL DIRF      ; Do It!
  1529.           ...
  1530.      FCB: DB   0,'????????TXT'     ; Select all TXT files
  1531.           ...
  1532.  
  1533.  
  1534.      Finally¼á thσá las⌠ tw∩ subroutine≤ availablσ iε SYSLI┬á fo≥ ì
  1535. directory manipulation are DFREE and FSIZE.
  1536.  
  1537.      DFRE┼á compute≤ thσ amoun⌠ oµ freσ spacσ lef⌠ oεá disk¼á anΣ ì
  1538. return≤á thi≤ valuσ (iε ╦ bytes⌐ iε DE«á  N∩ othe≥ register≤á arσ ì
  1539. affected«á  Thσ desireΣ disδ shoulΣ bσ loggeΣ in¼á DPARAM╙ shoulΣ ì
  1540. bσ calleΣ t∩ extrac⌠ thσ desireΣ informatioε fo≥ tha⌠ disk'≤ disδ ì
  1541. parameter block, and then DFREE should be called.
  1542.  
  1543.      FSIZ┼á compute≤ thσ sizσ oµ thσ filσ whosσ loadeΣá director∙ ì
  1544. entr∙ (mus⌠ havσ beeε loadeΣ b∙ DIRSLOA─ througΦ eithe≥ ß cal∞ t∩ ì
  1545. DIRSLOA─á o≥ ß cal∞ t∩ DIRFS⌐ i≤ pointeΣ t∩ b∙ HL«á  Thσ sizσá oµ ì
  1546. this file in K bytes is returned as a binary number in DE.
  1547.  
  1548.      Thi≤ complete≤ thσ discussioε oµ thσ director∙á manipulatioε ì
  1549. routine≤ oµ SYSLIB«á  Onσ fina∞ note║á  al∞ oµ thesσ routine≤ arσ ì
  1550. containeΣ iε thσ SDI╥ module¼á anΣ thσ entirσ modulσ i≤ loadeΣ iµ ì
  1551. an∙á onσá oµá thesσ routine≤ i≤á called«á  Sincσá thσá programme≥ ì
  1552. frequentl∙ want≤ t∩ usσ severa∞ oµ thesσ routine≤ iε hi≤ code¼á ╔ ì
  1553. did not consider this to be an unnecessary overhead burdon.
  1554.  
  1555.  
  1556. 4.02 Block-Oriented File Input/Output
  1557.  
  1558.      Thσ block-orienteΣ filσ input/outpu⌠ routine≤ oµ SYSLI┬ wil∞ ì
  1559. bσá discusseΣ briefl∙ iε thi≤ documen⌠ sincσ the∙ arσ quitσ simiì
  1560. la≥á t∩á thei≥ BDO╙ counterparts«á  Thσ majo≥ thinτá tha⌠á SYSLI┬ ì
  1561. offer≤á witΦá thesσá routine≤ i≤ no⌠ havinτ t∩á worr∙á abou⌠á thσ ì
  1562. effect≤ oµ thesσ routine≤ oε registers«á  Iε al∞ cases¼á onl∙ thσ ì
  1563. PS╫ i≤ affecteΣ b∙ thesσ routines¼ anΣ i⌠ i≤ useΣ t∩ returε erro≥ ì
  1564. codes«á  Thσ Block-OrienteΣ Filσ Input/Outpu⌠ routine≤ iεá SYSLI┬ ì
  1565. are:
  1566.  
  1567.           F$OPEN    Open the file whose FCB is pointed to by DE
  1568.                     Returns normal CP/M Error Code in A
  1569.           F$MOPEN   FCB is pointed to by DE, and, if the file is
  1570.                     not already existing, it is created; other-
  1571.                     wise, it is just opened;
  1572.                     Returns Error Code in A
  1573.           F$CLOSE   Close the file whose FCB is pointed to by DE
  1574.           F$MAKE    Create the file whose FCB is pointed to by
  1575.                     DE
  1576.           F$DELETE  Delete the file whose FCB is pointed to by DE
  1577.           F$RENAME  Rename the file whose FCB is pointed to by DE
  1578.                     to that whose FCB is pointed to by HL; only
  1579.                     the first 12 bytes of each FCB is required;
  1580.                     F$RENAME returns with the Zero Flag Set if
  1581.                     the original file was not found
  1582.           F$EXIST   Determine if the file whose FCB is pointed to
  1583.                     b∙ D┼ exist≤ iε thσ curren⌠ disδ anΣ use≥
  1584.                     area; F$EXIST returns with the Zero Flag Set
  1585.                     if the file does not exist
  1586.           F$READ    Read Block; usual error code
  1587.           F$WRITE   Write Block; usual error codeè
  1588.      Notσá tha⌠á thesσá routine≤ arσ mainl∙á reflection≤á oµá thσ ì
  1589. conventiona∞ BDO╙ functions«  Significan⌠ extension≤ arσ F$MOPEN¼ ì
  1590. F$RENAME, and F$EXIST.  Example follows:
  1591.  
  1592.           ...
  1593.           LXI  D,FCB2    ; test for existance of file
  1594.           CALL F$EXIST
  1595.           JZ   NOFILE
  1596. ;
  1597. ;  DE Still Points to FCB of Old File
  1598. ;
  1599.           LXI  H,FCB1    ; new FCB
  1600.           CALL F$RENAME  ; rename file
  1601.           ...
  1602. FCB1:     DB   0,'NEWFILE TXT'     ; new file name
  1603. FCB2:     DB   0,'OLDFILE TXT'     ; old file name
  1604.           ...
  1605.  
  1606.  
  1607.  
  1608. 4.03 Byte-Oriented File Input/Output
  1609.  
  1610.      SYSLI┬ take≤ ß significan⌠ ste≡ beyonΣ thσ conventiona∞ CP/═ ì
  1611. block-orienteΣá filσá input/outpu⌠á capabilitie≤ witΦá it≤á byte-ì
  1612. orienteΣ filσ input/outpu⌠ capabilities«á  Thesσ routines¼ unlikσ ì
  1613. thσá other≤á whicΦ requirσ thσ use≥ t∩ reaΣ t∩ anΣ writσá froφá ß ì
  1614. filσ oε ß blocδ basi≤ (12╕ byte≤ a⌠ ß time)¼ allo≈ thσ programme≥ ì
  1615. t∩á reaΣ froφ anΣ writσ t∩ ß CP/═ filσ oε ß byte-for-bytσá basis«  ì
  1616. Thesσ routines¼ oε read¼ reaΣ iε ß blocδ a≤ requireΣ anΣ continuσ ì
  1617. t∩ returε onl∙ thσ nex⌠ bytσ requesteΣ b∙ thσ programmer¼ and¼ oε ì
  1618. write¼á collec⌠ u≡ t∩ 12╕ byte≤ sen⌠ ou⌠ b∙ thσ programmer¼ writσ ì
  1619. tha⌠ block¼ anΣ theε continuσ collectinτ bytes.
  1620.  
  1621.      Thσá utilit∙ oµ thesσ routine≤ i≤ enhanceΣ b∙ thσ fac⌠á tha⌠ ì
  1622. the∙á caε bσ useΣ withou⌠ carσ b∙ thσ programmer«á  Fo≥á example¼ ì
  1623. F0$PU╘á i≤ useΣ t∩ outpu⌠ onσ bytσ t∩ filσ 0¼á anΣ thσá followinτ ì
  1624. samplσ codσ print≤ ß strinτ oµ byte≤ t∩ thσ console¼ printer¼ anΣ ì
  1625. disk file, using SYSLIB routines:
  1626.  
  1627.  
  1628.           ...
  1629.           LXI  D,FCB     ; POINT TO FCB OF OUTPUT FILE
  1630.           CALL INITFCB   ; CLEAR PROPER FCB FIELDS
  1631.           CALL FO0$OPEN  ; OPEN FILE 0 FOR OUTPUT
  1632.           JZ   FERR      ; FILE ERROR HANDLER
  1633.           LXI  H,STRING  ; POINT TO STRING TO OUTPUT
  1634. LOOP:
  1635.           MOV  A,M       ; GET NEXT CHARACTER
  1636.           ORA  A         ; END OF STRING IF 0
  1637.           JZ   DONE      ; DONE IF END OF STRING
  1638.           CALL F0$PUT    ; WRITE BYTE TO DISK
  1639.           JZ   FERR
  1640.           CALL COUT      ; WRITE BYTE TO CONSOLE
  1641.           CALL LOUT      ; WRITE BYTE TO PRINTER
  1642.           INX  H         ; POINT TO NEXT BYTE
  1643.           JMP  LOOP      ; CONTINUE UNTIL DONE
  1644. DONE:
  1645.           CALL FO0$CLOSE ; CLOSE OUTPUT FILE
  1646.           ...
  1647. FERR:                    ; ERROR HANDLER
  1648.           ...
  1649. FCB:      DB   0,'OUTFILE TXT'     ; OUTPUT FILE FCB
  1650.           DS   4
  1651.           DS   16
  1652.           DS   4         ; FOUR MORE BYTES FOR SYSLIB
  1653.           ...
  1654.  
  1655.  
  1656.      Thi≤ examplσ i≤ probabl∙ adequatσ t∩ sho≈ thσ reade≥ ho≈á t∩ ì
  1657. usσá SYSLI┬á iε general«á  Thσ followinτ arσ thσ SYSLI┬á routine≤ ì
  1658. used to support Byte-Oriented File Input and Output:
  1659.  
  1660.  File Open for       File Close for           Byte-Oriented
  1661. Input     Output    Input     Output         Read      Write
  1662. -----     ------    -----     ------         ----      -----
  1663. FI0$OPEN  FO0$OPEN  FI0$CLOSE FO0$CLOSE      F0$GET    F0$PUT
  1664. FI1$OPEN  FO1$OPEN  FI1$CLOSE FO1$CLOSE      F1$GET    F1$PUT
  1665. FI2$OPEN  FO2$OPEN  FI2$CLOSE FO2$CLOSE      F2$GET    F2$PUT
  1666. FI3$OPEN  FO3$OPEN  FI3$CLOSE FO3$CLOSE      F3$GET    F3$PUT
  1667.  
  1668.      U≡ t∩ eigh⌠ file≤ caε bσ opeε a⌠ onσ timσ -- fou≥ fo≥á inpu⌠ ì
  1669. anΣ fou≥ fo≥ output«  Thσ sequencσ oµ call≤ t∩ usσ thesσ routine≤ ì
  1670. is always the same:
  1671.  
  1672.           < Open Files for Input or Output >
  1673.           < Read or Write Bytes using GET and PUT >
  1674.           < Close Files for Input or Output >
  1675.  
  1676.  
  1677.      Thσ abovσ examplσ showeΣ ho≈ thi≤ wa≤ donσ fo≥ writinτ t∩á ß ì
  1678. file«á  Thσ $OPE╬ routine≤ requirσ ß 36-bytσ FC┬ whicΦ i≤ pointeΣ ì
  1679. t∩ b∙ D┼ a≤ aε inpu⌠ argument¼ anΣ the∙ returε witΦ thσ Zer∩ Flaτ ì
  1680. Se⌠á iµ aε erro≥ occurred«á  Thσ $CLOS┼ routine≤ requirσ n∩ inpu⌠ ì
  1681. argumen⌠ (the∙ kno≈ wha⌠ file≤ the∙ arσ dealinτ with)¼á anΣá the∙ ì
  1682. returεá witΦá Zer∩ Flaτ Se⌠ iµ aε erro≥ occurred«á  Thσ $GE╘á anΣ ì
  1683. $PU╘á routine≤ onl∙ requirσ ┴ t∩ contaiε thσ characte≥ t∩á outpu⌠ ì
  1684. (fo≥á thσ $PU╘ routines⌐ o≥ inpu⌠ (fo≥ thσá $GE╘á routines)¼á anΣ ì
  1685. the∙ returε aε erro≥ flaτ (Zer∩ Flaτ Se⌠ iµ Error⌐ anΣ erro≥ codσ ì
  1686. (iεá A⌐ iµ aε erro≥ occurs«á  Iµ aε erro≥ occurs¼á ┴ return≤á thσ ì
  1687. erro≥ code╗ iµ n∩ erro≥ occurs¼ ┴ i≤ unchanged.
  1688.  
  1689.      Chapte≥á ┤á oµ thσ SYSLI┬ Use≥ anΣ Referencσ Manualô give≤á ß ì
  1690. little more detail, including the error code information.
  1691.  
  1692.  
  1693. 4.04 File Control Block (FCB) Manipulation
  1694.  
  1695.      SYSLIB provides two simple routines for FCB manipulation.
  1696.  
  1697.      Thσ ke∙ field≤ wσ arσ interesteΣ iε aε FC┬ arσ thσ filσ namσ ì
  1698. anΣ filσ typσ fields«á  Thσ FC┬ useΣ b∙ SYSLI┬ i≤ alway≤ 3╢ byte≤ ì
  1699. long¼ anΣ i⌠ typicall∙ declareΣ witΦ thσ followinτ code:
  1700.  
  1701.           FCB: DB   0              ; Zero Disk Number
  1702.                DB   'FILENAMETYP'  ; File Name and Type
  1703.                DS   4              ; Rest of first 16 bytes
  1704.                DS   16             ; Second 16 bytes
  1705.                DS   4              ; Last required by SYSLIB
  1706.  
  1707.      Thσ firs⌠ i≤ INITFCB«  Thi≤ routinσ simpl∙ clear≤ al∞ oµ thσ ì
  1708. field≤ (excep⌠ thσ filσ namσ anΣ filσ typσ fields⌐ oµ thσ 36-bytσ ì
  1709. FC┬ pointeΣ t∩ b∙ D┼ t∩ zero«á  I⌠ i≤ ß nice¼á quicδ wa∙ t∩ initì
  1710. ializσ aε FC┬ fully.
  1711.  
  1712.      Notσá tha⌠ i⌠ clear≤ thσ disδ numbe≥ fielΣ (thσ firs⌠ field⌐ ì
  1713. a≤ well¼ thereb∙ selectinτ thσ curren⌠ disk«  I⌠ i≤ intendeΣ tha⌠ ì
  1714. thσá use≥ manuall∙ selec⌠ thσ disδ himselµ rathe≥á thaεá allowinτ ì
  1715. thσ BDO╙ t∩ auto-selec⌠ ß disk.
  1716.  
  1717.      Thσ seconΣ SYSLI┬ routinσ discusseΣ herσ i≤ FNAME«á  Thi≤ i≤ ì
  1718. ß filσ namσ strinτ parser¼ anΣ i⌠ build≤ aε FC┬ anΣ extract≤ use≥ ì
  1719. anΣá disδ informatioε froφ ß grou≡ oµ character≤ terminateΣ b∙á ß ì
  1720. delimiter«  Oε input¼ H╠ point≤ t∩ thσ firs⌠ bytσ oµ thσ grou≡ oµ ì
  1721. character≤á anΣ D┼ point≤ t∩ thσ FCB«á  Oε output¼á thσ followinτ ì
  1722. regster values are returned:
  1723.  
  1724.           B  = Number of Disk Specified (A=1 to P=16 or 0FFH if
  1725.                no disk specified)
  1726.           C  = User Number Specified (0 to 31, '?' if all users,
  1727.                or 0FFH if no user specified)
  1728.           HL = address of delimiter which ended the scan
  1729.           A  = error flag; A=0 and Zero Flag Set if invalid disk
  1730.                or user number specifiedè     Scanninτá vißá FNAM┼ i≤ stoppeΣ wheε ß delimite≥ i≤á encounì
  1731. tered«  Thσ followinτ arσ classifieΣ b∙ SYSLI┬ a≤ delimiters:
  1732.  
  1733.           <NULL or Binary 0>       <Space Character>
  1734.           =    _    ;    ,    <    >
  1735.  
  1736.      Thσ grou≡ oµ character≤ i≤ intendeΣ t∩ bσ ß filσá specificaì
  1737. tion¼ simila≥ t∩ thσ CP/═ standard«  I⌠ i≤ oµ thσ genera∞ form:
  1738.  
  1739.           du:filename.typ
  1740.  
  1741. wherσá d=disδ letter¼á u=use≥ number¼á anΣ thσ res⌠ i≤á standard«  ì
  1742. ValiΣá disδ letter≤ arσ A-P¼á anΣ valiΣ use≥ number≤ arσ 0-3▒ anΣ ì
  1743. the '?' character.
  1744.  
  1745.      Thσá FC┬ i≤ initializeΣ b∙ thi≤ routine¼á anΣ onl∙ thσá filσ ì
  1746. namσá anΣ filσ typσ field≤ arσ se⌠ (t∩ thσ filename.ty≡ part≤á oµ ì
  1747. thσá string)«á  Al∞ lowe≥ casσ character≤ arσ converteΣ t∩á uppe≥ ì
  1748. case.
  1749.  
  1750.      Examples of valid character sequences are:
  1751.  
  1752.           Sequence       Returned Values
  1753.           --------       ---------------
  1754.  
  1755.           test.txt       File Name = TEST    File Type = TXT
  1756.                          B Reg = 0FFH        C Reg = 0FFH
  1757.  
  1758.           a:t            File Name = T       File Type = <spaces>
  1759.                          B Reg = 1           C Reg = 0FFH
  1760.  
  1761.           5:.t           File Name = <space> File Type = T
  1762.                          B Reg = 0FFH        C Reg = 5
  1763.  
  1764.           c10:x*.t?t     File Name = X???????  File Type = T?T
  1765.                          B Reg = 3           C Reg = 10
  1766.  
  1767.  
  1768.      FNAM┼á i≤ frequentl∙ useΣ iε processinτ use≥ input«á  ┴ codσ ì
  1769. examplσ is:
  1770.  
  1771.  
  1772.           ...
  1773.           CALL PRINT
  1774.           DB   'Name of File? ',0
  1775.           CALL BBLINE    ; GET NAME OF FILE FROM USER
  1776.           LXI  D,FCB     ; PT TO FCB WITH DE, HL ALREADY PTS TO
  1777.                          ;   FIRST CHAR OF FILE NAME
  1778.           CALL FNAME     ; EXTRACT INFORMATION
  1779.           JZ   FNERR     ; ERROR HANDLER
  1780.           MOV  A,B       ; SAVE DISK NUMBER
  1781.           STA  DISK
  1782.           MOV  A,C       ; SAVE USER NUMBER
  1783.           STA  USER
  1784.           ...
  1785. FCB:      DS   36        ; NO INITIALIZATION NECESSARY FOR FCB
  1786. DISK:     DS   1         ; USER-SPECIFIED DISK NUMBER
  1787. USER:     DS   1         ; USER-SPECIFIED USER NUMBER
  1788.           ...
  1789.  
  1790.  
  1791. 4.05 ZCPR2-Specific Functions
  1792.  
  1793.      ╔ aφ currentl∙ iε thσ throw≤ oµ designinτ ß ne≈ CP/═ compatì
  1794. ablσá CCP-replacemen⌠á calleΣá ZCPR2¼á anΣ thσ desigεá oµá SYSLI┬ ì
  1795. reflect≤ thi≤ t∩ somσ extent«á  SYSLI┬ contain≤ tw∩ module≤ whicΦ ì
  1796. suppor⌠á ZCPR2-specifiπ capabilities¼á anΣ thesσ module≤á contaiε ì
  1797. si° SYSLIB-interna∞ buffe≥ initializatioε routine≤ anΣ si°á ZCPR▓ ì
  1798. utilit∙ routines«  Somσ oµ thσ reader≤ ma∙ bσ familia≥ witΦ ZCPR▒ ì
  1799. (whicΦá i≤á availablσ fo≥ freσ iε Volume≤ 5┤ anΣ 7╖ oµ thσá SIG/═ ì
  1800. User'≤á Group)«á  Afte≥á writinτ ZCPR1¼á ╔ founΣ severa∞á oµá it≤ ì
  1801. feature≤ t∩ bσ lackinτ (especiall∙ afte≥ ╔ gaineΣ somσ experiencσ ì
  1802. usinτ UNIX)«á  ZCPR▓ i≤ ß significan⌠ extensioε t∩ ZCPR1¼á anΣ i⌠ ì
  1803. contain≤ varient≤ oµ severa∞ feature≤ founΣ iε non-CP/═ operatinτ ì
  1804. systems¼ sucΦ a≤ UNIX.
  1805.  
  1806.      Giveεá thσ CP/═ memor∙ map≤ froφ beforσ (thσ reade≥á i≤á inì
  1807. viteΣá t∩á refe≥ bacδ t∩ theφ iµ desired)¼á thσ followinτ i≤á thσ ì
  1808. memor∙ ma≡ fo≥ ß typica∞ ZCPR2-baseΣ systeφ whicΦ support≤ al∞ oµ ì
  1809. thσ extendeΣ features:
  1810.  
  1811.  
  1812.           Comments       Size Memory Map
  1813.  
  1814.      High Memory              ----------------------------
  1815.                            1K | ZCPR2 Buffers, incl      |
  1816.                       (May be |   Multiple Command Line  |
  1817.                        less)  ----------------------------
  1818.                            2K | ZCPR2 BIOS, incl special |
  1819.                               |   Cold Boot Init routines|
  1820.                               ----------------------------
  1821.                          3.5K | CP/M BDOS or other BDOS  |
  1822.                         ->    ----------------------------
  1823.                        /   2K | ZCPR2                    |
  1824.      Normal ZCPR2     /       ----------------------------
  1825.        TPA (when     /   0.5K | ZEX Monitor and Buffer   |
  1826.        ZEX is not    \(Approx)|   Optionally Loaded      |
  1827.        loaded)        \       ----------------------------
  1828.                        \      | COM File Space           |
  1829.                         \     |    TPA when ZEX is       |
  1830.                          \    |        loaded in with    |
  1831.                           \   |        ZCPR2             |
  1832.      Address 100H          -> ----------------------------
  1833.                         0.25K | System Buffers and Entry |
  1834.                               |   Points                 |
  1835.      Address 0H               ----------------------------
  1836.  
  1837.  
  1838.  
  1839.      ╔ wil∞ no⌠ g∩ int∩ ß detaileΣ explanatioε oµ ZCPR2¼ particuì
  1840. larl∙á ZEX¼á a⌠á thi≤ time«á  Extensivσ detail≤ oε ZCPR▓ wil∞á bσ ì
  1841. releaseΣ later.
  1842.  
  1843.      Beforσ expoundinτ oε wha⌠ thσ ZCPR2-orienteΣ SYSLI┬ routine≤ ì
  1844. do¼á i⌠á woulΣá bσ ß gooΣ ideß t∩ explaiε somσá oµá thσá extendeΣ ì
  1845. feature≤á oµ ZCPR▓ whicΦ arσ supporteΣ b∙ thesσ routines«á  Threσ ì
  1846. ZCPR▓ feature≤ arσ supporteΣ iε SYSLIB:
  1847.  
  1848.           1. Multiple Command Lines
  1849.                -- ZCPR▓ caε bσ se⌠ u≡ t∩ allo≈ thσ use≥ t∩ ente≥ 
  1850.                   command lines like the following:
  1851.                     xdir;b3:;a7:display myfile
  1852.                          <-- run XDIR from current user/disk,
  1853.                              log into Disk B/User 3, run DISPLAY
  1854.                              from Disk A/User 7 on MYFILE in B3
  1855.  
  1856.           2. Command Search Paths (File Search Paths)
  1857.                -- wheε ZCPR▓ receive≤ ß command¼ iµ i⌠ determine≤ 
  1858.                   tha⌠ ß commanΣ filσ (CO═ file⌐ i≤ necessar∙ t∩ 
  1859.                   executσ thσ command¼ ZCPR▓ searche≤ alonτ ß 
  1860.                   patΦ fo≥ thσ command¼ movinτ froφ onσ disδ anΣ 
  1861.                   use≥ areß t∩ anothe≥ unti∞ thσ enΣ oµ thσ patΦ 
  1862.                   i≤ reached; example is --
  1863.  
  1864.  
  1865.                     $$ $0 a$ a0    <-- ZCPR2 will look for file
  1866.                                        from current disk/user to
  1867.                                        cur disk/user 0 to disk A
  1868.                                        cur user to disk A/U 0
  1869.  
  1870.  
  1871.           3« NameΣ Directorie≤ (ma∙ bσ implementeΣ oε 
  1872.              conventional CP/M systems as well)
  1873.                -- ZCPR▓ ha≤ thσ addeΣ abilit∙ t∩ suppor⌠ ß 
  1874.                   disk/user║ forφ whereve≥ jus⌠ ß disk║ forφ wa≤ 
  1875.                   permitteΣ before╗ example≤ arσ --
  1876.                     a5:            <-- change to disk A/User 5
  1877.                     b6:cmnd        <-- execute command from B6
  1878.                     type a7:myfile <-- type file in A7
  1879.                     dir c11:       <-- directory of C11
  1880.                     a:             <-- change to disk A/Cur User
  1881.                     5:             <-- change to cur disk/User 5
  1882.                     erß 1:myfilσ   <-- erasσ filσ oε cu≥ disk/╒ 1
  1883.  
  1884.                   Thi≤ i≤ furthe≥ extendeΣ b∙ aε implementatioε 
  1885.                   oµ nameΣ directorie≤ iε CO═ filσ thr⌡ SYSLIB╗ ß 
  1886.                   directory in the ZCPR2 vernacular is a disk and
  1887.                   use≥ areß combination¼ sucΦ a≤ disδ ┴ anΣ use≥ 
  1888.                   5╗ sucΦ directorie≤ caε bσ giveε mnemoniπ 
  1889.                   names¼ sucΦ a≤ JEFF║ o≥ MYWORK:╗ example≤ oµ 
  1890.                   existing ZCPR2 utilities are --
  1891.                     xdi≥ jeff║     <-- XDI╥ oε dir named JEFF
  1892.                     cd mytext:     <-- change dir (log into)
  1893.                                        dir named MYTEXT
  1894.                     mcopy backup:=work:*.txt
  1895.                                    <-- copy *.TXT files from
  1896.                                        WORK: to BACKUP:
  1897.  
  1898.  
  1899.      Beinτ iε lovσ witΦ thσ SYSLI┬ concept¼á ╔ decideΣ t∩ relievσ ì
  1900. somσá oµ thσ tediou≤ ZCPR2-specifiπ codinτ requireΣ t∩á implemen⌠ ì
  1901. o≥á acces≤ thesσ feature≤ froφ thσ programme≥ anΣ placσá i⌠á int∩ ì
  1902. SYSLIB«  Oncσ thσ whee∞ i≤ invented¼ wh∙ d∩ i⌠ again¼ right?
  1903.  
  1904.  
  1905.  
  1906.  
  1907.                   Multiple Commands and SYSLIB
  1908.  
  1909.      Acces≤á t∩á thσá ZCPR▓ multiplσ commanΣ linσá i≤á thσá firs⌠ ì
  1910. featurσ ╔ placeΣ int∩ SYSLI┬ iε thi≤ regard«á  Unde≥á ZCPR2¼á thσ ì
  1911. multiplσ commanΣ linσ featurσ ma∙ bσ engageΣ o≥ disengageΣ a⌠ thσ ì
  1912. systeφ programmer'≤ discretion«  Thσ tradeofµ fo≥ thi≤ featurσ i≤ ì
  1913. that¼á iµ disengaged¼ thσ buffe≥ useΣ t∩ storσ thσ user'≤ commanΣ ì
  1914. linσá i≤ storeΣ interna∞ t∩ ZCPR2¼á anΣ thi≤ prohibit≤ thσ usσ oµ ì
  1915. multiplσá command≤ oε ß singlσ linσ anΣ take≤ u≡á valuablσá spacσ ì
  1916. withiεá ZCPR▓ whicΦ ma∙ bσ useΣ fo≥ othe≥ options«á  Iµá engaged¼ ì
  1917. thσá buffe≥á useΣ t∩ storσ thσ user'≤ commanΣ linσ i≤ storeΣá exì
  1918. ternall∙ t∩ ZCPR2¼á anΣ somσ codσ mus⌠ bσ placeΣ int∩ thσ BIO╙ s∩ ì
  1919. tha⌠ thσ BIOS¼á oε ColΣ Boot¼ wil∞ allocatσ spacσ fo≥ thi≤ buffe≥ ì
  1920. anΣ initializσ it«  Onσ thinτ nicσ abou⌠ thi≤ featurσ i≤ that¼ iε ì
  1921. initializinτ thi≤ buffer¼á ß startu≡ commanΣ line¼á possibl∙ conì
  1922. sistinτ oµ severa∞ commands¼ caε bσ se⌠ t∩ bσ executeΣ wheneve≥ ß ì
  1923. colΣ boo⌠ (systeφ startup⌐ i≤ performed.
  1924.  
  1925.      Tw∩ thing≤ mus⌠ bσ knowε b∙ thσ SYSLI┬ multiplσ commanΣ linσ ì
  1926. routine║á  (1⌐á i≤ thσ multiplσ commanΣ linσ featurσ engageΣá anΣ ì
  1927. (2⌐á wherσá i≤ thσ multiplσ commanΣá linσá buffe≥á located┐á  Thσ ì
  1928. ZINIM├á routinσ initialize≤ (o≥ changes⌐ thσ interna∞ SYSLI┬ bufì
  1929. fe≥á whicΦá contain≤á thσ addres≤ oµ thσá multiplσá commanΣá linσ ì
  1930. buffer«á  Iµá ZINIM├ i≤ called¼á i⌠ assume≤ tha⌠ H╠ contain≤á thσ ì
  1931. addres≤á oµ thi≤ buffe≥ anΣ tell≤ SYSLI┬ tha⌠á multiplσá command≤ ì
  1932. arσá availablσá anΣá wherσ the∙ arσ located«á  Iµ ZINIM├á i≤á no⌠ ì
  1933. called¼ SYSLI┬ assume≤ tha⌠ multiplσ command≤ arσ no⌠ available.
  1934.  
  1935.      Oncσá ZINIM├ ha≤ beeε called¼á thσ SYSLI┬ routinσ ZMCPT╥á i≤ ì
  1936. availablσ t∩ thσ programmer«  Thi≤ routinσ return≤ thσ addres≤ oµ ì
  1937. thσ nex⌠ characte≥ iε thσ multiplσ commanΣ line«á  Thσ programme≥ ì
  1938. caεá theεá reaΣ thσ res⌠ oµ thσ curren⌠á multiplσá commanΣá line¼ ì
  1939. realizinτá tha⌠ eacΦ commanΣ i≤ separateΣ b∙ ß semicoloε (;⌐á anΣ ì
  1940. tha⌠á thσ entirσ linσ i≤ terminateΣ b∙ ß binar∙ 0«á  ZMCPT╥á als∩ ì
  1941. return≤á aε erro≥ codσ iε A¼á iε whicΦ casσ A=░ anΣ thσ Zer∩ Flaτ ì
  1942. i≤ Se⌠ (Z⌐ iµ multiplσ command≤ arσ no⌠ available.
  1943.  
  1944.  
  1945.      To illustrate, if the multiple command line is:
  1946.  
  1947.           myprog p1;myprog p2;myprog p3
  1948.  
  1949. and MYPROG.COM contains the following code:
  1950.  
  1951.           ...
  1952.           LXI  H,MCBASE  ; base adr of MC line
  1953.           CALL ZINIMC    ; init SYSLIB
  1954.           CAL╠ ZMCPT╥    ╗ ge⌠ ad≥ oµ firs⌠ bytσ oµ res⌠ oµ MC
  1955.                          ;   adr returned in HL
  1956.           CALL PRINT
  1957.           DB   'The rest of the command line is -- ',0
  1958.           CALL PSTR      ; print rest of command line, as pted
  1959.                          ;   to by HL and ending in a binary 0
  1960.           ...
  1961.  
  1962. then the command 'myprog p1' will print:
  1963.  
  1964.           The rest of the command line is -- myprog p2;myprog p3
  1965.  
  1966. and the command 'myprog p2' will print:
  1967.  
  1968.           The rest of the command line is -- myprog p3
  1969.  
  1970.  
  1971.  
  1972.                     External Paths and SYSLIB
  1973.  
  1974.      Thσá externa∞á pathô i≤ thσ seconΣá ZCPR▓á featurσá supporteΣ ì
  1975. extensivel∙ b∙ SYSLIB«  Again¼ likσ mos⌠ ZCPR▓ features¼ externa∞ ì
  1976. path≤á ma∙ bσ enableΣ o≥ disableΣ a⌠ thσ discretioε oµ thσ systeφ ì
  1977. programmer«á  Iε orde≥ t∩ understanΣ thσ concep⌠ oµ thσá externa∞ ì
  1978. path¼ thσ concep⌠ oµ thσ SYSLI┬ directoryô mus⌠ bσ understood«  Iε ì
  1979. thσ SYSLI┬ vernacular¼á ß directoryô i≤ ß logica∞ entit∙ oε ß disδ ì
  1980. iε whicΦ file≤ arσ stored«  I⌠ i≤ designateΣ witΦ aε X-┘ coordinì
  1981. ate¼á thσ ╪ coordinatσ beinτ thσ namσ oµ thσ disδ (A¼ B¼ C¼ etc.⌐ ì
  1982. anΣ thσ ┘ coordinatσ beinτ thσ numbe≥ oµ thσ use≥ areß (░ t∩ 31)«  ì
  1983. Unde≥á CP/═á 2.▓ anΣ ZCPR2¼á therσ arσ 3▓ directorie≤ oε eacΦá oµ ì
  1984. you≥á disks¼á anΣá thσ overal∞ director∙ systeφá (NO╘á thσá nameΣ ì
  1985. director∙ system¼ t∩ bσ discusseΣ later⌐ identifie≤ thesσ directì
  1986. orie≤ b∙ thσ form
  1987.  
  1988.           du:
  1989.  
  1990. wherσá 'dºá i≤á ß lette≥ (A-P⌐ anΣ 'uº i≤ ß use≥á numbe≥á (0-31)«  ì
  1991. Examples of directories are:
  1992.  
  1993.           A5:  B7:  A30: C12:
  1994.  
  1995.  
  1996.      Unde≥á CP/═ 2.▓ anΣ ZCPR2¼á distinc⌠ file≤ ma∙ bσ placeΣá iε ì
  1997. eacΦá oµ thσ directorie≤ anΣ bσ handleΣ a≤ uniquσ files¼á regardì
  1998. les≤á oµ thei≥ names«á  Specifically¼á ß filσ nameΣ TEST.TX╘á ma∙ ì
  1999. residσ iε directorie≤ A5:¼ A10:¼ A20:¼ anΣ B3:¼ anΣ therσ wil∞ bσ ì
  2000. fou≥á distinc⌠ file≤ herσ b∙ thσ samσ namσá (TEST.TXT)«á  Editinτ ì
  2001. TEST.TX╘ iε A5║á doe≤ no⌠ changσ thσ content≤ oµ TEST.TX╘ iεá thσ ì
  2002. othe≥á directories«á  Onσ exceptioε t∩ thi≤ rulσá exists¼á namel∙ ì
  2003. tha⌠á whicΦ occur≤ wheε thσ DUPUS╥ prograφ i≤ employed¼á anΣ thi≤ ì
  2004. wil∞ bσ discusseΣ later.
  2005.  
  2006.      Unde≥ CP/═ 2.2¼á thσ utilit∙ oµ thesσ directorie≤ wa≤á someì
  2007. wha⌠á limiteΣá since¼á oncσ thσ use≥ wa≤ loggeΣ int∩ ßá director∙ ì
  2008. likσá A5║á (hσ issueΣ thσ commanΣ 'A:º iµ hσ wa≤ no⌠á alread∙á oε ì
  2009. disδá ┴á anΣ thσ commanΣ 'USE╥ 5')¼á an∙ commanΣ hσ issueΣá whicΦ ì
  2010. requireΣ ß CO═ filσ t∩ executσ i⌠ haΣ t∩ usσ ß CO═ filσ whicΦ wa≤ ì
  2011. eithe≥á iε hi≤ curren⌠ director∙ o≥ oε anothe≥ disδ iεá thσá samσ ì
  2012. use≥á areß (iε whicΦ casσ hσ coulΣ issuσ ß commanΣ likσ "A:PIP")«  ì
  2013. Hence¼á iµ hσ wanteΣ t∩ separatσ hi≤ file≤ int∩ use≥ area≤ 5¼á 6¼ ì
  2014. anΣ ╖ oε disδ A║á anΣ hσ wanteΣ t∩ alway≤ havσ PI╨ available¼á hσ ì
  2015. haΣ t∩ havσ ß cop∙ oµ thσ PIP.CO═ filσ iε al∞ threσ use≥ areas.
  2016.  
  2017.      Problem≤á werσ immediatel∙ recognizeΣ witΦ thi≤á environmen⌠ ì
  2018. unde≥á CP/═ 2.2¼á anΣ ß prograφ calleΣ DUPUS╥ wa≤ releaseΣá whicΦ ì
  2019. createΣá duplicatσ director∙ entrie≤ oµ ß filσ iε differen⌠á use≥ ì
  2020. areas«á  Iε thi≤ way¼ additiona∞ director∙ entrie≤ werσ takeε up¼ ì
  2021. pointinτ t∩ thσ samσ file¼ bu⌠ thσ filσ itselµ diΣ no⌠ havσ t∩ bσ ì
  2022. duplicateΣ iε eacΦ use≥ area«á  Thi≤ wa≤ nice¼á bu⌠ i⌠ addeΣ danì
  2023. gers¼ especiall∙ wheε ß filσ wa≤ changeΣ o≥ deleteΣ froφ onσ use≥ ì
  2024. areß anΣ no⌠ iε al∞ thσ others«á  ZCPR▒ camσ ou⌠ late≥ t∩ relievσ ì
  2025. thi≤ probleφ anΣ eliminatσ thσ neeΣ fo≥ DUPUS╥ t∩ somσ extent.
  2026.  
  2027.      Unde≥ ZCPR1¼á thσ systeφ programmer¼á a⌠ installatioεá time¼ ì
  2028. coulΣ configurσ ZCPR▒ t∩ d∩ ß limiteΣ director∙ searcΦ wheneve≥ ß ì
  2029. CO═á filσ wa≤ t∩ bσ executed«á  Thσ ZCPR▒ defaul⌠ wa≤ t∩ looδ fo≥ ì
  2030. thσ CO═ filσ iε thσ curren⌠ disδ anΣ curren⌠ use≥ area¼á iµá thi≤ ì
  2031. faileΣá t∩ dro≡ dowε t∩ use≥ areß ░ oε thσ curren⌠ disk¼á iµ thi≤ ì
  2032. faileΣá t∩á dro≡á dowε t∩ disδ ┴ anΣ use≥ areßá 0¼á anΣá iµá thi≤ ì
  2033. failed¼ t∩ issuσ thσ standarΣ erro≥ messagσ tha⌠ thσ CO═ filσ wa≤ ì
  2034. no⌠á found«á  DUPUS╥ anΣ it≤ associateΣ danger≤ coulΣ bσá eliminì
  2035. ated¼á anΣá thσá use≥ coulΣ placσ himselµ int∩ an∙ use≥á areßá hσ ì
  2036. desired¼á keepinτá al∞ oµ hi≤ systeφ utilitie≤ oε disδ ┴ iεá use≥ ì
  2037. areßá 0¼á and¼á wheneve≥ hσ woulΣ issuσ ßá command¼á ZCPR▒á woulΣ ì
  2038. searcΦ fo≥ it«á  Thank≤ t∩ sucΦ ß concept¼ ZCPR▒ alloweΣ thσ use≥ ì
  2039. t∩ creatσ ß workinτ environmen⌠ iε which¼á say¼ disδ B║ containeΣ ì
  2040. al∞á oµ hi≤ workinτ file≤ anΣ disδ A:/use≥ ░ containeΣ al∞ oµ hi≤ ì
  2041. CO═ files«á  Hσ coulΣ issuσ an∙ commanΣ froφ an∙ use≥ areß oε B:¼ ì
  2042. sa∙á froφ B5:¼á anΣ ZCPR▒ woulΣ searcΦ fo≥ thσ CO═á file¼á movinτ ì
  2043. froφ B5║ t∩ B0║ t∩ A0:.
  2044.  
  2045.  
  2046.      Thi≤ was¼á iε m∙ opinioε (bu⌠ I'φ prejudice)¼á ß significan⌠ ì
  2047. enhancemen⌠á t∩á thσ CP/═ concept«á  No≈ thσ worδ disδá coulΣá bσ ì
  2048. totall∙á dedicateΣ t∩ worδ file≤ (beinτ devoiΣ oµ commands⌐ whilσ ì
  2049. ßá systeφá disδ coulΣ contaiε al∞ oµ thσá user'≤á commands«á  Thσ ì
  2050. ZCPR▒á capabilit∙ t∩ movσ froφ onσ disk/use≥ areß t∩ anothe≥á wa≤ ì
  2051. nice¼á bu⌠á stil∞á somewha⌠ limited«á  Thσ ZCPR▒ use≥á coulΣá no⌠ ì
  2052. changσá thi≤á commanΣ searcΦ patΦ (ß pathôá being¼á iεá thσá ZCPR▓ ì
  2053. definitions¼ ß vecto≥ oµ directorie≤ alonτ whicΦ ß filσ searcΦ i≤ ì
  2054. performed⌐ t∩ sto≡ a⌠ A10║ insteaΣ oµ A0║ withou⌠ modifyinτ ZCPR▒ ì
  2055. anΣ reinstallinτ it¼ fo≥ instance«  No≥ coulΣ hσ specif∙ ß longe≥ ì
  2056. path¼ sucΦ a≤ ß 4-director∙ search¼ withou⌠ somσ effort.
  2057.  
  2058.      ZCPR▓á significantl∙á extend≤ thσ commanΣ searcΦá patΦá ideß ì
  2059. froφ ZCPR1«  ZCPR▓ support≤ ß patΦ definition¼ whicΦ i≤ containeΣ ì
  2060. iεá ß memor∙ buffer«á  Thσ ZCPR▓ patΦ i≤ ß serie≤ oµ bytσá pairs¼ ì
  2061. thσá firs⌠á bytσ indicatinτ thσ disδ numbe≥ anΣ thσá seconΣá bytσ ì
  2062. indicatinτá thσ use≥ number¼á whicΦ ma∙ bσ oµ an∙ lengtΦá anΣá i≤ ì
  2063. terminateΣ b∙ ß binar∙ 0«á  Internally¼ thσ patΦ ma∙ bσ storeΣ a≤ ì
  2064. ß par⌠ oµ ZCPR▓ itself¼ takinτ u≡ spacσ withiε ZCPR2¼ o≥ externa∞ ì
  2065. t∩á ZCPR2¼á iε ß buffe≥ iε lo≈ memor∙ (belo≈ 100H¼á sucΦ a≤á 40H¼ ì
  2066. whicΦ ╔ use⌐ o≥ iε higΦ memor∙ (abovσ thσ BIOS¼á whicΦ i≤ wherσ ╔ ì
  2067. currentl∙ placσ m∙ multiplσ commanΣ linσ buffer).
  2068.  
  2069.      Iµ thσ patΦ i≤ storeΣ interna∞ t∩ ZCPR2¼ i⌠ canno⌠ typicall∙ ì
  2070. bσá changeΣ b∙ thσ programme≥ iε hi≤ utilities«á  Iµ thσ patΦá i≤ ì
  2071. externa∞á t∩ ZCPR▓ iε ß precisely-defineΣ locatioε (knowε b∙á thσ ì
  2072. systeφá programmer)¼á theεá ß programme≥ ma∙ writσá utilitie≤á t∩ ì
  2073. changσá thi≤á patΦá a⌠ will¼á addinτ TON╙ oµ flexibilit∙á t∩á thσ ì
  2074. system!á  ZCPR2¼á wheεá i⌠ i≤ released¼á wil∞ includσá ßá commanΣ ì
  2075. calleΣ PAT╚ iε it≤ distribution¼ anΣ thi≤ commanΣ allow≤ thσ use≥ ì
  2076. t∩ changσ hi≤ ZCPR▓ patΦ a⌠ wil∞ t∩ anythinτ hσ desires.
  2077.  
  2078.      EacΦá director∙á specifieΣ iε thσ patΦ i≤ representeΣá b∙á ß ì
  2079. bytσ pair«  Thσ firs⌠ bytσ i≤ thσ disδ number¼ anΣ i⌠ ma∙ takσ oε ì
  2080. value≤ froφ ▒ t∩ 1╢ (binary⌐ t∩ represen⌠ disk≤ A║á t∩ P:¼á o≥ i⌠ ì
  2081. ma∙á takσ oε thσ valuσ oµ thσ characte≥ '$º (24H)¼á whicΦá stand≤ ì
  2082. fo≥á thσ curren⌠ disδ (thσ disδ thσ use≥ i≤á loggeΣá into)«á  Thσ ì
  2083. seconΣ bytσ i≤ thσ use≥ number¼á anΣ i⌠ ma∙ takσ oε value≤ froφ ░ ì
  2084. t∩ 3▒ (binary⌐ t∩ presen⌠ user≤ ░ t∩ 31«á  Thσ patΦ i≤ terminateΣ ì
  2085. b∙ ß binar∙ ░ (whicΦ woulΣ bσ iε thσ placσ oµ ß disδ number¼á anΣ ì
  2086. ░ i≤ aε invaliΣ disδ number).
  2087.  
  2088.      A path, stored in memory, could look like this:
  2089.  
  2090.           01H 24H    24H 00H    01H 00H   00H
  2091.              \          \          \       \__ End of Path
  2092.               \          \          \
  2093.                \          \          \__ Disk A/User 0
  2094.                 \          \
  2095.                  \          \__ Current Disk/User 0
  2096.                   \
  2097.                    \__ Disk A/Current User
  2098.  
  2099.  
  2100.      Iεá designinτá thσá PAT╚á commanΣá oµá ZCPR2¼á ╔á havσá als∩ ì
  2101. establisheΣá ßá standarΣ wa∙ t∩ represen⌠ ß ZCPR▓ patΦá iεá text«  ì
  2102. Thσ following¼ fo≥ example¼ i≤ ß PAT╚ commanΣ whicΦ ma∙ bσ issueΣ ì
  2103. by the user to set the path in the example above:
  2104.  
  2105.           PATH A$ $0 A0
  2106.  
  2107.      Thσá PAT╚ commanΣ wil∞ bσ discusseΣ agaiε wheε ╔ cove≥ nameΣ ì
  2108. directories.
  2109.  
  2110.      Gettinτá bacδ t∩ path≤ anΣ SYSLIB¼á tw∩ SYSLI┬ utilitie≤ arσ ì
  2111. provideΣá whicΦá arσá designeΣ t∩ specificall∙á dea∞á witΦá ZCPR▓ ì
  2112. paths«  Thesσ utilitie≤ are:
  2113.  
  2114.           ∩ ZINIEX╘ -- tel∞ SYSLI┬ thσ basσ addres≤ (addres≤ oµ 
  2115.                the first byte) of the ZCPR2 path to be used;
  2116.                note that this may be the address of any path,
  2117.                and not necessarily that of the ZCPR2 system,
  2118.                so many paths may be used by different programs
  2119.                under ZCPR2 (such as having a path for HELP
  2120.                commands and another path to access special
  2121.                programs)
  2122.  
  2123.                ZINIEXT expects the base address of a path to
  2124.                be passed to it in HL; if ZINIEXT is not called,
  2125.                the SYSLIB routines assume that there is no path
  2126.                and just check the current disk/current user when
  2127.                called
  2128.  
  2129.           o ZPFIND -- search for a file along the current path
  2130.                whose base was identified by a call to ZINIEXT
  2131.                for the file whose FCB is pointed to by DE;
  2132.                B is a flag, and if B=0, search just the path,
  2133.                while if B<>0, search the current disk/user
  2134.                first and then follow the path
  2135.  
  2136.                ZPFIND returns with the Zero Flag Clear (NZ)
  2137.                and A=0FFH if the file is found, and the
  2138.                disk number of the file in B (B=0 for disk A)
  2139.                and the user number of the file in C (0-31) if
  2140.                the file is found
  2141.  
  2142.                ZPFIND leaves the user logged into the directory
  2143.                he was in originally before the path search began
  2144.  
  2145.  
  2146.  
  2147.      T∩ makσ lifσ eveε easie≥ fo≥ thσ SYSLI┬á programmer¼á SYSLI┬ ì
  2148. provide≤á fou≥á routine≤ whicΦ manipulatσ use≥ anΣ disδ area≤á s∩ ì
  2149. tha⌠á thσá programme≥ caε movσ betweeεá theφá witΦá ease«á  Thesσ ì
  2150. routines are:
  2151.  
  2152.           o PUTUD -- save the current disk/current user away in
  2153.                      an internal SYSLIB buffer; PUTUD affects
  2154.                      no registers
  2155.  
  2156.           o GETUD -- read the contents of the internal SYSLIB
  2157.                      buffer used by PUTUD and log the user into
  2158.                      his original disk/user; GETUD affects no
  2159.                      registers
  2160.  
  2161.           o LOGUD -- log the user into the disk/user specified
  2162.                      by BC; B is the disk number (B=0 for disk
  2163.                      A) and C is the user number (0-31); no
  2164.                      registers are affected by LOGUD
  2165.  
  2166.           o RETUD -- return the current user/disk numbers;
  2167.                      RETUD requires no inputs, and returns B with
  2168.                      the current disk (B=0 for disk A) and
  2169.                      C with the current user (0-31)
  2170.  
  2171.  
  2172.      Notσá tha⌠ thesσ routine≤ mesΦ iε nicel∙ witΦ ZPFIND¼á whicΦ ì
  2173. return≤á disδ numbe≥ iε ┬ (B=░ fo≥ disδ A⌐ anΣ use≥ numbe≥ iεá C«  ì
  2174. Thσ followinτ codσ illustrate≤ ho≈ thσ SYSLI┬ programme≥ ma∙á usσ ì
  2175. these routines to his advantage:
  2176.  
  2177.  
  2178.           ...
  2179.           LXI  H,MYPATH  ; Set ZCPR2 Path Base Address
  2180.           CALL ZINIEXT
  2181.           ...
  2182.           LXI  D,MYFCB   ; Find the desired file
  2183.           CALL INITFCB   ; Init FCB
  2184.           MVI  B,0FFH    ; Search current disk/user first
  2185.           CALL ZPFIND    ; Search along path
  2186.           JZ   FNF       ; Routine to execute if file not found
  2187. ;
  2188. ;  At this point, B=disk number and C=user number in which
  2189. ;  file was found
  2190. ;
  2191.           CALL PUTUD     ; Save current directory
  2192.           CALL LOGUD     ; Go to file's directory
  2193.           < Work With File -- Detail Left Out >
  2194.           CALL GETUD     ; Return to original directory
  2195.           ...
  2196. FNF:      ...            ; Routine to process if file not found
  2197.           ...
  2198. ;
  2199. ;  Path used by ZPFIND
  2200. ;
  2201. MYPATH:   DB   '$',0     ; Current disk/user 0
  2202.           DB   1,'$'     ; Disk A/current user
  2203.           DB   1,0       ; Disk A/user 0
  2204.           DB   0         ; End of path
  2205. ;
  2206. ;  FCB for desired file
  2207. ;
  2208. MYFCB:
  2209.           DB   0
  2210.           DB   'MYFILE TXT'
  2211.           DS   4
  2212.           DS   16
  2213.           DS   4         ; 36 bytes long
  2214.  
  2215.  
  2216.      Beforσá wσ leavσ thi≤ subject¼á let'≤ hi⌠ jus⌠ ß couplσ morσ ì
  2217. oµá thσ ZCPR2-specifiπ routine≤ iε SYSLI┬ whicΦ ma∙ bσ usefu∞á t∩ ì
  2218. the programmer:
  2219.  
  2220.           o ZINICI -- this initializes the character used to
  2221.                       indicate the Current User or Disk to ZCPR2;
  2222.                       if not called, the ZCPR2 default of '$' is
  2223.                       selected
  2224.  
  2225.           o ZINIDMA -- this initializes the DMA address for Disk
  2226.                        I/O of the ZCPR2 utilities; if not called,
  2227.                        the ZCPR2 default of 80H is selected
  2228.  
  2229.  
  2230.  
  2231.           o ZCPRQ -- this returns a pointer to a set of buffers
  2232.                      which contain the following information:
  2233.                          Bytes     Contents
  2234.                            0       Multiple Command Buffer
  2235.                                    Available Flag; 0=no buffer
  2236.                           1-2      Multiple Command Buffer
  2237.                                    Address, if available
  2238.                           3-4      Address of External Path
  2239.                                    (pts to empty path if not
  2240.                                    initialized)
  2241.                            5       Current User/Disk Indicator
  2242.                           6-7      DMA Address
  2243.  
  2244.           o ZCPRQ2 -- this returns a pointer to a set of buffers
  2245.                       in the 2nd ZCPR2 module of SYSLIB:
  2246.                          Bytes     Contents
  2247.                            ░       Ma° Numbe≥ oµ NameΣ Dirs
  2248.                           1-2      Address of Memory-Resident
  2249.                                    Named Directory Buffer
  2250.                           3-38     FCB for NAMES.DIR file
  2251.  
  2252.           o ZFSTAT -- this returns the attributes of the file
  2253.                       whose FCB is pointed to by DE; ZFSTAT
  2254.                       returns the following information:
  2255.                          B = System Flag (B=0 means Not Sys)
  2256.                          C = R/O Flag (C=0 means Not R/O)
  2257.                          A = File Found Flag (A=0 and Z mean
  2258.                               file NOT found, so BC invalid)
  2259.  
  2260.  
  2261.           o ZGPINS -- General Purpose Installation; with all of
  2262.                       these initializations to perform, I rapidly
  2263.                       became tired of coding up an installation
  2264.                       for SYSLIB as I wrote each ZCPR2 utility
  2265.                       program.  Hence, I added one more init
  2266.                       utility to SYSLIB -- ZGPINS.  This utility
  2267.                       assumes the program it resides in has a
  2268.                       set of standard ZCPR2 buffers starting at
  2269.                       location 103H, and it completely inits
  2270.                       SYSLIB based upon the contents of these
  2271.                       buffers.  The exact structure of these
  2272.                       buffers will not be discussed here, but the
  2273.                       filσ SINSFORM.MA├ iε thσ SYSLI┬ distribu-
  2274.                       tion gives this information.
  2275.  
  2276.  
  2277.  
  2278.  
  2279.                   Named Directories and SYSLIB
  2280.  
  2281.      Thσá thirΣá anΣá fina∞ ZCPR2-specifiπ featurσá supporteΣá b∙ ì
  2282. SYSLI┬á i≤á tha⌠ oµ nameΣ directories«á  Reiteratinτá ßá previou≤ ì
  2283. definition¼á ßá directoryô i≤ ß logica∞ entit∙ oε ß disδ iεá whicΦ ì
  2284. file≤ arσ stored«  I⌠ i≤ designateΣ witΦ aε X-┘ coordinate¼ thσ ╪ ì
  2285. coordinatσ beinτ thσ namσ oµ thσ disδ (A¼á B¼á C¼ etc.⌐ anΣ thσ ┘ ì
  2286. coordinatσ beinτ thσ numbe≥ oµ thσ use≥ areß (░ t∩ 31)«  Hence¼ ß ì
  2287. director∙á woulΣ bσ somethinτ likσ disδ A/use≥ ╡ o≥á disδá B/use≥ ì
  2288. 12¼á anΣ i⌠ i≤ designateΣ b∙ thσ forφ "du:ó iε thσ ZCPR▓ vernacuì
  2289. lar:
  2290.  
  2291.           A5:  B12: C31: D0:
  2292.  
  2293.      ┴ nameΣ directoryô unde≥ ZCPR▓ (i⌠ coulΣ als∩ bσá implementeΣ ì
  2294. unde≥á CP/═á 2.▓ fo≥ tha⌠ matter¼á bu⌠ i⌠ make≤ morσ sensσá unde≥ ì
  2295. ZCPR2⌐á i≤ ß director∙ whicΦ ha≤ beeε identifieΣ iε ß nameΣá dirì
  2296. ector∙ filσ (sucΦ filσ calleΣ NAMES.DI╥ iε thσ ZCPR▓á vernacular⌐ ì
  2297. anΣá ha≤ ß mnemoniπ namσ associateΣ witΦ it¼á likσ WOR╦ o≥á JEFF«  ì
  2298. Al∞á oµ thσ ZCPR▓ utilitie≤ arσ designeΣ t∩ suppor⌠ thi≤ feature¼ ì
  2299. anΣ the∙ permi⌠ thσ use≥ t∩ issuσ command≤ like:
  2300.  
  2301.           XDIR WORK:*.TXT
  2302.           MCOPY BACKUP:=*.MAC,BACKUP:=WORK:*.TXT
  2303.           ERASE TEXT:DEMO.TXT,TEMP:DEMO.TMP
  2304.           PROTECT *.COM,ROOT:*.COM RS
  2305.           CD TEXT:
  2306.  
  2307.      Thσ name≤ oµ thσ director∙ arσ storeΣ iε ß file¼á standardl∙ ì
  2308. calleΣ NAMES.DIR¼ whicΦ shoulΣ typicall∙ bσ locateΣ a⌠ thσ bottoφ ì
  2309. oµá thσá commanΣ searcΦ patΦ oµ ZCPR▓ (thσ las⌠á director∙á ZCPR▓ ì
  2310. stop≤ at)«á  Wheε ß ZCPR▓ utilit∙ receive≤ ß commanΣ containinτ ß ì
  2311. director∙ name¼á i⌠ searche≤ alonτ thσ ZCPR▓ patΦ fo≥á NAMES.DIR¼ ì
  2312. load≤á it¼á anΣ trie≤ t∩ matcΦ thσ namσ giveε t∩ thσ name≤ storeΣ ì
  2313. iε thi≤ file«á  Iµ n∩ match¼á i⌠ issue≤ aε error╗á otherwise¼á i⌠ ì
  2314. proceeds.
  2315.  
  2316.      Iεá orde≥á t∩á reducσá thσ overheaΣá oµá searchinτá fo≥á thσ ì
  2317. NAMES.DI╥á file¼á ZCPR▓ ma∙ bσ optionall∙ configureΣ t∩ suppor⌠ ß ì
  2318. memory-residen⌠á nameΣ director∙ buffer«á  Iµ thi≤ i≤á done¼á thσ ì
  2319. content≤ oµ ß nameΣ director∙ filσ (NAMES.DIR⌐ caε bσ loadeΣá anΣ ì
  2320. storeΣ iε memory¼ and¼ oncσ thσ ZCPR▓ utilitie≤ kno≈ thi≤ (b∙ thσ ì
  2321. ZFNINI╘á routine)¼á the∙á wil∞ looδ herσ beforσ goinτ oεá ßá disδ ì
  2322. search«á  Thi≤á dramaticall∙ reduce≤ thσ overheaΣ wheε nameΣ dirì
  2323. ectorie≤ arσ referenced.
  2324.  
  2325.      Thσá ZCPR▓á utilit∙ calleΣ CHDI╥ caε bσ useΣ t∩á creatσá anΣ ì
  2326. edi⌠á ßá NAMES.DI╥ file¼á a≤ wel∞ a≤ movσ froφ onσá director∙á t∩ ì
  2327. another«á  CHDI╥ (CHangσ DIRectory⌐ wil∞ no⌠ bσ discusseΣ iεá an∙ ì
  2328. further detail in this paper.
  2329.  
  2330.  
  2331.      SYSLI┬áá contain≤á fou≥á routine≤á whicΦá dea∞á witΦáá nameΣ ì
  2332. directories.  They are:
  2333.  
  2334.           o ZFNINIT -- Init Named Directory Buffers
  2335.           o ZDNFIND -- Scan for Disk Directory Name
  2336.           o ZDNAME  -- Load All Disk Directory Name Data
  2337.           o ZFNAME  -- Named Directory File Name Scanner
  2338.                          (like FNAME)
  2339.  
  2340.      ZFNINIT is passed four arguments:
  2341.  
  2342.           HL = address of memory-resident named directory buffer
  2343.           DE = address of FCB (36 bytes) containing name of
  2344.                disk directory file (NAMES.DIR)
  2345.           C  = maximum number of names in NAMES.DIR
  2346.           A  = flag which indicates the following:
  2347.                if Bit 7 = 1, pay attention to DE and set buffer
  2348.                if Bit 6 = 1, pay attention to C and set buffer
  2349.                if Bit 5 = 1, pay attention to HL and set buffer
  2350.  
  2351.      Iµ ZFNINI╘ i≤ no⌠ called¼á thσ namσ oµ thσ director∙ filσ i≤ ì
  2352. assumeΣá t∩ bσ NAMES.DIR¼á anΣ i⌠ i≤ assumeΣ t∩ contaiε ß maximuφ ì
  2353. of 64 names.
  2354.  
  2355.      ZDNAM┼á load≤á thσ content≤ oµ thσ NAMES.DI╥ filσá int∩á thσ ì
  2356. memor∙ buffe≥ pointeΣ t∩ b∙ H╠ s∩ tha⌠ thσ programme≥ ma∙á acces≤ ì
  2357. thi≤ informatioε a≤ hσ desires«  EacΦ entr∙ iε thi≤ file¼ a≤ wel∞ ì
  2358. a≤á thσá memory-baseΣ nameΣ director∙ buffer¼á i≤á structureΣá a≤ ì
  2359. follows:
  2360.  
  2361.           Byte 0: Disk Number (Disk A = 0)
  2362.           Byte 1: User Number
  2363.           Bytes 2-9: Directory Name (all caps), 8 chars max,
  2364.                      space fill at end
  2365.  
  2366.      So¼á representinτ ß NAMES.DI╥ filσ iε assembl∙ language¼ onσ ì
  2367. may look like this:
  2368.  
  2369.           DB   0,0            ; disk A/user 0
  2370.           DB   'ROOT    '     ; directory named ROOT:
  2371.           DB   0,1            ; disk A/user 1
  2372.           DB   'MINEWORK'     ; directory named MINEWORK:
  2373.           DB   0,0            ; disk A/user 0
  2374.           DB   0              ; no entry, so ignored
  2375.           DS   7              ; don't care
  2376.           DB   1,0            ; disk B/user 0
  2377.           DB   'DEVELOPE'     ; directory named DEVELOPE:
  2378.           ...
  2379.  
  2380.  
  2381.      ZDNAM┼ compresse≤ thi≤ informatioε somewhat¼á removinτ thosσ ì
  2382. entrie≤ whicΦ arσ empty«  Oε input¼ ZDNAM┼ expect≤ H╠ t∩ poin⌠ t∩ ì
  2383. ßá dynamiπá memor∙á buffe≥ (CODEN─ i≤á gooΣá fo≥á providinτá thi≤ ì
  2384. address).  On output, ZDNAME provides the following:
  2385.  
  2386.           HL = address of first entry in the buffer
  2387.           C  = number of valid entries
  2388.           B  = 0
  2389.           A  = error flag (A=0 and Z if NAMES.DIR not found or
  2390.                               memory overflow)
  2391.  
  2392.      ZDNAM┼á wil∞ d∩ al∞ thσ worδ fo≥ thσ programmer«á  Wheεá inì
  2393. voked¼á i⌠ searche≤ alonτ thσ patΦ fo≥ NAMES.DI╥ (startinτ a⌠ thσ ì
  2394. curren⌠ disk/user)¼á log≤ int∩ thσ director∙ containinτ thσ firs⌠ ì
  2395. NAMES.DI╥ i⌠ finds¼á load≤ thσ buffer¼á processe≤ thσ buffer¼ anΣ ì
  2396. returns¼ leavinτ thσ prograφ loggeΣ int∩ it≤ origina∞ directory.
  2397.  
  2398.      Glancinτá a⌠ thσ SYSLI┬ referencσ manual¼á notσ tha⌠á ZDNAM┼ ì
  2399. use≤ thσ FI3$OPE╬ anΣ F3$GE╘ routines«á  Hence¼á thesσ shoulΣ no⌠ ì
  2400. bσ useΣ b∙ thσ programmer«  Als∩ notσ tha⌠ i⌠ use≤ ZPFIND¼ s∩ thσ ì
  2401. programme≥á shoulΣá initializσá thσá patΦá usinτá ZINIEX╘á beforσ ì
  2402. calling ZDNAME.  A sample code segment using ZDNAME follows:
  2403.  
  2404.           ...
  2405.           LXI  H,MYPATH  ; set ZCPR2 path for SYSLIB
  2406.           CALL ZINIEXT
  2407.           CALL CODEND    ; get beginning of scratch area in HL
  2408.           CALL ZDNAME    ; load memory buffer
  2409.           JZ   NERR      ; process error routine
  2410.           ...
  2411.  
  2412.      Thσ nex⌠ SYSLI┬ routine¼á ZDNFIND¼ i≤ useΣ t∩ quickl∙ deterì
  2413. minσá thσ director∙ referreΣ t∩ b∙ ß strinτ oµ character≤ oµá thσ ì
  2414. forφá "du:ó o≥ "dir:ó (conventiona∞ ZCPR▓ director∙á nomenclaturσ ì
  2415. o≥ ZCPR▓ nameΣ director∙ forφ allowed).
  2416.  
  2417.      ZDNFIND accepts two inputs:
  2418.  
  2419.           HL = address of first byte of DIR: or DU: prefix
  2420.                this prefix may be terminated by a colon (:),
  2421.                space, or binary 0
  2422.           A  = flag; if A=0, ZDNFIND does not permit the DU:
  2423.                form to be used and assumes that only a DIR:
  2424.                form is given and issues an error if it is not
  2425.  
  2426.      ZDNFIND returns these values:
  2427.  
  2428.           HL = address of character which terminated the prefix
  2429.                (usually the address of the colon)
  2430.           B  = disk number (disk A = 1, or 0FFH if current disk)
  2431.           C  = user number (0-31, or 0FFH if current user)
  2432.           Zero Flag Set if error
  2433.  
  2434. è     Again¼á ZDNFIN─ use≤ Bytσ Inpu⌠ Filσ 3¼á s∩ thi≤ filσ shoulΣ ì
  2435. no⌠ bσ activσ wheε ZDNFIN─ i≤ called.
  2436.  
  2437.  
  2438.      Thσ fina∞ nameΣ director∙ routinσ iε SYSLI┬ i≤á ZFNAME«á  I⌠ ì
  2439. i≤á ßá filσá namσá scanner¼á likσ FNAME¼á bu⌠á i⌠á permit≤á nameΣ ì
  2440. directorie≤ t∩ bσ used«  Oε input¼ D┼ point≤ t∩ ß 36-bytσ FC┬ anΣ ì
  2441. H╠á point≤ t∩ thσ firs⌠ bytσ oµ ß strinτ t∩ scan«á  String≤á likσ ì
  2442. this may be evaluated by ZFNAME:
  2443.  
  2444.           HELP:*.HLP          A5:TEST.TXT
  2445.           C?:ABC.*            PASCAL:*.COM
  2446.  
  2447.      Notσ tha⌠ thσ use≥ numbe≥ fielΣ oµ thσ DU║á forφ ma∙ contaiε ì
  2448. ß questioε mark╗á thi≤ indicate≤ al∞ use≥ areas«  Thσ samσ value≤ ì
  2449. arσá returneΣá a≤á witΦ ZDNFIND¼á bu⌠ ├ caε als∩ takσá oεá ßá '?º ì
  2450. character¼á anΣá thσ scaε i≤ terminateΣ b∙ an∙ SYSLI┬á delimiter¼ ì
  2451. including:
  2452.  
  2453.           <Binary 0 or NULL>       <Space>
  2454.           = _ ; , < >
  2455.  
  2456.      An example on the use of ZFNAME:
  2457.  
  2458.           ...
  2459.           LXI  H,MYPATH  ; SET PATH FOR ZPFIND (USED BY ZFNAME)
  2460.           CALL ZINIEXT
  2461.           ...
  2462.           CALL PRINT
  2463.           DB   'Input Your File Name: ',0
  2464.           CALL BBLINE    ; GET LINE FROM USER
  2465.           RZ             ; ABORT IF EMPTY LINE
  2466.                          ╗   H╠ NO╫ POINT╙ T╧ FIRS╘ CHA╥ O╞ LINE
  2467.           LXI  D,FCB     ; PT TO FCB
  2468.           CALL ZFNAME    ; PARSE NAME AND GET DATA
  2469.           JZ   FERR      ; ERROR IF ZERO FLAG SET
  2470. ;
  2471. ;  B IS NOW DISK NUMBER, C IS NOW USER NUMBER, AND HL PTS TO
  2472. ;  TERMINATING CHAR ... PROCESSING MAY NOW CONTINUE AS DESIRED
  2473. ;
  2474.           ...
  2475. FERR:     ...            ; ERROR ROUTINE
  2476.           ...
  2477. MYPATH    EQU  40H       ; ZCPR2 PATH BASE
  2478. FCB:      DS   36        ; SYSLIB FCB
  2479.           ...
  2480.  
  2481. .fo 5 - Numbers, CRC Check, and Sort Routines          Page #
  2482.  
  2483. 5.0 Numeric String Evaluation, CRC Check, and Sort Routines
  2484.  
  2485.      Thσá las⌠ threσ set≤ oµ SYSLI┬ routine≤ whicΦ remaiεá t∩á bσ ì
  2486. discusseΣá dea∞ witΦ evaluatioε oµ ASCI╔ characte≥ string≤á whicΦ ì
  2487. arσ intendeΣ t∩ represen⌠ number≤ (like¼ "110ó fo≥ decima∞ 11░ o≥ ì
  2488. "ABCHóá fo≥á hexadecima∞ ABC)¼á performinτ erro≥á checkinτá usinτ ì
  2489. Cycliπá Redundanc∙ Checδ algorithms¼á anΣ thσ SYSLI┬ general-purì
  2490. posσ sor⌠ routines.
  2491.  
  2492.  
  2493. 5.01 Numeric String Evaluation
  2494.  
  2495.      Recognizinτá tha⌠ i⌠ wil∞ bσ occasionall∙ necessar∙ fo≥á thσ ì
  2496. programme≥ t∩ bσ ablσ t∩ accep⌠ ß numbe≥ a≤ typeΣ iε b∙ thσá use≥ ì
  2497. anΣá conver⌠ i⌠ t∩ ß binar∙ forφ tha⌠ caε bσ useΣ b∙ thσ codσá oµ ì
  2498. thσá program¼á ╔ havσ provideΣ SYSLI┬ witΦ ß serie≤ oµ ╡ routine≤ ì
  2499. which perform such conversions.  These routines are:
  2500.  
  2501.           o EVAL2  -- convert binary digit strings to binary
  2502.           o EVAL8  -- convert octal digit strings to binary
  2503.           o EVAL10 -- convert decimal digit strings to binary
  2504.           o EVAL16 -- convert hexadecimal digit strings to binary
  2505.           o EVAL   -- determine base employed by user based on
  2506.                         an optional suffix character and convert
  2507.  
  2508.      Iεá al∞á cases¼á thσ addres≤ oµ thσ firs⌠ characte≥á oµá thσ ì
  2509. strinτ i≤ passeΣ t∩ thσ routinσ iε thσ H╠ registe≥ pair¼á anΣ thσ ì
  2510. routinσá return≤á ß 16-bi⌠ valuσ iε D┼ anΣ aε 8-bi⌠á valuσá iεá ┴ ì
  2511. (A=E)«á  Evaluatioε oµ thσ strinτ progresse≤ froφ thσ firs⌠ charì
  2512. acte≥á unti∞á aε invaliΣ digi⌠ (fo≥ thσ appropriatσ base⌐ i≤á enì
  2513. countered¼á anΣ thσ routinσ return≤ H╠ pointinτ t∩ thσá characte≥ ì
  2514. whicΦ terminateΣ thσ scan.
  2515.  
  2516.      EVAL▓á evaluate≤ binar∙ characte≥ string≤ (onl∙ '0º anΣá '1º ì
  2517. arσá thσá valiΣ digits)«á  String≤ likσ "1010ó arσ evaluateΣá anΣ ì
  2518. converteΣ t∩ binary«á  Giveε ß strinτ likσ "1010B"¼á thσá routinσ ì
  2519. wil∞á sto≡ wheε i⌠ encounter≤ thσ "Bó anΣ returε witΦ H╠ pointinτ ì
  2520. to this character.
  2521.  
  2522.      EVAL╕ evaluate≤ octa∞ characte≥ string≤ (onl∙ '0º t∩ '7º arσ ì
  2523. thσá valiΣ digits)«á  EVAL1░ evaluate≤ decima∞ characte≥á string≤ ì
  2524. (onl∙á '0ºá t∩ '9º arσ thσ digits)¼á anΣ EVAL1╢á evaluate≤á hexaì
  2525. decima∞ characte≥ string≤ (onl∙ '0º t∩ '9º anΣ 'Aº t∩ 'Fº arσ thσ ì
  2526. digits¼ anΣ casσ i≤ no⌠ significan⌠ witΦ thσ letters).
  2527.  
  2528.      EVA╠á i≤ thσ grandadd∙ oµ thσ group¼á anΣ i⌠ accept≤ string≤ ì
  2529. of the following forms:
  2530.  
  2531.           bbbbbbbbbbbbbbbbB -- b='0' or '1'; Binary string
  2532.           oooooooO or oooooooQ -- '0' <= o <= '7'; Octal string
  2533.           ttttt or tttttD -- '0' <= t <= '9'; Decimal string
  2534.           hhhhH or hhhhX -- '0' <= h <= 'F'; Hexadecimal string
  2535.  
  2536.  
  2537.      EVA╠ determine≤ thσ typσ oµ strinτ useΣ anΣ call≤ thσ approì
  2538. priatσ routinσ t∩ perforφ thσ conversion«  EVA╠ return≤ onσ othe≥ ì
  2539. flaτ thaε thσ others╗ Carr∙ Flaτ Se⌠ mean≤ tha⌠ aε invaliΣ strinτ ì
  2540. forma⌠á wa≤á given¼á anΣ H╠ point≤ t∩ thσ offendinτ characte≥á oε ì
  2541. exit.
  2542.  
  2543.      Thσ followinτ i≤ aε examplσ oµ ß codσ segmen⌠ whicΦá accept≤ ì
  2544. two numbers input by the user and adds them together:
  2545.  
  2546.           ...
  2547.           EXT  PRINT     ; USE SYSLIB PRINT STRING ROUTINE
  2548.           EXT  BBLINE    ; USE SYSLIB INPUT LINE EDITOR
  2549.           EXT  PHLDC     ; USE SYSLIB PRINT HL AS DEC ROUTINE
  2550.           EXT  CRLF      ; USE SYSLIB NEW LINE ROUTINE
  2551.           EXT  EVAL      ; USE SYSLIB EVAL ROUTINE
  2552.           ...
  2553.           CALL PRINT     ; PROMT USER
  2554.           DB   'Input Your Numbers, Separated by a Comma: ',0
  2555.           CALL BBLINE    ; GET LINE FROM USER
  2556.                          ;  HL POINTS TO FIRST ARGUMENT
  2557.           CALL EVAL      ; EXTRACT FIRST ARGUMENT
  2558.           JC   NUMERR    ; ERROR IF CARRY SET
  2559.           PUSH D         ; SAVE FIRST NUMBER ON STACK
  2560.           MOV  A,M       ; GET OFFENDING CHARACTER
  2561.           CPI  ','       ; ERROR IF IT IS NOT A COMMA
  2562.           JNZ  CERR
  2563.           INX  H         ; SKIP OVER THE COMMA
  2564.           CALL EVAL      ; GET THE 2ND NUMBER IN DE
  2565.           JC   NUMERR    ; PROCESS ERROR
  2566.           POP  H         ; GET FIRST NUMBER FROM STACK
  2567.           CALL CRLF      ; NEW LINE
  2568.           DAD  D         ; HL=HL+DE
  2569.           CALL PRINT
  2570.           DB   'The sum of these numbers is ',0
  2571.           CALL PHLDC     ; PRINT AS DECIMAL
  2572.           ...
  2573.  
  2574.  
  2575.      A≤á thσ reade≥ caε see¼á thσ EVA╠ famil∙ oµá routine≤á make≤ ì
  2576. numeriπ inpu⌠ conversioε reall∙ easy.
  2577.  
  2578.  
  2579.  
  2580. 5.02 Cyclic Redundancy Checking
  2581.  
  2582.      Thσ SYSLI┬ CR├ routine≤ ma∙ bσ useΣ t∩ checδ thσ validit∙ oµ ì
  2583. aεá incominτ seria∞ bytσ streaφ oµ arbitrar∙á length«á  The∙á arσ ì
  2584. particularl∙ gooΣ iε makinτ surσ tha⌠ ß giveε filσ contain≤ valiΣ ì
  2585. datß o≥ tha⌠ datß transmitteΣ viß thσ phonσ line≤ (a≤ pe≥ ß modeφ ì
  2586. program⌐á wa≤á correctl∙ received«á  Thesσ routine≤á computσá anΣ ì
  2587. checδá ß truσ 16-bi⌠ Cycliπ Redundanc∙ Codσ (CRC)¼á anΣ thei≥ usσ ì
  2588. will guarantee the detection of:
  2589.  
  2590.           o all single- and double-bit errors
  2591.           o all errors with an odd number of error bits
  2592.           o all burst errors of length 16 or less
  2593.  
  2594. Also, the CRC routines will detect the following:
  2595.  
  2596.           o 99.9969% of all 17-bit error bursts
  2597.           o 99.9984% of all possible longer error bursts
  2598.  
  2599.      Three sets of CRC routines are provided.  They are:
  2600.  
  2601.           CRC       CRC1        CRC2    Function
  2602.           CRCCLR    CRC1CLR   CRC2CLR   Clear CRC Accumulator
  2603.           CRCUPD    CRC1UPD   CRC2UPD   Update CRC Accumulator
  2604.           CRCDONE   CRC1DONE  CRC2DONE  Done and Return CRC Value
  2605.  
  2606.      The polynomials used by these routines are:
  2607.           CRC  = X^16 + X^12 + X^5 + 1
  2608.           CRC1 = X^16 + X^15 + X^2 + 1
  2609.           CRC2 = X^16 + X^15 + X^13 + X^7 + X^4 + X^2 + X + 1
  2610.  
  2611.      Thσá SYSLI┬á programme≥ neeΣ no⌠ bσ concerneΣ witΦ ho≈á thi≤ ì
  2612. polynomia∞ i≤ applieΣ internall∙ ..«á jus⌠ tha⌠ i⌠ doe≤ it≤á job«  ì
  2613. Thσ interesteΣ reade≥ i≤ inviteΣ t∩ examinσ thσ sourcσ code«á  A≤ ì
  2614. ßá sidσ note¼á CRC▓ i≤ useΣ b∙ thσ publiπ domaiε CRC╦ prograφá oµ ì
  2615. KeitΦ Petersen.
  2616.  
  2617.      Thσá CRCCL╥ routinσ require≤ n∩ argument≤ anΣ return≤á none«  ì
  2618. It has no effect on any register.
  2619.  
  2620.      Thσá CRCUP─á routinσá update≤ thσ CR├ Accumulato≥á witΦá thσ ì
  2621. valuσ oµ thσ nex⌠ byte¼á whicΦ i≤ passeΣ t∩ i⌠ iε thσ ┴ register«  ì
  2622. No registers are affected by this routine.
  2623.  
  2624.      Thσá CRCDON┼ routinσ return≤ thσ calculateΣ 16-bi⌠ CR├ valuσ ì
  2625. iεá thσ H╠ registe≥ pair«á  I⌠ simpl∙ return≤ ß valuσ anΣ ma∙á bσ ì
  2626. called as many times as desired.
  2627.  
  2628.  
  2629.  
  2630.      Thσ followinτ codσ segmen⌠ illustrate≤ ß typica∞ wa∙ t∩á usσ ì
  2631. these routines:
  2632.  
  2633.           ...
  2634.           EXT  CRCCLR    ; CLEAR CRC
  2635.           EXT  CRCUPD    ; UPDATE CRC
  2636.           EXT  CRCDONE   ; RETURN CRC
  2637.           EXT  COMPHD    ; COMPARE HL TO DE AND RET W/Z IF EQUAL
  2638.           ...
  2639. ;
  2640. ;  ROUTINE TO COMPUTE TRANSMITTED CRC
  2641. ;
  2642. CRC$MAKE:
  2643.           CALL CRCCLR    ; CLEAR ACCUMULATOR
  2644.           < Loop CALLing CRCUPD with Byte Values in A >
  2645.           CALL CRCDONE   ; GET VALUE
  2646.           PUSH H         ; SAVE IT
  2647.           ...
  2648. ;
  2649. ;  ROUTINE TO EVALUATE INCOMING DATA FOR VALID CRC
  2650. ;
  2651. CRC$CHECK:
  2652.           CALL CRCCLR    ; CLEAR ACCUMULATOR
  2653.           < Loop CALLing CRCUPD with Byte Values in A >
  2654.           CALL CRCDONE   ; GET CRC VALUE IN HL
  2655.           POP  D         ; GET FIRST CRC VALUE IN DE
  2656.           CALL COMPHD    ; COMPARE HL TO DE
  2657.           JZ   OK        ; PROCESS IF OK
  2658. ;
  2659. ;  THE ERROR ROUTINE GOES HERE
  2660. ;
  2661.           ...
  2662.  
  2663.  
  2664.  
  2665. 5.03 The SYSLIB Sort Routines
  2666.  
  2667.      Therσáá arσá tw∩á SYSLI┬á routine≤á whicΦá givσá thσá SYSLI┬ ì
  2668. programme≥á acces≤ t∩ ß ver∙ flexiblσ sortinτ system«á  Thσá maiε ì
  2669. routinσ i≤ calleΣ SORT¼á anΣ i⌠ provide≤ ß utilit∙ whicΦ doe≤á aε ì
  2670. in-memor∙á sor⌠á oµ ß se⌠ oµ fixed-lengtΦ records«á  Thσá sortinτ ì
  2671. techniquσá useΣ i≤ ß Shel∞ Sort¼á adapteΣ froφ thσ booδá Softwarσ ì
  2672. Toolsô b∙ Kernigaε anΣ Plaugher¼ publisheΣ b∙ Addison-Wesly¼ 1976¼ ì
  2673. page 106.  This sort is much faster than the simple bubble sort.
  2674.  
  2675.  
  2676.      Thσ SOR╘ routinσ caε bσ instructeΣ t∩ perforφ thσá in-memor∙ ì
  2677. sor⌠á iεá onσá oµá tw∩ way≤ -- witΦ o≥á withou⌠á usinτá pointers«  ì
  2678. Sortinτá withou⌠ usinτ pointer≤ i≤ typicall∙ slowe≥ thaεá sortinτ ì
  2679. witΦ pointers¼ mainl∙ becausσ wheε usinτ pointers¼ ß swa≡ i≤ donσ ì
  2680. b∙á simpl∙á exchanginτ pointer≤ (▓ bytσá values)¼á whilσá ßá sor⌠ ì
  2681. withou⌠á pointer≤á require≤ ß swa≡ t∩ completel∙ exchangσ thσá n-ì
  2682. bytσá record≤á beinτ sorted«á  Thσ onl∙ advantagσá t∩á no⌠á usinτ ì
  2683. pointer≤á i≤á thσá saving≤ oµ thσ spacσ takeε u≡ b∙á thσá pointe≥ ì
  2684. table«  Thi≤ tablσ require≤ 2*(numbe≥ oµ entrie≤ t∩ bσ sorted⌐ iε ì
  2685. bytes.
  2686.  
  2687.      Thσá SOR╘á i≤ controlleΣ b∙ passinτ ß pointe≥á t∩á thσá Sor⌠ ì
  2688. Specificatioεá Blocδ (SSB⌐ iε D┼ t∩ thσ SOR╘ routine«á  Thi≤ Sor⌠ ì
  2689. Specificatioε Blocδ i≤ ß serie≤ oµ si° 2-bytσ word≤ whicΦ contaiε ì
  2690. the following information:
  2691.  
  2692.           Bytes 0&1 -- Starting Address of 1st Record
  2693.           Bytes 2&3 -- Number of Records to Sort
  2694.           Bytes 4&5 -- Size of Each Record (in Bytes)
  2695.           Bytes 6&7 -- Address of Compare Routine Provided
  2696.                          by the Programmer
  2697.           Bytes 8&9 -- Address of a Pointer Table (if needed)
  2698.           Byte 10   -- Flag; 0 means to use pointers, 0FFH not
  2699.           Byte 11   -- Unused
  2700.  
  2701.      Tw∩á routine≤á arσ provideΣ iε thσ SSOR╘ modulσá oµá SYSLIB«  ì
  2702. The∙á arσá SSBINIT¼á whicΦ i≤ useΣ t∩ initializσ buffer≤á anΣá i≤ ì
  2703. describeΣ full∙ iε thσ SYSLI┬ referencσ manual¼á anΣ SORT¼á whicΦ ì
  2704. perform≤ thσ actua∞ sort«á  ╔ wil∞ no⌠ cove≥ SSBINI╘ herσ ..« thσ ì
  2705. interested reader is invited to read the reference manual.
  2706.  
  2707.      SOR╘ accept≤ a≤ inpu⌠ ß pointe≥ t∩ aε SS┬ iε D┼ anΣ perform≤ ì
  2708. thσ sort«  N∩ error≤ arσ generated¼ anΣ n∩ register≤ arσ affecteΣ ì
  2709. by SORT.  An example of a code sequence using SORT follows:
  2710.  
  2711.           ...
  2712.           EXT  SORT      ; SORT ROUTINE IN SYSLIB
  2713.           ...
  2714.           CALL CODEND    ; GET ADDRESS OF SCRATCH AREA FOR PTRS
  2715.           SHLD SSBPTR    ; SET ADDRESS IN SSB
  2716.           LXI  D,SSB     ; POINT TO SSB
  2717.           CALL SORT      ; DO THE SORT
  2718.           ...
  2719. ;
  2720. ;  THIS IS THE COMPARE ROUTINE
  2721. ;
  2722. COMPARE:
  2723.           PUSH H         ; ONLY PSW MAY BE AFFECTED
  2724.           PUSH D
  2725.           PUSH B
  2726.           MVI  B,RECSIZ  ; SIZE OF RECORDS
  2727. CLOOP:
  2728.           LDAX D         ; COMPARE (DE) TO (HL)
  2729.           CMP  M
  2730.           JNZ  CDONE     ; RETURN WITH CARRY SET IF (DE)<(HL)
  2731.           INX  H         ; PT TO NEXT BYTE
  2732.           INX  D
  2733.           DCR  B         ; COUNT DOWN REQUIRED NUMBER OF BYTES
  2734.           JNZ  CLOOP
  2735. CDONE:
  2736.           POP  B         ; RESTORE REGISTERS
  2737.           POP  D
  2738.           POP  H
  2739.           RET            ; RETURN WITH CARRY SET IF (DE)<(HL)
  2740.                          ;   OR ZERO SET IF (DE)=(HL)
  2741.           ...
  2742. ;
  2743. ;  THE SORT SPECIFICATION BLOCK DEFINES THE SORT PARAMETERS
  2744. ;
  2745. SSB:
  2746.           DW   REC1      ; ADDRESS OF FIRST RECORD
  2747.           DW   NREC      ; NUMBER OF RECORDS TO SORT
  2748.           DW   RECSIZ    ; SIZE OF EACH RECORD
  2749.           DW   COMPARE   ; ADDRESS OF COMPARE ROUTINE
  2750. SSBPTR:
  2751.           DS   2         ; ADDRESS OF POINTER TABLE, FILLED IN
  2752.                          ;   ABOVE
  2753.           DB   0,0       ; USE POINTERS
  2754.           ...
  2755. ;
  2756. ;  THE DATA TO SORT
  2757. ;
  2758. REC1:
  2759.           DB   'THIS'    ; 4-BYTE RECORDS
  2760.           DB   'IS  '
  2761.           DB   'A   '
  2762.           DB   'TEST'
  2763. RECSIZ    EQU  4                   ; SIZE OF EACH RECORD
  2764. NREC      EQU  ($-REC1)/RECSIZ     ; NUMBER OF RECORDS
  2765.           ...è.fo 6 - What is SYSLIB?  SYSLIB Overview               Page #
  2766.  
  2767. 6.0 What is SYSLIB?  SYSLIB Overview
  2768.  
  2769.      Froφ thσ beginninτ oµ thi≤ document¼ SYSLI┬ (SYSteφ LIBrary⌐ ì
  2770. wa≤á describeΣ a≤ ß collectioε oµ ove≥ 13░ subroutine≤ whicΦá arσ ì
  2771. designeΣá t∩ providσ t∩ thσ CP/═ 8080/Z8░ assembl∙ languagσá proì
  2772. gramme≥ ß se⌠ oµ function≤ upoε whicΦ hσ caε builΣ hi≤á programs«  ì
  2773. Thi≤ librar∙ i≤ intendeΣ t∩ relievσ thσ programme≥ oµ thσ tasδ oµ ì
  2774. frequentl∙á "reinventinτá thσ wheeló anΣ t∩ providσ hiφá witΦá aε ì
  2775. environmen⌠á oµá reliablσ tool≤ whicΦ encourage≤ structureΣá proì
  2776. gramminτ a⌠ thσ assembl∙ languagσ level.
  2777.  
  2778.      Iε thi≤ document¼ ╔ havσ takeε yo⌡ througΦ al∞ 130½ routine≤ ì
  2779. iεá SYSLIB¼á describinτá theφ iε ß functiona∞á sensσá anΣá givinτ ì
  2780. example≤á a≤ t∩ ho≈ ╔ intendeΣ theφ t∩ bσ useΣ anΣ designeΣá theφ ì
  2781. t∩ worδ together.
  2782.  
  2783.  
  2784.  
  2785. 6.01 Functional Overview of SYSLIB
  2786.  
  2787.      Thσá SYSLI┬ routine≤ arσ groupeΣ int∩ ß numbe≥ oµ functiona∞ ì
  2788. categories.  In a nutshell, these categories are:
  2789.  
  2790.      Directory Manipulation Routines
  2791.           DIRF      DIRFS     DBUFFER   DPARAMS
  2792.           DFREE     FSIZE     DIRLOAD   DIRSLOAD
  2793.           DIRALPHA  DIRSEL    DIRPACK   DIRNPACK
  2794.  
  2795.      Numeric String Evaluation Routines
  2796.           EVAL      EVAL16    EVAL10    EVAL8
  2797.           EVAL2
  2798.  
  2799.      Byte-Oriented File Input/Output Routines (0<=n<=3)
  2800.           FIn$OPEN  FOn$OPEN  FIn$CLOSE FOn$CLOSE
  2801.           Fn$GET    Fn$PUT
  2802.  
  2803.      CP/M File Input/Output Routines
  2804.           F$OPEN    F$MOPEN   F$CLOSE   F$MAKE
  2805.           F$DELETE  F$RENAME  F$EXIST   F$READ
  2806.           F$WRITE
  2807.  
  2808.      File Name String Parser and FCB Initialization
  2809.           FNAME     INITFCB
  2810.  
  2811.      Input Line Editors
  2812.           BBLINE    BLINE     INLINE
  2813.  
  2814.      String Output Routines
  2815.           PRINT     LPRINT    PSTR      LPSTR
  2816.  
  2817.  
  2818.      NumeriπáOutpu⌠ Routine≤
  2819.           PHL4HC    LHL4HC    MHL4HC    PHL5DC
  2820.           LHL5DC    MHL5DC    PHLDC     LHLDC
  2821.           MHLDC     PA2HC     LA2HC     MA2HC
  2822.           PA3DC     LA3DC     MA3DC     PADC
  2823.           LADC      MADC
  2824.  
  2825.      String and Value Comparison Routines
  2826.           COMPHD    COMPB     COMPBC    SCANNER
  2827.           INSTR
  2828.  
  2829.      Character-Oriented Input/Output Routines
  2830.           CRLF      LCRLF     CONDIN    CST
  2831.           CIN       RIN       COUT      LOUT
  2832.           POUT      CCOUT     CLOUT     CPOUT
  2833.  
  2834.      Math Routines
  2835.           ADDHD     SUBHD     MULHD     DIVHD
  2836.           NEGH      CMPH      ROTLH     ROTRH
  2837.           SHFTLH    SHFTRH    ANDHD     ORHD
  2838.           XORHD
  2839.  
  2840.      CRC Routines
  2841.           CRCCLR    CRC1CLR   CRC2CLR
  2842.           CRCUPD    CRC1UPD   CRC2UPD
  2843.           CRCDONE   CRC1DONE  CRC2DONE
  2844.  
  2845.      Random Number Generator Routines
  2846.           RNDINIT   RNDSEED   RND
  2847.  
  2848.      User/Disk Manipulation Routines
  2849.           PUTUD     GETUD     LOGUD     RETUD
  2850.  
  2851.      Sort Routines
  2852.           SSBINIT   SORT
  2853.  
  2854.      ZCPR2 Feature-Specific Routines
  2855.           ZINICI    ZINIDMA   ZINIMC    ZINIEXT
  2856.           ZGPINS    ZCPRQ     ZCPRQ2    ZMCPTR
  2857.           ZPFIND    ZFSTAT
  2858.  
  2859.      ZCPR2-Specific Named Directory Routines
  2860.           ZFNINIT   ZDNAME    ZDNFIND   ZFNAME
  2861.  
  2862.      Misπellaneous Routines
  2863.           BDOS      BIOS      CAPS      CAPSTR
  2864.           CATH      CLINE     CODEND    EN
  2865.           FILLB     FILLBC    HFILB     HFILBC
  2866.           MOVEB     MOVEBC    HMOVB     HMOVBC
  2867.           PAUSE     VERSION
  2868.  
  2869.  
  2870.  
  2871. 6.02 SYSLIB Documentation and Files and SYSLIB Availability
  2872.  
  2873.      SYSLI┬á documentatioε i≤ somewha⌠ extensive¼á consistinτá oµ ì
  2874. (1⌐á ß 112½ pagσ SYSLI┬ Use≥ anΣ Referencσ Manualô whicΦá contain≤ ì
  2875. detail≤á oε al∞ oµ thσ SYSLI┬ routine≤ anΣ ß se⌠ oµ seveεá samplσ ì
  2876. programs¼á completσá witΦ ß samplσ assembl∙ anΣ ruε oµ eacΦá proì
  2877. graφ anΣ (2⌐ ß se⌠ oµ 1│ HEL╨ file≤ whicΦ caε bσ accesseΣá onlinσ ì
  2878. via the HELP program (new release coming out shortly to SIG/M).
  2879.  
  2880.      Thσ origina∞ SYSLIB¼á Versioε 1¼á i≤ currentl∙ availablσá iε ì
  2881. Volumσ 1│ oµ thσ SIG/═ disks«á  Usσ oµ thi≤ versioε i≤ no⌠ recomì
  2882. mendeΣá becausσá thσ versioε describeΣ iε thi≤á documen⌠á greatl∙ ì
  2883. enhance≤á thσá feature≤ oµ thσ origina∞ SYSLI┬ anΣá thσá origina∞ ì
  2884. SYSLI┬ haΣ somσ problem≤ dealinτ witΦ CP/═ 2.2«á  Thσ ne≈ SYSLIB¼ ì
  2885. describeΣá iε thi≤ document¼á wil∞ bσ availablσ iε thσ SIG/═ libì
  2886. rary.
  2887.  
  2888.  
  2889.  
  2890. 6.03 Distribution Statement for SYSLIB
  2891.  
  2892.      SYSLI┬ i≤ releaseΣ t∩ thσ publiπ domain«á  Anyonσ wh∩ wishe≤ ì
  2893. t∩ US┼ i⌠ ma∙ d∩ s∩ witΦ n∩ string≤ attached«  Thσ autho≥ assume≤ ì
  2894. n∩á responsibilit∙á o≥ liabilit∙ fo≥ thσ usσ oµá SYSLIB«á  I⌠á i≤ ì
  2895. copyrighteΣ b∙ thσ author¼á RicharΣ Conn¼á wh∩ ha≤ solσ right≤ t∩ ì
  2896. it«á  SYSLI┬á anΣá it≤á associateΣ documentatioε ma∙ bσá solΣá b∙ ì
  2897. itselµá o≥ a≤ aε independen⌠ par⌠ oµ ß packagσ oµá program≤á onl∙ ì
  2898. witΦá thσ express¼á writteε consen⌠ oµ thσ author«á  Thσá author¼ ì
  2899. however¼ support≤ thσ usσ oµ SYSLI┬ b∙ commercia∞ softwarσ develì
  2900. opers¼á anΣá place≤ n∩ restrictioε oε thσ salσ oµ program≤á whicΦ ì
  2901. arσá baseΣ oε SYSLI┬ anΣ usσ routine≤ containeΣ withiε SYSLI┬á t∩ ì
  2902. perforφ thei≥ majo≥ functions.
  2903.  
  2904.  
  2905.