October 17, 1983

                        Jim Lopushinsky

                       Edmonton, Alberta


CPM3LIB.RE̠ i� � librar� o� subroutine� tha� mak� us� o� CP/� �
Plu� features��  Include� ar� routine� t� acces� th� tim� an� �
date�� se� an� interogat� elapse� time�� inspec� physica� an� �
logica� characte� I/� devices�� an� set/ge� bau� rate� fo� seria� �
I/� devices.

Thi� i� jus� � start��  I� th� future� � hop� th� librar� wil� b� �
increased to include other CP/M Plus features.

Al� routine� (excep� BIOS� adher� t� th� Microsof� paramete� �
passin� convention� s� tha� the� ma� b� calle� directl�� b�� an� �
Microsoft language compiler (FORTRAN-80, COBOL-80, BASIC-80).

T� includ� an� require� modules�� searc� CPM3LI� durin� th� lin� �
step.







BIOS      Direct bios call thru the BDOS using function 50.

    Input:    Register D - Bios entry number (0-32).
              Al� othe� register� - A� expecte� b�� th� BIO� �
���������������routine.

    Output:   Al� register� returne� a� appropriat� fo� th� BIO� �
���������������routine.





TIMERS    Initiate time counter

    Input:    none.

    Output:   none��  Al� register� ar� preserved�  Th� interna� �
���������������tim� counte� i� initialize� t� � an� incremente� �
���������������every second.

�����Fortran calling convention:

              CALL TIMERS �



ITIMER    Retur� numbe� o� second� elapse� sinc� th� las� cal� t� �
����������TIMERS.

    Input:    none.

    Output:   Register HL - Number of seconds elapsed.
���������������Register A  - Copy of Register L.
���������������Z flag set - TIMERS not yet called.
���������������All other registers are preserved.

    Fortran calling convention:

              ITIME=ITIMER(0)

    Where:    ITIME is either I*2 or I*1 variable.
              �� i� � dumm� paramete� s� tha� FORTRAN-8�� wil�
���������������kno� tha� thi� i� � functio� call.




TIME      Return date and time as 3 character strings.

    Input:    Register HL points to 3 byte Day of Week field.
���������������Register DE points to 8 byte date field.
���������������Register BC points to 8 byte time field.

    Output:   Th� � field� ar� se� t� th� curren� tim� an� date�  �
���������������Day of Week - Abbreviation of Weekday.
���������������Date field - MM/DD/YY.
���������������Time field - HH:MM:SS.
���������������All registers are destroyed.

    Fortran calling convention:

              CALL TIME(WKDAY,DATE,TIMEX)

�����Where:����WKDAY is a 3 byte array.
              DATE and TIMEX are 8 byte arrays.




TIMEB     Return date and time in binary format.

    Input:    Register HL points to Day of Week word.
���������������Register DE points to 3 words for date.
���������������Register BC points to 3 words for time.

    Output:   The 3 fields are set to current date and time.
���������������Weekday is in the range 0-6 (0=Monday). ����������������Date is in the order Month,Day,Year.
���������������Time is in the order Hour,Minute,Second.
���������������All registers are destroyed.

    Fortran calling convention:

              CALL TIMEB(IWKDAY,IDATE,ITIME)

    Where:    IWKDAY is I*2 variable for Weekday.
              IDATE and ITIME are I*2 arrays of 3 for date and time.




IFNDEV    Return� th� pysica� devic� numbe� associate� wit� th� �
����������devic� name.

    Input:    Registe� H̠ point� t� � characte� strin� whic� �
���������������contain� th� devic� name.


    Output:   Register HL contains the device number.
              Register A  - copy of register L.
              All other registers are preserved.

    Error condition��    I� registe� H� � 0FFFF� (-1�� the� th� �
���������������named device does not exist.

    Fortran calling convention:

              IDEV=IFNDEV(DEVNM)

    Where:    IDEV is I*2 or I*1 variable for device number.
              DEVNM is 6 byte string containing the device name.

    Example:  IDEV=IFNDEV('MODEM ')

              IDE֠� wil� contai� th� pysica� devic� numbe� �
���������������associate� wit� th� nam� MODEM�� o� -�� i� MODE� �
���������������could not be found.




IBAUD     Get or Set the baud rate for a pysical device.

    Input:    Register HL points to the Baud rate word.
              If baud rate=0 then return current baud rate.
���������������Otherwise set the device to value at baud rate.
���������������Register DE points to device number byte.

    Output:   Registe� H� contain� th� curren� bau� rat� o� th� �
���������������requested device.

    Error condition��    H� � � - Invali� bau� rat� o� invali� �����������������devic� numbe� o� devic� doe� no� suppor� requeste� �
���������������baud rate.

    Fortran calling convention:

              IBD=IBAUD(IRATE,IDEVNO)

�����Where:����IBD is I*2 variable containing returned baud rate.
              IRATŠ i� I*� variabl� whic� contain� � fo� ge� o� �
���������������a baud rate for set.
���������������IDEVNϠ i� I*�� o� I*�� variabl� containin� th� �
���������������device number.

    Examples:

              IBD=IBAUD(0,1)

              Returns the current baud rate of device 1

              IBD=IBAUD(1200,2)

              Sets the baud rate of device 2 to 1200 baud.





IMXDEV    Returns the maximum physical device number.

    Input:    none.

    Output:   Register L - Maximum device number.
���������������Register A - Copy of Register L.
���������������Register H - 0
���������������All other registers are preserved.

    Fortran calling convention:

              MAXDEV=IMXDEV(0)

    Where:    MAXDE֠ i� I*� o� I*� variabl� tha� wil� contai� �
���������������the maximum physical device number.




IGTMOD    Returns a physical device Mode byte.

    Input:    Register HL points to physical device number

    Output:   Register L - Mode byte
              Register A - Copy of Register L.
              Register H - 0
              All other registers are preserved.
�     Fortran calling convention:

              MODE=IGTMOD(IDEVNO)

    Where:    IDEVNO is I*2 or I*1 physical device number.
���������������MOD� i� I*� o� I*� variabl� tha� wil� contai� th� �
���������������mode byte.

���������������Th� bit� i� th� mod� byt� hav� th� followin� �
���������������meanings:

���������������Bit

���������������0    Device may do input
���������������1    Device may do output
���������������2    Software selectable baud rates
���������������3    Device may use XON/XOFF protocol
���������������4    XON/XOFF protocol enabled
���������������5-7  Reserved for future use




IGTDEV    Retur� curren� logica� t� physica� devic� assignmen� �
����������vector.

    Input:    Register HL points to logical device number.

              CP/M 3 has five logical devices:

              0    CONIN     Console input
���������������1    CONOUT    Console output
���������������2    AUXIN     Auxiliary input
���������������3    AUXOUT    Auxiliary output
���������������4    LSTOUT    List output

    Output:  �Registe� H� - curren� physica� assignmen� vecto� �
���������������fo� th� requeste� logica� device��  Bit� ar� se� �
���������������correspondin� t� physica� device� fro� lef� t� �
���������������right (bit 15 = device 0, bit 0 = device 15).
���������������All other registers (except PSW) are preserved.

    Error condition:
���������������Registe� H� � 0FFFF� (-1� - Invali� logica� devic� �
���������������number.

    Fortran calling convention:

              IVEC=IGTDEV(DEVNO)

    Where:    DEVNO is I*2 or I*1 logical device number.
              IVEC is I*2 variable for assignment vector.



ISTDEV    Set logical to physical device assignment vector.

    Input:    Register HL points to logical device number.
              Registe� DŠ point� t� ne�� physica� assignmen� �
���������������vector.

    Output:   none���  Al� register� excep� PSנ an� H̠ ar� �
���������������preserved.

    Error condition:
              Registe� H� � 0FFFF� (1-� Invali� logica� devic� �
���������������number.

    Fortran calling convention:

              IERR=ISTDEV(DEVNO,IVEC)

    Where:    DEVNO is I*2 or I*1 logical device number.
���������������IVEC is I*2 assignment vector.
���������������IERR is I*2 or I*1 error return code.