home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / sigmv017.ark / TAG2.ASM < prev    next >
Encoding:
Assembly Source File  |  1984-04-29  |  5.7 KB  |  269 lines

  1. ;    TAG Version 1.2 - Original by Bruce Ratoff
  2. ;    Latest Revision: 2/17/81 Tim Nicholas
  3. ;
  4. ;    title    'TAG - set or reset and display the "no copy" flag on a file'
  5. ;    by Bruce R. Ratoff - first version 5/18/80
  6. ;    modified 5/19/80 by BRR to display 4 across
  7. ;
  8. ;
  9. ;02/17/81 Added conditional assy to tag either "f1" or
  10. ;      "f2" bit for MP/M v1.1 compatibility.
  11. ;      XMODEM v4.1 now tests both "f1" and "f2" for
  12. ;      tagged files.
  13. ;
  14. ;
  15. ;
  16. ; The purpose of this program is to set or reset the f1' bit on a file.
  17. ; This is used by the XMODEM program to indicate that a file may not
  18. ; be transmitted.  The anticipated purpose is to allow remote use of
  19. ; licensed programs without the danger of their being copied by the
  20. ; remote users.  This should protect the licensee from liabilities
  21. ; associated with dissemination of licensed software.
  22. ;
  23. ; To Set the "no copy" flag on a file, type:
  24. ;    A>TAG d:filename.typ S
  25. ; To Reset the flag (allows copying via XMODEM), type:
  26. ;    A>TAG d:filename.typ R
  27. ;
  28. ; The filename.typ may contain the wildcards "*" and "?".
  29. ;
  30. ;
  31. ;
  32. ; Please forward all comments, suggestions and improvements to:
  33. ;    Bruce R. Ratoff
  34. ;    80 Gill Lane, Apt 1B
  35. ;    Iselin, New Jersey 08830
  36. ;
  37. ;
  38. false    equ    0        ;define false.
  39. true    equ    not false    ;define true
  40. ;
  41. f2tag    equ    true        ;False = f1 tag.
  42.                 ;True  = f2 tag.
  43. ;
  44. ;
  45. bdos    equ    5        ;cp/m entry point
  46. exit    equ    0        ;cp/m exit point
  47. dfcb    equ    5ch        ;cp/m default fcb
  48. dbuff    equ    80h        ;default disk buffer
  49. ;
  50. pchar    equ    2        ;print character function
  51. pmessg    equ    9        ;print message function
  52. seldsk    equ    14        ;select drive function
  53. srchfst    equ    17        ;search for first file match
  54. srchnxt    equ    18        ;search for next file match
  55. attrib    equ    30        ;set file attributes function
  56. ;
  57. ;
  58.     org    100h
  59. begin:
  60.     lhld    bdos+1        ;set up a stack
  61.     sphl            ;at top of tpa
  62. ;
  63. ; Signon message - reports version and attribute used
  64. ;           for tagging "f1" or "f2".
  65. ;
  66.     lxi    d,signon    ;get signon address.
  67.     mvi    c,pmessg    ;print string fuction.
  68.     call    bdos        ;print it.
  69. ;
  70. signon:    db    13,10
  71.     db    'TAG - V1.2  2/17/81'
  72.     db    13,10
  73. ;
  74.     IF    NOT F2TAG
  75.     db    'Uses "f1" for Tag'
  76.     ENDIF
  77. ;
  78.     IF    F2TAG
  79.     db    'Uses "f2" for Tag'
  80.     ENDIF
  81. ;
  82.     db    13,10,13,10,'$'
  83.     lda    dfcb        ;check for specific drive
  84.     dcr    a
  85.     mov    e,a        ;set up for select disk call
  86.     mvi    c,seldsk
  87.     inr    a        ;if no specified drive, skip call
  88.     cnz    bdos
  89.     sub    a        ;now zap out drive spec
  90.     sta    dfcb
  91.     mvi    a,'?'        ;force extent number wild
  92.     sta    dfcb+12
  93.     lda    dfcb+17        ;get "S" or "R" option
  94.     sta    sropt
  95.     cpi    'S'
  96.     jz    okopt
  97.     cpi    'R'
  98.     jz    okopt
  99.     cpi    ' '
  100.     jz    okopt
  101. badopt:
  102.     lxi    d,ilgopt
  103.     mvi    c,pmessg    ;bitch about illegal option
  104.     call    bdos
  105.     jmp    exit
  106. ilgopt:
  107.     db    'Invalid option letter$'
  108. okopt:
  109.     sub    a        ;zero out file count
  110.     sta    filcnt
  111.     lxi    d,dfcb        ;find the first file and get its block map
  112.     mvi    c,srchfst
  113.     call    bdos
  114.     inr    a        ;search successful?
  115.     jnz    gotfile        ;yes, go process rest
  116.     lxi    d,nofile
  117.     mvi    c,pmessg    ;say "no file"
  118.     call    bdos
  119.     jmp    exit
  120. nofile:
  121.     db    'File not found$'
  122. gotfile:
  123.     dcr    a        ;compensate for inr above
  124.     rrc            ;file offset to bits 5 and 6
  125.     rrc
  126.     rrc
  127.     ani    60h
  128.     lxi    h,dbuff        ;point to base of buffer
  129.     mov    c,a
  130.     mvi    b,0
  131.     dad    b        ;index by file offset
  132.     push    h        ;save for the moment
  133.     lxi    b,filetable
  134.     call    filepoint    ;get table pointer to hl
  135.     xchg            ;de now points to place in table
  136.     lda    filcnt
  137.     inr    a
  138.     sta    filcnt        ;bump file count
  139.     pop    h        ;hl points to directory entry
  140.     mvi    b,32
  141.     call    blkmov        ;copy entry into table
  142.     mvi    c,srchnxt    ;search for another entry
  143.     lxi    d,dfcb
  144.     call    bdos
  145.     inr    a        ;returns 0ffh at end of search
  146.     jnz    gotfile        ;got another one...go save it
  147. ;
  148. ; end of directory encountered, now process them
  149. ;
  150. tagfile:
  151.     lxi    b,filetable-32    ;allow for filcnt one greater than desired
  152.     call    filepoint
  153.     push    h
  154.     lxi    d,dfcb        ;copy next name to default fcb
  155.     mvi    b,32
  156.     call    blkmov
  157.     sub    a
  158.     sta    dfcb        ;clear drive number
  159.     lxi    d,-20        ;point back to extent field
  160.     dad    d
  161.     mvi    m,'$'        ;tag end of print here
  162.     pop    d        ;get back pointer to start of entry
  163.     inx    d        ;bump fwd to name
  164.     mvi    c,pmessg
  165.     call    bdos        ;say what we're working on
  166.     lda    dfcb+12        ;get extent #
  167.     push    psw        ;save it
  168.     adi    '0'        ;convert to ascii
  169.     mov    e,a
  170.     mvi    c,pchar
  171.     pop    psw
  172.     ora    a        ;print extent if nonzero
  173.     jnz    pext
  174.     mvi    e,' '
  175. pext:
  176.     call    bdos
  177.     lda    sropt        ;get S or R
  178.     cpi    ' '        ;display only?
  179.     jz    nextfile
  180.     rrc            ;bit 7=0 for R, 1 for S
  181.     ani    80h
  182.     mov    b,a        ;save mask
  183. ;
  184.     IF    NOT F2TAG
  185.     lxi    d,dfcb+1    ;Point to f1.
  186.     ENDIF
  187. ;
  188.     IF    F2TAG
  189.     lxi    d,dfcb+2    ;point to f2
  190.     ENDIF
  191. ;
  192.     ldax    d        ;get it
  193.     ani    7fh        ;strip fx'
  194.     ora    b        ;set bit if option was S
  195.     stax    d        ;put it back
  196.     dcx    d        ;point to start of fcb
  197. ;
  198.     IF    F2TAG
  199.     dcx    d
  200.     ENDIF
  201. ;
  202.     sub    a        ;zap out drive field
  203.     stax    d
  204.     mvi    c,attrib    ;do set attributes call
  205.     call    bdos
  206. nextfile:
  207.     IF    NOT F2TAG
  208.     lda    dfcb+1        ;get f1
  209.     ENDIF
  210. ;
  211.     IF    F2TAG
  212.     lda    dfcb+2        ;get f2
  213.     ENDIF
  214. ;
  215.     rlc            ;isolate fx'
  216.     ani    1
  217.     adi    'R'        ;make an R or S
  218.     sta    donmsg+1
  219.     lxi    d,donmsg
  220.     mvi    c,pmessg    ;print completion message for this file
  221.     call    bdos
  222.     lda    filcnt        ;get file counter
  223.     ani    3        ;multiple of 4?
  224.     lxi    d,crlf
  225.     mvi    c,9        ;if so, time for new line
  226.     cz    bdos
  227.     lxi    h,filcnt    ;point to file counter
  228.     dcr    m        ;count it down
  229.     jz    exit        ;exit if done
  230.     jmp    tagfile        ;and go work on next one
  231. donmsg:
  232.     db    '  ',9,'$'
  233. crlf:
  234.     db    13,10,'$'
  235. ;
  236. ;
  237. ; subroutine to do block moves
  238. blkmov:
  239.     mov    a,m        ;copy byte from m(hl) to m(de)
  240.     stax    d
  241.     inx    h        ;bump pointers
  242.     inx    d
  243.     dcr    b        ;loop for count in b
  244.     jnz    blkmov
  245.     ret
  246. ;
  247. ;
  248. ; subroutine to index bc by file counter
  249. filepoint:
  250.     lhld    filcnt        ;get file counter
  251.     mvi    h,0        ;force hi ord to 0
  252.     dad    h        ;multiply by 32
  253.     dad    h
  254.     dad    h
  255.     dad    h
  256.     dad    h
  257.     dad    b        ;use as index to file table
  258.     ret
  259. ;
  260. ;
  261. ;
  262. ;
  263. filcnt:    ds    1        ;count of files in filetable
  264. sropt:    ds    1        ;storage for S or R option letter
  265. ;
  266. filetable    equ    $    ;start table here, take all avail memory
  267. ;
  268.     end
  269.