home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / kaypro / dskdrv13.lbr / ENQUIRE.ZQ0 / ENQUIRE.Z80
Text File  |  1985-06-05  |  2KB  |  145 lines

  1.     title    'ENQUIRE RSX residency (85/01/26)'
  2. ;
  3. ; Usage: ENQURE nn   (where nn is RSX number. prints response in a)
  4. ; quicky test mechanism for RSX's.  Can be very DANGEROUS.
  5. ; Ex:  "ENQUIRE 1"   will show hex value of next key struck.
  6. ;      "ENQUIRE 64 FFFF" will inactivate RSX #100
  7. ;      "ENQUIRE 63" will show if RSX #99 is presently active
  8. ;      "ENQUIRE C" will show CPM version number.
  9. ;      "ENQUIRE 2 45" will print hex 45, i.e "E"
  10. ;
  11. bdos    equ    5
  12. cout    equ    2
  13. pstrg    equ    9
  14. fcb1    equ    05ch;        find rsx # here
  15. fcb2    equ    06ch;        find argument here, if any
  16. ;
  17. cr    equ    13
  18. lf    equ    10
  19. ;
  20.     ld    hl,0
  21.     add    hl,sp
  22.     ld    sp,stack
  23.     push    hl
  24.     ld    hl,fcb1
  25.     call    getnum
  26.     jp    c,help;        invalid enquiry
  27.     ld    c,e
  28.     ld    hl,fcb2
  29.     call    getnum;        ignore failure, use 0 default
  30.     call    bdos
  31.     or    a
  32.     jp    nz,live
  33.     ld    de,none
  34. exitm:    call    tstr
  35. exit:    pop    hl
  36.     ld    sp,hl
  37.     ret
  38. ;
  39. hlpmsg:    db    'Usage: ENQUIRE nn [arg]',cr,lf
  40.     db    '  nn is bdos call #, values in hex',cr,lf
  41.     db    '  DANGEROUS - can execute any BDOS function$'
  42. none:    db    'No such RSX now active (or function returns 0)$'
  43. ;
  44. help:    ld    de,hlpmsg
  45.     jp    exitm
  46. ;
  47. ; output string de
  48. tstr:    ld    c,pstrg
  49.     jp    bdos
  50. ;
  51. ; getnumber from hl^ up. 1st byte should be zero.  Carry if invalid
  52. ; or initial space.
  53. getnum:    ld    de,0
  54.     ld    a,(hl)
  55.     inc    hl
  56.     or    a
  57.     stc
  58.     ret    nz
  59.     ld    a,(hl)
  60.     call    qhex
  61.     ret    c;        no 1st digit
  62.     and    0fh
  63.     ld    e,a
  64. gnum1:    inc    hl
  65.     ld    a,(hl)
  66.     call    qhex
  67.     jp    c,gnumx
  68.     and    0fh
  69.     ex    de,hl
  70.     add    hl,hl
  71.     add    hl,hl
  72.     add    hl,hl
  73.     add    hl,hl
  74.     add    l
  75.     ld    l,a
  76.     ex    de,hl
  77.     jp    gnum1
  78. gnumx:    cp    ' '
  79.     ret    z
  80.     scf
  81.     ret
  82. ;
  83. ; carry for non-hex char, else correct A thru F
  84. qhex    cp    '0'
  85.     ret    c
  86.     cp    'F'+1
  87.     ccf
  88.     ret    c
  89.     cp    '9'+1
  90.     ccf
  91.     ret    nc;    '0'..'9'
  92.     cp    'A'
  93.     ret    c;    '9'+1 thru 'A'-1
  94.     sub    7;    convert
  95.     ret
  96. ;
  97. livmsg:    db    cr,lf,'live RSX, response(a, hl)=$'
  98. ;
  99. live:    push    af
  100.     push    hl
  101.     ld    de,livmsg
  102.     call    tstr
  103.     pop    hl
  104.     pop    af
  105.     call    t2hx
  106.     ld    a,' '
  107.     call    couta
  108.     call    t4hx
  109.     jp    exit
  110. ;
  111. t4hx:    ld    a,h
  112.     call    t2hx
  113.     ld    a,l
  114. ;    "    "
  115. t2hx:    push    af
  116.     rrca
  117.     rrca
  118.     rrca
  119.     rrca
  120.     and    0fh
  121.     call    t1hx
  122.     pop    af
  123. ;    "    "
  124. t1hx:    and    0fh
  125.     add    a,090h
  126.     daa
  127.     adc    a,040h
  128.     daa
  129. ;    "    "
  130. couta:    push    bc
  131.     push    de
  132.     push    hl
  133.     ld    e,a
  134.     ld    c,cout
  135.     call    bdos
  136.     pop    hl
  137.     pop    de
  138.     pop    bc
  139.     ret
  140. ;
  141.     ds    32
  142. stack:    ds    0
  143. ;
  144.     end
  145.