                                       CP/M 2.2
                             Application Note 03, 06/25/81
                        Sample BIOS for a Serial Printer Device

                          Copyright   1982 by Digital Research
                  CP/M is a registered trademark of Digital Research.
                                 Compiled November 1982



          Applicable products and version numbers:  CP/M   V1.4,  V2.0,  V2.1,
          and V2.2

          Program:  BIOS

               The following code  fragment  drives  Diablo  serial  interface
          printers  or  other  serial devices that use the X ON/X OFF protocol
          for synchronization.  A device that uses this protocol receives data
          faster  than  it can print.  The device transmits a CTRL-S character
          when its buffer becomes full, and a  CTRL-Q  to  receive  more  data
          after the buffer is emptied.


                LIST$STAT EQU 00H
                LIST$DATA EQU 01H
                IN$MASK   EQU 02H
                OUT$MASK  EQU 01H

                LIST:
                         CALL LISTST ! JZ LIST
                         MOV A,C ! OUT LIST$DATA
                         RET
                LISTST
                         ;return list status (0 if not ready, FF if ready)
                         LXI H,LST$FLAG
                         IN LIST$STAT ! ANI INS$MASK ! JZ NO$INPUT
                         IN LIST$DATA ! ANI 7FH ! CPI 'Q'-'@' ! JNZ S?
                         MVI M OFFH
                S?       CPI 'S'-'@' ! JNZ NO$INPUT
                         MVI M,O
                NO$INPUT:
                         IN LIST$STAT ! ANI OUT$MASK ! ANA M ! RZ
                         ORI 255
                         RET
                LST$FLAG:
                         DB     255     ;must be 255 initially


               Licensed  users  are  granted  the  right  to   include   these
          modifications in CP/M software.
