PL/M-86 COMPILER    SDIR - UTILITY ROUTINES                                                                     PAGE   1


ISIS-II PL/M-86 V2.0 COMPILATION OF MODULE UTILITY
OBJECT MODULE PLACED IN UTIL
COMPILER INVOKED BY:  :F0: UTIL.PLM DEBUG OBJECT(UTIL) OPTIMIZE(3) XREF



              $title('SDIR - Utility Routines')
   1          utility:
              do;

              /* Utility Module for SDIR */
               
              $include(comlit.lit)
          =
   2   1  =   declare
          =           lit                literally          'literally',
          =           dcl                lit                'declare',
          =           true               lit                '0ffh',
          =           false              lit                '0',
          =           boolean            lit                'byte',
          =           forever            lit                'while true',
          =           cr                 lit                '13',
          =           lf                 lit                '10',
          =           tab                lit                '9',
          =           ctrlc              lit                '3',
          =           ff                 lit                '12',
          =           page$len$offset    lit                '1ch',
          =           nopage$mode$offset lit                '2Ch',
          =           sectorlen          lit                '128';


              /* -------- arithmetic functions -------- */

   3   1      add3byte: procedure(byte3adr,num) public;
   4   2            dcl (byte3adr,num) address,
                        b3 based byte3adr structure (
                        lword address,
                        hbyte byte),
                        temp address;

   5   2            temp = b3.lword;
   6   2            if (b3.lword := b3.lword + num) < temp then             /* overflow */
   7   2                b3.hbyte = b3.hbyte + 1;
   8   2      end add3byte;

                          /* add three byte number to 3 byte value structure */
   9   1      add3byte3: procedure(totalb,numb) public;
  10   2            dcl (totalb,numb) address,
                        num based numb structure (
                        lword address,
                        hbyte byte),
                        total based totalb structure (
                        lword address,
                        hbyte byte);

  11   2            call add3byte(totalb,num.lword);
  12   2            total.hbyte = num.hbyte + total.hbyte;
PL/M-86 COMPILER    SDIR - UTILITY ROUTINES                                                                     PAGE   2


  13   2      end add3byte3;

                                                              /* divide 3 byte value by 8 */
  14   1      shr3byte: procedure(byte3adr) public;
  15   2          dcl byte3adr address,
                      b3 based byte3adr structure (
                      lword address,
                      hbyte byte),
                      temp1 based byte3adr (2) byte,
                      temp2 byte;

  16   2              temp2  = ror(b3.hbyte,3) and 11100000b;  /* get 3 bits              */
  17   2              b3.hbyte = shr(b3.hbyte,3);
  18   2              b3.lword = shr(b3.lword,3);
  19   2              temp1(1) = temp1(1) or temp2;            /* or in 3 bits from hbyte */
  20   2      end shr3byte;


              /* ------- print routines -------- */

  21   1      mon1: procedure(f,a) external;
  22   2          declare f byte, a address;
  23   2      end mon1;

              /*break: procedure external;
              end break;*/

              $include(fcb.lit)
          =
  24   1  =   declare
          =       f$drvusr          lit '0',        /* drive/user byte               */
          =       f$name            lit '1',        /* file name                     */
          =       f$namelen         lit '8',        /* file name length              */
          =       f$type            lit '9',        /* file type field               */
          =       f$typelen         lit '3',        /* type length                   */
          =       f$rw              lit '9',        /* high bit is R/W attribute     */
          =       f$dirsys          lit '10',       /* high bit is dir/sys attribute */
          =       f$arc             lit '11',       /* high bit is archive attribute */
          =       f$ex              lit '12',       /* extent                        */
          =       f$s1              lit '13',       /* module byte                   */
          =       f$rc              lit '15',       /* record count                  */
          =       f$diskmap         lit '16',       /* file disk map                 */
          =       diskmaplen        lit '16',       /* disk map length               */
          =       f$drvusr2         lit '16',       /* fcb2                          */
          =       f$name2           lit '17',
          =       f$type2           lit '25',
          =       f$cr              lit '32',       /* current record                */
          =       f$rrec            lit '33',       /* random record                 */
          =       f$rreco           lit '35';       /*   "      "    overflow        */
          =

              /* BDOS calls */

  25   1      print$char: procedure(char) public;
  26   2          declare char byte;
  27   2          call mon1(2,char);
  28   2      end print$char;
PL/M-86 COMPILER    SDIR - UTILITY ROUTINES                                                                     PAGE   3



  29   1      print: procedure(string$adr) public;
  30   2          dcl string$adr address;
  31   2          call mon1(9,string$adr);
  32   2      end print;

  33   1      printb: procedure public;
  34   2          call print$char(' ');
  35   2      end printb;
               
  36   1      crlf: procedure public;
  37   2          call print$char(cr);
  38   2          call print$char(lf);
  39   2      end crlf;

  40   1      printfn: procedure(fname$adr) public;
  41   2          dcl fname$adr address,
                      file$name based fname$adr (1) byte,
                      i byte;                                /* <filename> ' ' <filetype> */

  42   2          do i = 0 to f$namelen - 1;
  43   3              call printchar(file$name(i) and 7fh);
  44   3          end;
  45   2          call printchar(' ');
  46   2          do i = f$namelen to f$namelen + f$typelen - 1;
  47   3              call printchar(file$name(i) and 7fh);
  48   3          end;
  49   2      end printfn;

  50   1      pdecimal: procedure(v,prec,zerosup) public;
                                       /* print value v, field size = (log10 prec) + 1  */
                                       /* with leading zero suppression if zerosup = true */
  51   2          declare v address,                          /* value to print           */
                          prec address,                       /* precision                */
                          zerosup boolean,                    /* zero suppression flag    */
                          d byte;                             /* current decimal digit    */

  52   2          do while prec <> 0;
  53   3              d = v / prec;                           /* get next digit           */
  54   3              v = v mod prec;                         /* get remainder back to v  */
  55   3              prec = prec / 10;                       /* ready for next digit     */
  56   3              if prec <> 0 and zerosup and d = 0 then
  57   3                  call printb;
                      else
  58   3              do;
  59   4                  zerosup = false;
  60   4                  call printchar('0'+d);
  61   4              end;
  62   3          end;
  63   2      end pdecimal;

  64   1      p3byte: procedure(byte3adr,prec) public;
                                                 /* print 3 byte value with 0 suppression */
  65   2            dcl byte3adr address,        /* assume high order bit is < 10         */
                        prec address,
                        b3 based byte3adr structure (
                        lword address,
PL/M-86 COMPILER    SDIR - UTILITY ROUTINES                                                                     PAGE   4


                        hbyte byte),
                        i byte;

                                                     /* prec = 1 for 6 chars, 2 for 7 */
  66   2            if b3.hbyte <> 0 then
  67   2            do;
  68   3                call pdecimal(b3.hbyte,prec,true);  /* 3 for 8 chars printed      */
  69   3                call pdecimal(b3.lword,10000,false);
  70   3            end;
                    else
  71   2            do;
  72   3                i = 1;
  73   3                do while i <= prec;
  74   4                    call printb;
  75   4                    i = i * 10;
  76   4                end;
  77   3                call pdecimal(b3.lword,10000,true);
  78   3            end;
  79   2      end p3byte;

  80   1      end utility;
PL/M-86 COMPILER    SDIR - UTILITY ROUTINES                                                                     PAGE   5


CROSS-REFERENCE LISTING
-----------------------


   DEFN  ADDR   SIZE  NAME, ATTRIBUTES, AND REFERENCES
  ----- ------ -----  --------------------------------


     21  0000H     2  A. . . . . . . . .    WORD PARAMETER        22 
      3  0000H    29  ADD3BYTE . . . . .    PROCEDURE PUBLIC STACK=0006H         11 
      9  001DH    30  ADD3BYTE3. . . . .    PROCEDURE PUBLIC STACK=000EH
      4  0000H     3  B3 . . . . . . . .    STRUCTURE BASED(BYTE3ADR)        5    6    7 
     15  0000H     3  B3 . . . . . . . .    STRUCTURE BASED(BYTE3ADR)       16   17   18 
     65  0000H     3  B3 . . . . . . . .    STRUCTURE BASED(BYTE3ADR)       66   68   69   77 
      2               BOOLEAN. . . . . .    LITERALLY        51 
      3  0006H     2  BYTE3ADR . . . . .    WORD PARAMETER AUTOMATIC         4    5    6    7 
     64  0006H     2  BYTE3ADR . . . . .    WORD PARAMETER AUTOMATIC        65   66   68   69   77 
     14  0004H     2  BYTE3ADR . . . . .    WORD PARAMETER AUTOMATIC        15   16   17   18   19 
     25  0004H     1  CHAR . . . . . . .    BYTE PARAMETER AUTOMATIC        26   27 
      2               CR . . . . . . . .    LITERALLY        37 
     36  0087H    17  CRLF . . . . . . .    PROCEDURE PUBLIC STACK=000EH
      2               CTRLC. . . . . . .    LITERALLY
     51  0004H     1  D. . . . . . . . .    BYTE        53   56   60 
      2               DCL. . . . . . . .    LITERALLY
     24               DISKMAPLEN . . . .    LITERALLY
     21  0000H     1  F. . . . . . . . .    BYTE PARAMETER        22 
      2               FALSE. . . . . . .    LITERALLY        59   69 
     24               FARC . . . . . . .    LITERALLY
     24               FCR. . . . . . . .    LITERALLY
     24               FDIRSYS. . . . . .    LITERALLY
     24               FDISKMAP . . . . .    LITERALLY
     24               FDRVUSR. . . . . .    LITERALLY
     24               FDRVUSR2 . . . . .    LITERALLY
     24               FEX. . . . . . . .    LITERALLY
      2               FF . . . . . . . .    LITERALLY
     41  0000H     1  FILENAME . . . . .    BYTE BASED(FNAMEADR) ARRAY(1)        43   47 
     24               FNAME. . . . . . .    LITERALLY
     24               FNAME2 . . . . . .    LITERALLY
     40  0004H     2  FNAMEADR . . . . .    WORD PARAMETER AUTOMATIC        41   43   47 
     24               FNAMELEN . . . . .    LITERALLY        42   46 
      2               FOREVER. . . . . .    LITERALLY
     24               FRC. . . . . . . .    LITERALLY
     24               FRREC. . . . . . .    LITERALLY
     24               FRRECO . . . . . .    LITERALLY
     24               FRW. . . . . . . .    LITERALLY
     24               FS1. . . . . . . .    LITERALLY
     24               FTYPE. . . . . . .    LITERALLY
     24               FTYPE2 . . . . . .    LITERALLY
     24               FTYPELEN . . . . .    LITERALLY        46 
     65  0002H     1  HBYTE. . . . . . .    BYTE MEMBER(B3)       66   68 
     15  0002H     1  HBYTE. . . . . . .    BYTE MEMBER(B3)       16   17 
     10  0002H     1  HBYTE. . . . . . .    BYTE MEMBER(TOTAL)         12 
     10  0002H     1  HBYTE. . . . . . .    BYTE MEMBER(NUM)           12 
      4  0002H     1  HBYTE. . . . . . .    BYTE MEMBER(B3)        7 
     65  0005H     1  I. . . . . . . . .    BYTE        72   73   75 
     41  0003H     1  I. . . . . . . . .    BYTE        42   43   46   47 
      2               LF . . . . . . . .    LITERALLY        38 
PL/M-86 COMPILER    SDIR - UTILITY ROUTINES                                                                     PAGE   6


      2               LIT. . . . . . . .    LITERALLY         2   24 
     15  0000H     2  LWORD. . . . . . .    WORD MEMBER(B3)       18 
     10  0000H     2  LWORD. . . . . . .    WORD MEMBER(TOTAL)
     10  0000H     2  LWORD. . . . . . .    WORD MEMBER(NUM)           11 
      4  0000H     2  LWORD. . . . . . .    WORD MEMBER(B3)        5    6 
     65  0000H     2  LWORD. . . . . . .    WORD MEMBER(B3)       69   77 
     21  0000H        MON1 . . . . . . .    PROCEDURE EXTERNAL(0) STACK=0000H         27   31 
      2               NOPAGEMODEOFFSET .    LITERALLY
     10  0000H     3  NUM. . . . . . . .    STRUCTURE BASED(NUMB)           11   12 
      3  0004H     2  NUM. . . . . . . .    WORD PARAMETER AUTOMATIC         4    6 
      9  0004H     2  NUMB . . . . . . .    WORD PARAMETER AUTOMATIC        10   11   12 
     64  0143H    89  P3BYTE . . . . . .    PROCEDURE PUBLIC STACK=0020H
      2               PAGELENOFFSET. . .    LITERALLY
     50  00EDH    86  PDECIMAL . . . . .    PROCEDURE PUBLIC STACK=0018H         68   69   77 
     64  0004H     2  PREC . . . . . . .    WORD PARAMETER AUTOMATIC        65   68   73 
     50  0006H     2  PREC . . . . . . .    WORD PARAMETER AUTOMATIC        51   52   53   54   55   56 
     29  006CH    16  PRINT. . . . . . .    PROCEDURE PUBLIC STACK=000AH
     33  007CH    11  PRINTB . . . . . .    PROCEDURE PUBLIC STACK=000EH         57   74 
     25  0059H    19  PRINTCHAR. . . . .    PROCEDURE PUBLIC STACK=000AH         34   37   38   43   45   47   60
     40  0098H    85  PRINTFN. . . . . .    PROCEDURE PUBLIC STACK=0010H
                      ROR. . . . . . . .    BUILTIN          16 
      2               SECTORLEN. . . . .    LITERALLY
                      SHR. . . . . . . .    BUILTIN          17   18 
     14  003BH    30  SHR3BYTE . . . . .    PROCEDURE PUBLIC STACK=0004H
     29  0004H     2  STRINGADR. . . . .    WORD PARAMETER AUTOMATIC        30   31 
      2               TAB. . . . . . . .    LITERALLY
      4  0000H     2  TEMP . . . . . . .    WORD         5    6 
     15  0000H     2  TEMP1. . . . . . .    BYTE BASED(BYTE3ADR) ARRAY(2)        19 
     15  0002H     1  TEMP2. . . . . . .    BYTE        16   19 
     10  0000H     3  TOTAL. . . . . . .    STRUCTURE BASED(TOTALB)         12 
      9  0006H     2  TOTALB . . . . . .    WORD PARAMETER AUTOMATIC        10   11   12 
      2               TRUE . . . . . . .    LITERALLY        68   77 
      1  0000H        UTILITY. . . . . .    PROCEDURE STACK=0000H
     50  0008H     2  V. . . . . . . . .    WORD PARAMETER AUTOMATIC        51   53   54 
     50  0004H     1  ZEROSUP. . . . . .    BYTE PARAMETER AUTOMATIC        51   56   59 



MODULE INFORMATION:

     CODE AREA SIZE     = 019CH    412D
     CONSTANT AREA SIZE = 0000H      0D
     VARIABLE AREA SIZE = 0006H      6D
     MAXIMUM STACK SIZE = 0020H     32D
     186 LINES READ
     0 PROGRAM ERROR(S)

END OF PL/M-86 COMPILATION
