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 / ENTERPRS / CPM / UTILS / S / Z80DOS10.ARC / DATEDEMO.Z80 < prev    next >
Text File  |  1989-09-15  |  5KB  |  252 lines

  1. ;
  2. ; Program:    DATEDEMO
  3. ; Author:    Carson Wilson
  4. ; Date:     September 19, 1987
  5. ; Version:    1.0
  6. ; Assembly:    Z80ASM, PDLN, SYSLIB.REL, DATEHL.REL
  7. ;
  8. ; Purpose:    Example program using Z80DOS and DATEHL module.
  9. ;
  10. ; Comments:    Produces a non-alphabetized listing of matching filenames
  11. ;          and their Z80DOS time stamps on console.
  12. ;
  13. ; Usage:
  14. ;        DATEDEMO /            display help (both versions)
  15. ;
  16. ;        DATEDEMO [d:][afn]        non-ZCPR version
  17. ;        DATEDEMO [du: or dir:][afn]    ZCPR version
  18.  
  19.  
  20. no    equ    0
  21. yes    equ    not no
  22. Z80ASM    equ    no        ; Assemble with Z80ASM
  23. tab    equ    09h
  24. cr    equ    0dh
  25. lf    equ    0ah
  26. fcb1    equ    05ch
  27. dskbuf    equ    80h
  28. bdos    equ    5
  29. sfirst    equ    17
  30. snext    equ    18
  31. zuser    equ    069h    ; ZCPR location
  32. getstp    equ    54    ; Z80DOS call
  33. vers    equ    10
  34.  
  35.     .request syslib,datehl        ; Linker request for PDLN.COM
  36.  
  37.     external datehl            ; DATEHL module
  38.     external pa2hc,print,crlf,cout    ; SYSLIB routines
  39.     external pfn1,sua,cin,condin    ; SYSLIB routines
  40.  
  41.      if Z80ASM        ; Z80ASM pseudo-op
  42.     .accept    'Assemble for ZCPR ("yes" or "no"): ',ZCPR
  43.      else
  44. ZCPR    equ    no        ; Assemble for ZCPR
  45.      endif
  46. ;
  47. ; Begin
  48. ;
  49.      if ZCPR
  50.     ld    a,(zuser)    ; Log to ZCPR user #
  51.     call    sua
  52.      endif
  53. ;
  54. ; Test for help command
  55. ;
  56.     ld    a,(dskbuf)    ; # chars on command line
  57.     cp    1        ; One character?
  58.     jr    nz,nohelp    ; No
  59.     ld    a,(fcb1+1)    ; Yes
  60.     cp    '/'        ; Help command?
  61.     jr    nz,nohelp    ; No
  62.     call    print        ; Display help and exit
  63.     db    'DATEDEMO Version '
  64.     db    vers / 10 + '0','.', vers mod 10 + '0'
  65.     db    ' for Z80DOS',cr,lf
  66.     db    ' Syntax:',cr,lf
  67.      if ZCPR
  68.     db    tab,'DATEDEMO [du: or dir:][afn]',cr,lf,0
  69.      else
  70.     db    tab,'DATEDEMO [d:][afn]',cr,lf,0
  71.      endif    ; ZCPR
  72.     ret            ; Return to user
  73. ;
  74. ; Begin output
  75. ;
  76. nohelp:
  77.     ld    a,(fcb1+1)
  78.     cp    ' '        ; Filespec given?
  79.     jr    nz,test
  80.     ld    hl,fcb1+1    ; No, match all files
  81.     ld    a,'?'
  82.     ld    b,11
  83. fill:                ; Fill with '?'
  84.     ld    (hl),a
  85.     inc    hl
  86.     djnz    fill
  87. ;
  88. ; Search for match
  89. ;
  90. test:
  91.     ld    de,fcb1
  92.     ld    c,sfirst
  93.     call    bdos
  94.     cp    0ffh        ; No matches
  95.     jp    nz,found
  96.     call    print
  97.     db    'DATEDEMO: no matching files.',cr,lf,0
  98.     ret
  99. ;
  100. ; Matches found - print header:
  101. ;
  102. found:
  103.     call    print
  104.     db    tab,tab,'----Access----   ----Update----   -Create-'
  105.     db    cr,lf,0
  106.  
  107.     call    process        ; Display name and stamp of first match
  108. ;
  109. ; Search for next match
  110. ;
  111. next:
  112.     call    condin        ; Test pause
  113.     call    nz,cin        ; Get input to restart
  114.     ld    de,fcb1
  115.     ld    c,snext
  116.     call    bdos
  117.     cp    0ffh        ; No more matches
  118.     ret    z
  119.     call    process        ; Display name and stamp of next match
  120.     jr    next
  121. ;
  122. ; Process - Get date/time stamp, display filename and stamp
  123. ;
  124. process:
  125.     push    af        ; save dir. return code from search
  126. ;
  127. ; Store time stamp
  128. ;
  129.     ld    c,getstp    ; Z80DOS call
  130.     call    bdos        ; HL --> stamp
  131.     ld    b,10        ; copy 10 byte stamp
  132.     ld    de,cdate
  133.     ldir            ; to cdate, udate, utime, adate, atime
  134. ;
  135. ; Print file name and stamp
  136. ;
  137.     pop    af        ; Get return code
  138.     add    a,a
  139.     add    a,a
  140.     add    a,a
  141.     add    a,a
  142.     add    a,a
  143.     add    81h        ; Point to matching filename in DMA
  144.     ld    e,a
  145.     ld    d,0
  146.     call    pfn1        ; SYSLIB print file name pointed to by DE
  147.     call    ptab
  148.     call    printstp    ; Display stamp
  149.     call    crlf
  150.     ret
  151. ;
  152. ; PrintStp - Display file's time stamp from buffers
  153. ;
  154. PrintStp:
  155.     ld    hl,(adate)    ; Print last access date
  156.     call    datedisp
  157.     call    space
  158.  
  159.     ld    hl,(atime)    ; ..and time
  160.     call    timedisp
  161.     call    space
  162.     call    space
  163.     call    space
  164.  
  165.     ld    hl,(udate)    ; Print update date
  166.     call    datedisp
  167.     call    space
  168.  
  169.     ld    hl,(utime)    ; ..and time
  170.     call    timedisp
  171.     call    space
  172.     call    space
  173.     call    space
  174.  
  175.     ld    hl,(cdate)    ; Print create date
  176.     call    datedisp
  177.     ret
  178. ;
  179. ; DateDisp - Display mm-dd-yy on console
  180. ;
  181. ;    Inputs: HL = Days since Dec. 31, 1977 in hex.
  182. ;
  183. DateDisp:
  184.     call    datehl        ; --> H = BCD year, L = BCD month,
  185.                 ; ..A = BCD day
  186.     ld    b,a        ; Save day
  187.  
  188.     ld    a,l        ; Get month
  189.     call    pa2hc        ; Print 2 digit month
  190.     call    dash
  191.  
  192.     ld    a,b        ; Get day
  193.     call    pa2hc        ; Print 2 digit day
  194.     call    dash
  195.  
  196.     ld    a,h        ; Get year
  197.     call    pa2hc        ; Print 2 digit year
  198.     ret            ; Done with date
  199. ;
  200. ; TimeDisp - Display hh:mm on console
  201. ;
  202. ;    Inputs: H = minutes in BCD, L = hours in BCD
  203. ;
  204. TimeDisp:
  205.     ld    a,l
  206.     call    pa2hc        ; Print 2 digit hour
  207.  
  208.     ld    a,':'        ; Print ':'
  209.     call    cout
  210.  
  211.     ld    a,h
  212.     call    pa2hc        ; Print 2 digit minute
  213.     ret            ; Done with time
  214. ;
  215. ptab:                ; Print a tab on console
  216.     ld    a,tab
  217.     call    cout
  218.     ret
  219. ;
  220. space:                ; Print a space on console
  221.     ld    a,' '
  222.     call    cout
  223.     ret
  224. ;
  225. dash:                ; Print a dash on console
  226.     ld    a,'-'
  227.     call    cout
  228.     ret
  229.  
  230. ; -----------------------
  231.  
  232. ;    Data Area
  233.  
  234. ; -----------------------
  235.  
  236.     dseg            ; Or else we collide with code segment
  237. cdate:
  238.     ds    2        ; Create date
  239. udate:
  240.     ds    2        ; Update date
  241. utime:
  242.     ds    2        ; Update time
  243. adate:
  244.     ds    2        ; Last access date
  245. atime:
  246.     ds    2        ; Last access time
  247. ;
  248.     end
  249.  
  250. ; END of DATEDEMO.Z80
  251.  
  252.