                                       CP/M   V2.2
                              Application Note 04, 2/20/82 
                             BIOS Error Return Code Options

                           Copyright  1982 by Digital Research
                  CP/M is a registered trademark of Digital Trademark.
                     DDT and SID are trademarks of Digital Research.
                                 Compiled November 1982



          Applicable products and version numbers:   CP/M   V2.2

          Program:  BIOS

               Usually, CP/M responds only to a zero or nonzero  value  as  the
          return  code from the BIOS READ and WRITE entry points.  If the value
          in register A is zero, CP/M  assumes  that  the  disk  operation  was
          completed  successfully.  If  a  nonzero  value is in register A, the
          BDOS returns the message BDOS ERR ON x: BAD SECTOR.   You  then  have
          the  option of pressing the RETURN key to ignore the error, or CTRL-C
          to abort.

               This modification interjects three additional return  codes  for
          the BIOS READ and WRITE routines in register A as shown below.


               0    The disk Read or Write operation was successful.
               1    Bad Sector--indicates permanent disk error.
               2    Select Error--indicates the drive is not ready.
               3    R/O--the disk is Read-Only (used by WRITE).
               4    File R/O--not normally used.


               In the following code segment, addresses given  are  hexadecimal
          offsets from the base of the CP/M system.  The CCP is usually located
          at 980H, but can be located at A00H if you use a two-sector boot.

               After modifying your BIOS READ and WRITE routines  to  pass  the
          extended error codes to the BDOS, you can assemble the BDOS patch for
          your size memory system.  The cpmbase equals  the  BDOS  entry  point
          address  at  locations 6 and 7 in the base page of memory minus 806H.
          You must change this  entry point  address when  you  load  DDT    or
          SID    .  Under  DDT  or SID, follow the jump at location 5 until you
          find an address  with  a  least  significant  digit  of  6.   In  the
          following example, the cpmbase would be E506H-806H or DD00H.


                  0005  JMP  CD00
                  CD00  JMP  D3A4
                  D3A4  XTHL
                  D3A5  SHLD E452
                  D3A8  XTHL
                  D3A9  JMP  E506
                                          1
          CP/M V2.2                                     Application Note 04


               Patch into the SYSGEN or MOVCPM image exactly as you would patch
          in  a  new  version of your BIOS, using the DDT i command followed by
          the DDT r command.  Use the same offset as your custom BIOS.

               Before installing this patch, the code at  the  cpmbase  +  BBDh
          should read:

                  lxi     h,cpmbase +809H
                  jmp     cpmbase + B4AH

          Replace the preceding code with the following code:

                  cpmbase equ     ?
                  ;
                  ;
                          org     cpmbase + BBDH
                  ;
                          lxi     h,cpmbase + 807H
                          jmp     cpmbase + 83AH
                          end

               Or, you  can  install  this  change  directly  into  MOVCPM,  if
          MOVCPM.COM  is  on  your  system disk.  The patch is installed in any
          size system that you build using MOVCPM.   Make  a  back-up  copy  of
          MOVCPM.COM before using DDT to install the following procedure:

                    A>ddt movcpm.com
                    DDT VERS 2.2
                    NEXT  PC
                    2700 0100
                    -l15bd
                    15BD  LXI  H,0809
                    15C0  JMP  0B4A
                    15C3  LHLD 15EA
                    . . .

                    -a15bd
                    15BD lxi h,807
                    15C0 jmp 83a
                    15C3 .
                    -g0

                    A>save 38 movcpm1.com


               Use  the  new  program  MOVCPM1.COM  in  place  of   MOVCPM.COM.
          Additional  error  return  codes for the BIOS READ and WRITE routines
          are supported in any CP/M system generated with MOVCPM1.COM.

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