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

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