home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / BDOS / DOSPLSOR.ARK / SETPATH.MAC < prev    next >
Text File  |  1987-01-10  |  4KB  |  188 lines

  1. ;
  2. ; usage: SETPATH pathstring
  3. ;
  4. ; DOS+ utility.  For run-time configuration of DOS+.
  5. ;
  6. ; 1.1    87/01/10 Reduced messages so passworded version is smaller.
  7. ;
  8. @flags    equ    018h;        BDOS offset to flags byte, base page
  9. @path    equ    014h;        BDOS offset to path address
  10. ;
  11. ; DOS+/CPM  calls
  12. tstr    equ    9
  13. cpmver    equ    12
  14. getinfo    equ    210;        e = 0 returns BDOS base address
  15. ;
  16. bdos    equ    5
  17. defdma    equ    080h
  18. ;
  19. cr    equ    0dh
  20. lf    equ    0ah
  21. dol    equ    '$'+80h;    So passes thru wrtstring
  22. ;
  23.     jmp    bgn
  24. ;
  25. ; This message also defines the acceptable words. ']' terminates lists.
  26. hlpmsg:    db    'usage: SETPATH string',cr,lf
  27.     db    '  ex: SETPATH a0b1b2c',dol,cr,lf
  28.     db    'to search A & C on user 0, B & C on users 1 & 2,'
  29.     db    ' C on all users.',cr,lf
  30.     db    '      SETPATH ', dol, dol, '   (resets path)',cr,lf
  31.     db    'Not protected against over-long input strings'
  32.     db    ' (installation dependant)$'
  33. ;
  34. badpth:    db    'Invalid path string$'
  35. badver:    db    'Needs DOS+ 2.4 up$'
  36. nopath:    db    'No path location configured$'
  37. ;
  38. ; Start here
  39. bgn:    lxi    h,0
  40.     dad    sp
  41.     lxi    sp,stack
  42.     push    h
  43.     lda    defdma
  44.     ora    a
  45.     jz    help;        empty command line, help
  46.     mvi    c,cpmver;    Make sure running DOS+ 2.4 up
  47.     call    bdos
  48.     lxi    d,badver
  49.     inr    h
  50.     dcr    h
  51.     jnz    msgxit;        not MPM etc
  52.     cpi    22h
  53.     jc    msgxit;        < 2.2, cant be compatible mode
  54.     cpi    30h
  55.     jnc    msgxit;        Can't use CPM 3
  56.     cpi    24h
  57.     jnc    bgn2;        ok, 2.4 thru 2.f
  58.     call    getbas;        of DOS+, if running
  59.     mov    a,h;        DOS+ returns base pointer
  60.     ora    a;        CPM returns 0
  61.     jz    msgxit;        not in compatible mode
  62. ;    "    "
  63. ; DOS+ running, check parameters and execute
  64. bgn2:    call    getbas;        of DOS+
  65.     mvi    l,@path;    point to configured path location
  66.     mov    a,m
  67.     inx    h
  68.     mov    h,m
  69.     mov    l,a
  70.     ora    h
  71.     lxi    d,nopath
  72.     jz    msgxit;        no path configured
  73.     xchg;            path pointer to de
  74.     lxi    h,defdma
  75.     mov    a,m;        length of command line
  76.     inx    h
  77.     push    h
  78.     add    l
  79.     mov    l,a
  80.     adc    h
  81.     sub    l
  82.     mov    h,a;        point to end of string
  83.     mvi    m,0;        and mark it
  84.     pop    h;        
  85.     call    skipbk;        initial empty line leaves old path
  86.     jc    exit;        end of input string
  87.     mov    a,m
  88.     cpi    '?'
  89.     jz    help
  90. bgn3:    cpi    '$'
  91.     jz    bgn4;        '$' ok, used to clear path only
  92.     ani    05fh;        upshift to get drive idd
  93.     cpi    'A'
  94.     jc    badstg
  95.     cpi    'P'+1;        max possible drive
  96.     jnc    badstg
  97. bgn4:    mov    b,a
  98.     inx    h
  99.     mov    a,m
  100.     cpi    '$'
  101.     cnz    getnum
  102.     jc    badstg;        faulty input string
  103.     inx    h
  104.     mov    c,a;        b is drive, c is user
  105.     mov    a,b
  106.     stax    d
  107.     inx    d
  108.     mov    a,c
  109.     stax    d
  110.     inx    d
  111.     xra    a
  112.     stax    d;        tentative line end marker
  113.     mov    a,m
  114.     ora    a
  115.     jnz    bgn3;        get next pair
  116. ;    "    "
  117. ; restore sp and exit
  118. exit:    pop    h
  119.     sphl
  120.     ret    
  121. ;
  122. ; Bad string message and exit
  123. badstg:    lxi    d,badpth
  124.     jmp    msgxit
  125. ;
  126. ; Help message and exit
  127. help:    lxi    d,hlpmsg
  128. ;    "    "
  129. ; Message de^ to console
  130. msgxit:    mvi    c,tstr
  131.     call    bdos
  132.     jmp    exit
  133. ;
  134. ; skip blanks, string hl^
  135. skipbk:    mov    a,m
  136.     cpi    ' '
  137.     rnz;            carry for control, end marker
  138.     inx    h
  139.     jmp    skipbk
  140. ;
  141. ; get number (1 or 2 decimal digits) from input string hl^
  142. ; exit with hl pointing to last digit.  Cy for invalid number
  143. getnum:    mov    a,m
  144.     call    qnum;        exit error if non-digit
  145.     rc
  146.     ani    0fh
  147.     mov    c,a
  148.     inx    h
  149.     mov    a,m;        possible 2nd digit
  150.     call    qnum
  151.     dcx    h;        in case 1 digit only
  152.     cmc
  153.     mov    a,c
  154.     rnc    ;        no 2nd digit
  155.     add    a
  156.     add    a;        4*
  157.     add    c;        5*
  158.     add    a;        10*
  159.     mov    c,a
  160.     inx    h
  161.     mov    a,m
  162.     ani    0fh
  163.     add    c
  164.     ret
  165. ;
  166. ; check (a) is decimal digit (ascii).  Carry if not
  167. ; f
  168. qnum:    cpi    '0'
  169.     rc
  170.     cpi    '9'+1
  171.     cmc
  172.     ret
  173. ;
  174. ; Get BDOS base page, on DOS+.  CPM returns 0
  175. ; a,f,h,l
  176. getbas:    push    b
  177.     push    d
  178.     mvi    c,getinfo
  179.     mvi    e,0
  180.     call    bdos;        get BDOS base page
  181.     pop    d
  182.     pop    b
  183.     ret
  184.     
  185.     ds    48
  186. stack:
  187.     end
  188. ░)