Directory Manipulation Routines
Numeric String Evaluation Routines
Byte-Oriented File Input/Output Routines
CP/M File Input/Output Routines
User/Disk Manipulation Routines
File Name String Parser (FNAME) and FCB Init (INITFCB)
ZCPR2-Specific File Name String Parser (ZFNAME) and Support
ZCPR2 Feature-Specific Routines
Input Line Editors
String Output Routines
Numeri�Outpu� Routine�
String and Value Comparison Routines
Character-Oriented Input/Output Routines
Math Routines
CRC Routines
Random Number Generator Routines
Sort Routines
Mis�ellaneous Routines
::SYSLIB1.HLP
::SYSLIB2.HLP
::SYSLIB3.HLP
::SYSLIB4.HLP
:User/Disk Manipulation Routines

    Thi� i� � se� o� fou� routine� whic� allo�� th� use� t� �
readil� mov� aroun� betwee� disk� an� use� areas�  Thes� routine� �
are:
         PUTUD -- to save away the current disk/user
         GETUD -- to restore the disk/user saved by PUTUD
         RETUD -- to return the current disk/user
         LOGUD -- to log the user into a specified disk/user

    PUTUĠ an� GETU� ar� designe� t� b� use� a� � plac� marke� �
an� retur� combination��  The� ar� intende� t� b� use� i� cod� �
sequences like the following:

         CALL PUTUD     ; Mark current location
         < move around on disks/users >
         CALL GETUD     ; Return to marked location

    RETU� an� LOGU� ar� t� b� use� t� fin� ou� wher� th� progra� �
is (RETUD) and to enter a specific disk/user area (LOGUD).

    Routine Name:  PUTUD
    Function�
         PUTUĠ save� th� curren� use� an� dis� number� awa� fo� �
late� retrieva� b� GETUD��  PUTU� an� GETU� ar� intende� t� b� �
use� t� sav� an� restor� th� curren� dis� an� use� aroun� som� �
set of operations in another user/disk area.
    Inputs:  None
    Outputs:  None
    Registers Affected:  None
    SYSLIB Routines Called:  RETUD
    Specia� Erro� Conditions�  None


    Routine Name:  GETUD
    Function�
         GETUĠ restore� th� curren� use� an� dis� whic� wa� �
saved by PUTUD.
    Inputs:  None
    Outputs:  None
    Registers Affected:  None
    SYSLIB Routines Called:  BDOS
    Specia� Erro� Conditions�  None


    Routine Name:  LOGUD
    Function�
         LOGU� log� i� th� dis� specifie� b� th� � registe� (B=� �
fo� Dis� A) and the user specified by the C register.
    Inputs:  B=Disk (B=0 for Disk A), C=User
    Outputs:  None
    Registers Affected:  None
    SYSLIB Routines Called:  BDOS
    Specia� Erro� Conditions�  None


    Routine Name:  RETUD
    Function�
         RETUĠ return� th� number� o� th� curren� use� i� � an� �
current disk in B (B=0 for disk A).
    Inputs:  None
    Outputs:  B=Disk (B=0 for disk A), C=User
    Registers Affected:  BC
    SYSLIB Routines Called:  BDOS
    Specia� Erro� Conditions�  None


:File Name String Parser (FNAME) and FCB Init (INITFCB)
    Routine Name: FNAME
    Function:
         FNAMŠ i� � fil� nam� scanner��  Pointin� t� th� firs� �
characte� o� � fil� nam� specificatio� o� th� form:

�����          du:filename.typ

wher� an�� par� o� th� specificatio� i� optional�� thi� routin� �
fill� i� a� FC� wit� zeroe� (3� bytes)�� properl� initialize� th� �
F� (Fil� Name� fiel� i� 'filename� i� presen� an� F� (Fil� Type� �
fiel� i� 'typ� i� present� an� return� th� numbe� o� th� selecte� �
dis� (i� th� rang� fro� � fo� � t� 1� fo� P� i� 'd� i� presen� �
an� th� numbe� o� th� selecte� use� (i� th� rang� fro� �� t� 3� �
an� th� questio� mar� '?� character� i� 'u� i� present��  I� 'd� �
i� no� present� 0FF� i� returne� fo� i� t� indicat� curren� disk� �
an� i� 'u� i� no� present�� 0FF� i� returne� fo� i� t� indicat� �
curren� user.


    Th� strin� pointe� t� b� H� i� no� � conventiona� strin� i� �
th� sens� o� th� res� o� th� SYSLI� routines��  Thi� strin� i� �
terminate� b� an� o� th� followin� delims�� a� oppose� b�� simpl� �
alway� bein� terminate� b� � binar� zero�  Th� delimite� lis� is:

�����          <NULL or Binary 0>       <SP or Space>
�����          =    _    ;    ,    <    >

    Th� followin� ar� vali� examples:
�����          test.txt   <-- FN=TEXT  FT=TXT, B reg = 0FFH,
�����                         C reg = 0FFH
�����          a:t        <-- FN=T  FT=<SP>, B reg = 1,
�����                         C reg = 0FFH
�����          5:t        <-- FN=T  FT=<SP>, B reg = 0FFH,
�����                         C reg = 5
�����          c10:x.y    <-- FN=X  FT=Y, B reg = 3,
�����                         C reg = 10


    Inputs:  HL points to the first byte of the target string
�����               (which ends in a delimiter)
�����         DE pts to the first byte of a 36-byte long FCB
    Outputs:  B=Disk Number (1 for A to 16 for P, or 0FFH if
�����               no disk specified)
�����          C=User Number (0 to 31 or '?' for all users, or
�����               0FFH if no user specified)
�����          HL points to the character which ended the scan
�����          A = 0 and Zero Flag Set (Z) if invalid Disk or User
�����               Specified; A = 0FFH and NZ if no error
    Registers Affected: PSW, BC, HL
    SYSLIB Routines Called:  CAPS
    Special Error Conditions:  None


    Routine Name:  INITFCB
    Function�
�����     INITFC  simpl�� clear� al� o� th� field� o� � 36-byt� �
�����FC  t� zer� excep� fo� th� F� an� F� (Fil� Nam� an� Fil� �
�����Type� fields� whic� i� leave� untouched.

    Inputs:  DE = pointer to FCB buffer
    Outputs:  None
    Registers Affected:  None
    SYSLIB Routines Called:  FILLB
    Special Error Conditions:  None
::SYSLIB8.HLP
::SYSLIB9.HLP
::SYSLIBA.HLP
:String Output Routines -- PRINT, LPRINT, PSTR, LPSTR
    Routine Names:  PRINT, LPRINT
    Function�
         Prin� strin� pointe� t� b� th� retur� addres� o� CON� �
(PRINT�� o� LST�� (LPRINT)��  Strin� i� terminate� b� � binar� 0�  �
Contro� i� returne� t� byt� followin� string.
    Inputs:  Return Address = pointer to string to be printed
    Outputs:  HL points to byte after string
              (string is printed on CON: or LST:)
    Registers Affected:  HL
    SYSLIB Routines Called:  PSTR (for PRINT); LSTR (for LPRINT)
    Specia� Erro� Conditions:
         Th� strin� MUS� b� terminate� b� � binar� 0!!!

    Routine Names:  PSTR, LPSTR
    Function�
         Prin� strin� pointe� t� b� H� o� CON�� (PSTR� o� LST� �
(LPSTR)�  Strin� i� terminate� b� � binar� 0.
    Inputs:  HL = pointer to string to be printed
    Outputs:  HL pts to the byte following the terminating 0
               (string is printed on CON: or LST:)
    Registers Affected:  HL
    SYSLI  Routine� Called�  CCOUT�� COU� (fo� PSTR)�
                              LCOUT� LOU� (fo� LPSTR)
    Specia� Erro� Conditions:
         Th� strin� MUS� b� terminate� b� � binar� 0!!!
::SYSLIB5.HLP
:String and Value Comparision Routines
    Routine Name:  COMPHD
    Function�
         Compar� H� t� DE��  O� return�� Zer� Fla� Se� =� HL=DE� �
Carr� Fla� Se� =� HL<DE.
    Inputs:  HL, DE -- Values to compare
    Outputs:  Zero and Carry Flags
    Registers Affected:  PSW
    SYSLIB Routines Called:  -None-
    Special Error Conditions:  -None-

    Routine Names:  COMPB, COMPBC
    Function�
         Vecto� Compar� Routines�  Compar� th� vecto� pointe� t� �
b�� H� wit� tha� pointe� t� b� D� (Vector� ar� o� equa� length)�  �
Vector� ar� � byte� lon� fo� COMP� an� B� byte� lon� fo� COMPBC�  �
O� exit�� Zer� Fla� Se� indicate� tha� vector� ar� identical� �
Carr� Fla� Se� indicate� tha� th� vecto� pointe� t� b� H� i� les� �
tha� th� vecto� pointe� t� b� DE.
    Inputs:  HL, DE -- Pointers to vectors to compare
             B (for COMPB), BC (for COMPBC) -- number of bytes in vectors
    Outputs:  Zero and Carry Flags
    Registers Affected:  PSW
    SYSLIB Routines Called:  -None-
    Special Error Conditions:  -None-

    Routine Name:  SCANNER
    Function�
         SCANNE� scan� th� vecto� o� byte� pointe� t� b� H̠ fo� �
th� vecto� o� byte� pointe� t� b� DE��  Th� HL-byt� vecto� i� � �
byte� lon� an� th� DE-byt� vecto� i� � byte� long�  O� return� i� �
found� H� point� t� th� beginnin� locatio� withi� th� origina� H� �
vecto� o� th� locate� vecto� an� th� Zer� Fla� i� Set�� i� no� �
found� Zer� Fla� i� no� se� an� H� i� no� affecte� (point� t� th� �
beginnin� o� th� origina� HL-byt� vector).
    Inputs:  HL = Pointer to vector to be scanned
             DE = Pointer to vector to scan for
             B = Number of bytes in HL-vector
             C = Number of bytes in DE-vector
    Outputs:  If found, Zero Set and HL pts to located vector
              If not found, Zero Reset and HL unaffected
    Registers Affected:  PSW, HL
    SYSLIB Routines Called:  -None-
    Specia� Erro� Conditions��  Automati� succes� i� vecto� �
searche� fo� i� null.

    Routine Name:  INSTR
    Function�
         INSTRINǠ Function��  Sca� th� strin� pointe� t� b�� H� �
fo� th� strin� pointe� t� b� DE��  � strin� i� � vecto� o� byte� �
terminate� b� � binar� 0.
         O� return�� i� found� Zer� Fla� i� Se� an� H� point� t� �
1s� byt� o� substrin� withi� scanne� string�� i� no� found�� Zer� �
Fla� i� no� se� an� H� i� no� affected.
    Inputs:  HL = Pointer to string to be scanned
             DE = Pointer to string to scan for
    Outputs:  If found, Zero Set and HL pts to located substring
              If not found, Zero Reset and HL unaffected
    Registers Affected:  PSW, HL
    SYSLIB Routines Called:  -None-
    Specia� Erro� Conditions:
         Automati� succes� i� strin� searche� fo� i� null.
::SYSLIB6.HLP
::SYSLIB7.HLP
:CRC Routines -- CRCCLR, CRCUPD, CRCDONE, CRC1's, CRC2's
    Th� CRà Routine� ma� b� use� t� chec� th� validit�� o� a� �
incomin� seria� byt� strea� o� arbitrar� length��  Thes� routine� �
comput� an� chec� � tru� 16-bi� Cycli� Redundanc� Cod� (CRC).
    The use of these routines will guarantee detection of:
         1) all single- and double-bit errors
         2) all errors with an odd number of error bits
         3) all burst errors of length 16 or less
    Additionally, the following statistics:
         1) 99.9969% of all 17-bit error bursts
         2) 99.9984% of all possible longer error bursts

    Th� followin� scree� displa� illustrate� � typica� wa�� t� �
us� thes� routines:

    CRC$MAKE:                ; ROUTINE TO ESTABLISH OUTGOING CRC VALUE
         CALL CRCCLR    ; CLEAR CRC
         <loop CALLing CRCUPD>    ; ACQUIRE VALUES
         CALL CRCDONE   ; GET VALUE
         SHLD CRCVAL    ; SAVE VALUE
    CRC$CHECK:          ; ROUTINE TO CHECK INCOMING CRC VALUE
         CALL CRCCLR    ; CLEAR CRC
         <loop CALLing CRCUPD>    ; ACQUIRE VALUES
         CALL CRCDONE   ; GET VALUE
         XCHG           ; VALUE IN DE
         LHLD CRCVAL    ; GET FIRST VALUE IN HL
         CALL COMPHD    ; COMPARE HL TO DE
         JNZ  ERROR     ; CRC'S DON'T MATCH IF NOT EQUAL

    Th� followin� scree� display� describ� th� CRà routines�  �
Th� CRC- routine� us� th� X^16+X^12+X^5+� polynomial�� th� CRC1- �
routine� us� th� X^16+X^15+X^2+�� polynomial�� an� th� CRC2-�
routines use the X^16+X^15+X^13+X^7+X^4+X^2+X+1 polynomial.
    Routine Name:  CRCCLR, CRC1CLR, CRC2CLR
    Function�
         Clea� th� interna� CR� Accumulato� i� preparatio� t� �
CR� computation.
    Inputs:  None
    Outputs:  None
    Registers Affected:  None
    SYSLIB Routines Called:  None
    Special Error Conditions:  None

    Routine Name:  CRCUPD, CRC1UPD, CRC2UPD
    Function:
         Updat� th� CR� Accumulato� valu� wit� th� nex� byte.
    Input:  A=byte to be included in CRC
    Outputs:  None
    Registers Affected:  None
    SYSLIB Routines Called:  None
    Special Error Conditions:  None
    Routine Name:  CRCDONE, CRC1DONE, CRC2DONE
    Function�
         Terminat堠 CRà valu� accumulatio� an� retur th� �
calculate� 16-bi� CR� value.
    Inputs:  None
    Output:  HL = calculated CRC value
    Registers Affected:  HL
    SYSLIB Routines Called:  None
    Special Error Conditions:  None

:Random Number Generator Routines

    The Random Number Generator Routines are:

         RNDINIT - Initializes the Generator Seed on user
                        keypress
         RNDSEED - Allows user to provide a seed
         RND - Returns a Pseudo-Random Number


    Routine Name:  RNDINIT
    Function�
         RNDINI� enter� � countin� loop� waitin� fo� th� use� t� �
strik� � ke� a� hi� console�  I� the� set� th� see� valu� fo� th� �
rando� numbe� generato� base� upo� it� coun� valu� a� th� instan� �
of keypress.  The seed value is an 8-bit quantity.
    Inputs:  None (User Keypress)
    Outputs:  None  (Seed is set)
    Registers Affected:  None
    SYSLIB Routines Called:  CONDIN, RND
    Specia� Erro� Conditions�  None

    Routine Name:  RNDSEED
    Function�
         Thi� routin� allow� th� use� t� provid� � see� valu� �
fo� th� rando� numbe� generator��  Th� see� i� passe� i� th� � �
register.
    Inputs:  A = Seed
    Outputs:  None  (Seed is set)
    Registers Affected:  None
    SYSLIB Routines Called:  RND
    Specia� Erro� Conditions�  None


    Routine Name:  RND
    Function�
         Thi� i� th� user-callabl� rando� numbe� generator��  I� �
return� � pseudo-rando� numbe� (8-bit� i� th� �� registe� whe� �
called.
    Inputs:  None
    Outputs:  A = Random Number
    Registers Affected:  PSW
    SYSLIB Routines Called:  None
    Specia� Erro� Conditions�  None

::SYSLIBB.HLP
::SYSLIBC.HLP