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