home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / utils / sysutl / log10.lbr / LOG.AZM / LOG.ASM
Assembly Source File  |  1987-02-27  |  5KB  |  166 lines

  1. TITLE ' ';
  2. ;
  3. ; PROGRAM LOG
  4. ;
  5. ; This is LOG.ASM for any Z80 based CP/M system.
  6. ; It was authored by ANDY HOFFMAN and is 
  7. ; copyright (c) 1986 by ABC Software co.
  8. ;                       Box 804
  9. ;                       New Westminster
  10. ;                       B.C. Canada
  11. ;                       V3L 4Z8
  12. ;
  13. ;  this program is FREE to all who desire to use it
  14. ;  for non monitary gains. You are free to give it
  15. ;  away to whomever you like whenever you like and
  16. ;  may be used by anyone provided there is no profit
  17. ;  gains of any type at all involved.
  18. ;
  19. ;  It is designed to be assembled with  UVMAC
  20. ;  although it can easily be converted to M80
  21. ;  or any other kind of Z80 assmebler.
  22. ;
  23. ;  the primary purpose of doing this program was
  24. ;  to have a ZCPR3 style drive/user program that
  25. ;  will log a user and a drive from a single
  26. ;  command line, to use this program first
  27. ;  assemble with UVMAC, and then LOG du: will
  28. ;  log the desired drive user. it has its own
  29. ;  error checking and will work with BYE in
  30. ;  a RCP/M enviroment with no problem as BYE
  31. ;  does its own drive/user checking to see
  32. ;  that the logged drive/user is valid!! 
  33. ;
  34.     ORG    100H        ; 
  35.     JP    START        ; begin
  36. ;
  37. CR    EQU    13        ; carriage return
  38. LF    EQU    10        ; linefeed
  39. SPACE    EQU    020H        ; spacebar
  40. BDOS    EQU    5        ; bdos address
  41. PRNT    EQU    9        ; bdos function 9
  42. BUFF    EQU    081H        ; CCP command tail buffer
  43. MAXDRV    EQU    3        ; maximum drives
  44. ;
  45. ;
  46. ;
  47. START:    LD    HL,0        ; PROGRAM STARTS HERE
  48.     ADD    HL,SP        ; 
  49.     LD    (OLDSTK),HL    ; save the old stack
  50.     LD    SP,STACK    ; get the new stack
  51.     LD    HL,BUFF        ; get the ccp command tail into HL
  52.     LD    A,(HL)        ; get the charactor into A
  53.     CP    SPACE        ; is it a space?
  54.     JR    Z,COOL        ; ya branch to COOL
  55. ;    JP    ERROR1        ; remove ; if you want to display error
  56.     LD    A,0        ; 
  57.     LD    (USER),A    ; set up user 0
  58.     LD    (DRIVE),A    ; and drive A
  59.     JP    SETDV2        ; go do it and exit
  60. ;
  61. COOL:    CALL    GETCHR        ; get the next charactor into A
  62.     SUB    041H        ; convert it
  63.     CP    MAXDRV        ; is it greater then maxdriv
  64.     JP    NC,ERROR2    ; ya say so and exit 
  65.     LD    (DRIVE),A    ; no store it in DRIVE
  66.     CALL    GETCHR        ; get the next charactor
  67.     CP    ':'        ; is that all?
  68.     JR    Z,SETDV1    ; yup set the drive and exit
  69.     SUB    030H        ; make it binary
  70.     CP    0AH        ; is it anything but a number?
  71.     JP    NC,ERROR2    ; ya so exit
  72.     EX    AF,AF'        ; exchange accumilator and flag with alternate
  73.     CALL    GETCHR        ; get the next charactor into A
  74.     CP    ':'        ; is that all?
  75.     CALL    NZ,VALID    ; nope so check if valid
  76.     DEC    HL        ; put HL back to where it was
  77.     CALL    GETCHR        ; so we can get the next charactor
  78.     CP    ':'        ; is that all?
  79.     JP    Z,SETDV3    ; yup so branch
  80.     SUB    030H        ; make it binary
  81.     CP    6        ; is it greater then a 5
  82.     JP    NC,ERROR2    ; yup so say so and exit
  83.     LD    B,A        ; store it in B
  84.     LD    A,0AH        ; we know it is > 10 so put 10 in A 
  85.     ADD    A,B        ; add what we saved into B
  86.     LD    (USER),A    ; store the new user #
  87.     JP    SETDV2        ; set drive/user and exit
  88. ;
  89. SETDV3:    EX    AF,AF'        ; get the old A
  90.     LD    (USER),A    ; store the new user #
  91.     JR    SETDV2        ; set the drive/user and exit
  92. ;
  93. VALID:    EX    AF,AF'        ; get the old A
  94.     CP    2        ; is it > 2
  95.     JP    NC,ERROR2    ; yup so exit
  96.     EX    AF,AF'        ; put back A
  97.     RET
  98. ;
  99. GETCHR:    INC    HL        ; increment HL for next charactor
  100.     LD    A,(HL)        ; get the charactor
  101.     RET            ; return
  102. ;
  103. SETDV1:    LD    A,(04)        ; get the old drive/user
  104.     RLCA            ; make the low nibble the high nibble
  105.     RLCA    
  106.     RLCA
  107.     RLCA
  108.     AND    0FH        ; 0 off the high nibble
  109.     RLCA            ; now switch it back
  110.     RLCA
  111.     RLCA
  112.     RLCA
  113.     EX    AF,AF'        ; swap accumilator
  114.     LD    A,(DRIVE)    ; get the drive number
  115.     LD    C,A        ; put it in C
  116.     EX    AF,AF'        ; swap em back
  117.     ADD    A,C        ; add the drive # to A
  118.     LD    (04),A        ; put the new drive/user byte in
  119.     JP    0        ; warm boot so CCP see's new drive
  120. ;
  121. SETDV2:    LD    A,(USER)    ; get the new user #
  122.     RLCA            ; make it the high nibble
  123.     RLCA            
  124.     RLCA
  125.     RLCA
  126.     EX    AF,AF'        ; exchange Acummilator
  127.     LD    A,(DRIVE)    ; get the drive
  128.     LD    C,A        ; store it in C
  129.     EX    AF,AF'        ; exchange back
  130.     ADD    A,C        ; add it to A
  131.     LD    (04),A        ; store the new drive/user
  132.     JP    0        ; warm boot so CCP see's new drive/user
  133. ;
  134. ERROR1:    LD    DE,ERMSG1    ; get the address of message
  135.     CALL    PRINT        ; print it
  136.     JR    FINISH        ; branch to finish
  137. ;
  138. ERROR2:    LD    DE,ERMSG2    ; get the address of message
  139.     CALL    PRINT        ; print it
  140.     JR    FINISH        ; branch to finish
  141. ;
  142. PRINT:    LD    C,PRNT        ; BDOS function 9 print string till $
  143.     CALL    BDOS        ;  
  144.     RET            ; return
  145. ;
  146. FINISH:    LD    HL,(OLDSTK)    ; get the old stack
  147.     LD    SP,HL        ; put it in
  148.     RET            ; return to exit to CCP
  149. ;
  150. OLDSTK    DW    0        ; storage for the old stack
  151. DRIVE:    DB    0        ; storage for the new drive
  152. USER:    DB    0        ; storage for the new user
  153. ERMSG1:    DB    CR,LF,'LOG v1.0                            ABC Software co  1986'
  154.     DB    CR,LF,CR,LF,CR,LF,'Usage -  LOG du:',CR,LF,CR,LF
  155.     DB    'Where d=Desired Drive letter and u=Desired user #',CR,LF
  156.     DB    CR,LF,'for example to log drive B: and user 7 type "LOG B7:"',CR,LF
  157.     DB    '$'
  158. ;
  159. ERMSG2:    DB    CR,LF,'LOG v1.0                            ABC Software co 1986'
  160.     DB    7,7,7,7,7,7,7,7
  161.     DB    CR,LF,CR,LF,'DRIVE/USER ERROR!!, Type LOG by itself for more info',CR,LF
  162.     DB    '$'
  163. STPACE:    DS    128        ; make room for
  164. STACK:    DW    0        ; the new stack
  165.     END
  166.