home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / sysutl / xuser.lbr / XUSER.AZM / XUSER.ASM
Encoding:
Assembly Source File  |  1987-01-15  |  3.1 KB  |  139 lines

  1. ;
  2. ;    program XUSER.ASM
  3. ;
  4. ;       John Evancie   7/3/85
  5. ;
  6. ;    to extend the accessibility of CPM's user areas
  7. ;
  8. ;    User types: XUSER xx
  9. ;    and program switches into the selected user
  10. ;       area, or into user area 0 if no argument is
  11. ;       supplied. Before BDOS is called, the program
  12. ;       checks that the argument is less than 32.
  13. ;
  14. ;    After the area is selected, the program uses
  15. ;    BDOS to get it back, and display it at the
  16. ;    console. In this way, both uses of BDOS function
  17. ;    call #32 are illustrated (even if it is a BIT 
  18. ;       redundant)
  19. ;
  20. ;    It should be noted that this approach allows you
  21. ;    access to user areas 0 - 31, whereas access via
  22. ;    CCP is limited to user areas 0 - 15.
  23. ;
  24. cr    equ    0dh        ;carriage return
  25. lf    equ    0ah        ;line feed
  26. uflag    equ    0ffh        ;"get user" bdos value
  27. pbuff    equ    09h        ;"print string" bdos code
  28. getus    equ    020h        ;"get/set user" bdos code
  29. fcb     equ     05ch
  30. bdos    equ    05h
  31. tpa     equ     0100h
  32. ;
  33.     org     tpa
  34. ;
  35.     lxi    D,mess0        ;startup message
  36.     call    print
  37. ;
  38.     lda    fcb+1        ;check the command line
  39.     cpi    020h        ;is it blank?
  40.     jnz    begin        ;if not, take it apart below
  41. ;
  42.     mvi    E,0        ;if so, assume user wants user area 0
  43.     jmp    ok        ;and do it!
  44. ;
  45. begin:    lda    fcb+2        ;is the second character of the
  46.     cpi    020h        ;command line blank?
  47.     jz    single        ;if so, process the first one
  48. ;
  49.     sui    030h        ;if not, convert the ASCII char to hex
  50.     mov    D,A        ;and stash the result in DE
  51. ;
  52.     lda    fcb+1        ;look at the first character now
  53.     cpi    020h        ;is it blank?
  54.     jnz    cnvt1        ;if not, do further checking
  55.     jmp    doit        ;if so, assume user made a typo and proceed
  56. ;
  57. cnvt1:    sui    030h        ;convert to hex
  58.     mov    B,A        ;stash in B
  59.     add    B
  60.     add    B
  61.     add    B
  62.     add    B
  63.     add    B        ;lazy mans multiply by 10
  64.     add    B
  65.     add    B
  66.     add    B
  67.     add    B
  68.     add    D        ;and add back in the ones digit
  69.     mov    E,A        ;and store result in E
  70.     jmp    doit        ;you are now set up to make the switch
  71. ;
  72. single:    lda    fcb+1        ;grab the first and only digit
  73.     sui    030h        ;convert to hex
  74.     mov    E,A        ;move it into position for BDOS call
  75. ;
  76. doit:    mov    A,E        ;get choice back in A
  77.     cpi    020h        ;is it less that 32?
  78.     jc    ok        ;if so, do it finally
  79.     jmp    endit        ;if not, abort
  80. ;
  81. ok:    mvi    C,getus        ;put switch user code in C
  82.     mvi    D,uflag        ;set D to switch code (instead of E)
  83.     call    bdos        ;and do it
  84. ;
  85.     mvi    a,0h
  86.     lxi    d,mess2
  87.     call    print
  88.     mvi    c,getus        ;now get ready to read back the user area
  89.     mvi    d,0        ;
  90.     mvi    e,uflag        ;E needs the switch code in order to read it back
  91.     call     bdos
  92. ;
  93.     call    finis
  94.     ret
  95.  
  96. finis:    call    cnvrt
  97.     mvi    c,2
  98.     mov    e,h
  99.     push    b
  100.     push    h
  101.     call    bdos
  102.     pop    h
  103.     pop    b
  104.     mov    e,l
  105.     call    bdos
  106.     ret
  107. cnvrt:    push    psw
  108.     ani    00001111b
  109.     call    dovrt
  110.     mov    l,a
  111.     pop    psw
  112.     rrc
  113.     rrc
  114.     rrc
  115.     rrc
  116.     ani    00001111b
  117.     call    dovrt
  118.     mov    h,a
  119.     ret
  120. dovrt:    cpi    0ah
  121.     jc    num1
  122.     adi    037h
  123.     ret
  124. num1:    adi    030h
  125.     ret
  126. endit:    lxi    D,mess1        ;point to error message
  127.     call    print        ;print it
  128.     ret
  129. print:    mvi    c,pbuff
  130.     call    bdos
  131.     ret
  132. ;
  133. mess0:    db    'XUSER.COM   V 1.0  7/3/85',cr,lf,'$'
  134. mess1:    db    'Invalid area...',cr,lf
  135.     db    '(valid areas are 0 - 31 inclusive)',cr,lf,lf,'$'
  136. mess2:    db    'User Area selected: $'
  137. ;
  138. end
  139.