home *** CD-ROM | disk | FTP | other *** search
/ Frostbyte's 1980s DOS Shareware Collection / floppyshareware.zip / floppyshareware / APOG / ASM2.ZIP / DC.ASM < prev    next >
Encoding:
Assembly Source File  |  1988-11-24  |  9.5 KB  |  509 lines

  1. page ,132
  2. title dc ( dircomp - compare 2 dirs ) as of 01/21/87 - 10:45 pm
  3. ;*-------------------------------------------------
  4. ;
  5. ;        dircomp.asm
  6. ;        lists two directories side by side
  7. ;
  8. ;*-------------------------------------------------
  9. codeseg  segment
  10. ;
  11.          assume  cs:codeseg,ds:codeseg,es:codeseg,ss:codeseg
  12. ;
  13.          org   128
  14. ;
  15. param    label byte
  16. ;
  17.          org   256
  18. ;
  19. entry:   jmp   begin
  20. ;
  21. ;*-------------------------------------------------------
  22. ;   most of the data is here; but some is at the end
  23. ;*-------------------------------------------------------
  24. ;
  25. synmsg   db    'syntax: dc filespec filespec$'
  26. dosmsg   db    'dc: Needs dos 2.0 +   $'
  27. bfnmsg   db    'dc: Bad file name     $'
  28. tmfmsg   db    'dc: Too many files    $'
  29. nemmsg   db    'dc: Not enough memory $'
  30. ;
  31. tosm     db    'name.... ext    size   date....  time   '
  32.          db    'name.... ext    size   date....  time   ',13,10,'$'
  33. ;
  34. coqm     db    13,10,'===> press enter to continue ! $'
  35. ;
  36. delim    db    9,' ,;='
  37. ;
  38. filist1  dd    0,0
  39. filist2  dd    0,0
  40. filcnt1  dw    0
  41. filcnt2  dw    0
  42. ;
  43. append   db    '\*.*',0
  44. ;
  45. slc      db    0
  46. ;
  47. ;   check dos version
  48. ;
  49. begin:   mov   ah,48
  50.          int   33
  51.          cmp   al,2
  52.          jae   dosok
  53.          lea   dx,dosmsg
  54. errexit:
  55.          mov   ah,9
  56.          int   33
  57.          int   32
  58. ;
  59. ;   parse command line to get filespecs
  60. ;
  61. dosok:
  62.          cld
  63.          lea   si,param
  64.          lodsb
  65.          mov   bl,al
  66.          sub   bh,bh
  67.          mov   word ptr [si + bx],0d20h
  68.          lea   di,filspec1
  69.          call  gfs
  70.          lea   di,filspec2
  71.          call  gfs
  72. ;
  73. ;   de- allocate rest of memory
  74. ;
  75.          lea   dx,nemmsg
  76.          lea   sp,stacktop
  77.          mov   bx,sp
  78.          add   bx,15
  79.          mov   cl,4
  80.          shr   bx,cl
  81.          mov   ah,74
  82.          int   33
  83.          jc    errexit
  84. ;
  85. ;   find files from filespecs
  86. ;
  87.          lea   dx,dtabfr
  88.          mov   ah,26
  89.          int   33
  90. ;
  91.          lea   dx,filspec1
  92.          call  gfas
  93.          mov   word ptr [filist1 + 2],ax
  94.          mov   [filcnt1],cx
  95. ;
  96.          lea   dx,filspec2
  97.          call  gfas
  98.          mov   word ptr [filist2 + 2],ax
  99.          mov   [filcnt2],cx
  100.          call  tos
  101. ;
  102. ;   now display on screen
  103. ;
  104. ndos:
  105.          lea   di,dspstr
  106.          mov   al,32
  107.          cmp   [filcnt1],0
  108.          jz    fcd
  109.          cmp   [filcnt2],0
  110.          jz    lo1
  111.          push  si
  112.          push  di
  113.          push  ds
  114.          push  es
  115.          les   di,[filist2]
  116.          lds   si,[filist1]
  117.          mov   cx,12
  118.          repz  cmpsb
  119.          pop   es
  120.          pop   ds
  121.          pop   di
  122.          pop   si
  123.          jb    lo1
  124.          ja    lo2
  125.          call  lf1
  126.          stosb
  127.          jmp   dosec
  128. ;
  129. ;  first column done
  130. ;
  131. fcd:
  132.          cmp   [filcnt2],0
  133.          jz    alldone
  134. ;
  135. ;  list only 2
  136. ;
  137. lo2:
  138.          mov   cx,40
  139.          rep   stosb
  140. ;
  141. ;  do second
  142. ;
  143. dosec:
  144.          call  lf2
  145.          jmp   wcl
  146. ;
  147. ;  list only 1
  148. ;
  149. lo1:
  150.          call  lf1
  151.          mov   cx,40
  152.          rep   stosb
  153. ;
  154. ;   write cr, lf
  155. ;
  156. wcl:
  157.          mov   ax,0a0dh
  158.          stosw
  159. ;
  160. ;   spill out
  161. ;
  162. so:
  163.          lea   dx,dspstr
  164.          mov   cx,81
  165.          mov   bx,1
  166.          mov   ah,64
  167.          int   33
  168.          inc   slc
  169.          cmp   slc,20
  170.          jb    jndos
  171.          call  scoqm
  172.          call  tos
  173. jndos:
  174.          jmp   ndos
  175. ;
  176. alldone:
  177.          int   32
  178. ;*-------------------------------------
  179. ;* get file spec
  180. ;* uses di to point to destination
  181. ;*-------------------------------------
  182. gfs:
  183.          mov   dx,di
  184. search:
  185.          call  scanparm
  186.          je    search
  187. searche:
  188.          stosb
  189.          call  scanparm
  190.          jne   searche
  191.          mov   byte ptr [di],0
  192.          push  si
  193.          mov   si,1+offset append
  194.          mov   cx,4
  195.          cmp   byte ptr [di-1],':'
  196.          jz    appends
  197.          cmp   byte ptr [di-1],'\'
  198.          jz    appends
  199.          mov   ax,4300h
  200.          int   33
  201.          jc    fud
  202.          test  cl,16
  203.          jz    fud
  204.          dec   si
  205.          inc   cx
  206. ;
  207. appends:
  208.          rep   movsb
  209. fud:
  210.          pop   si
  211.          ret
  212. ;
  213. ;   scan parameter
  214. ;
  215. scanparm:
  216.          push  di
  217.          lodsb
  218.          cmp   al,13
  219.          jne   naend
  220.          lea   dx,synmsg
  221.          jmp   errexit
  222. naend:
  223.          lea   di,delim
  224.          mov   cx,5
  225.          repne scasb
  226.          pop   di
  227.          ret
  228. ;
  229. ;  get files and sort
  230. ;
  231. gfas:
  232.          push  es
  233.          mov   bx,1000h
  234.          mov   ah,48h
  235.          int   33
  236.          jnc   allok
  237.          mov   ah,48
  238.          int   33
  239. allok:
  240.          mov   cl,4
  241.          shl   bx,cl
  242.          sub   bx,20
  243.          mov   es,ax
  244.          sub   di,di
  245.          sub   bp,bp
  246.          mov   cx,6
  247.          mov   ah,4eh
  248. findfile:
  249.          int   33
  250.          jnc   continue
  251.          cmp   ax,18
  252.          jz    nomofils
  253.          lea   dx,bfnmsg
  254.          jmp   errexit
  255. continue:
  256.          cmp   di,bx
  257.          jb    stillok
  258. tmf:
  259.          lea   dx,tmfmsg
  260.          jmp   errexit
  261. stillok:
  262.          inc   bp
  263.          mov   si,30+offset dtabfr
  264.          mov   cx,12
  265. traname:
  266.          lodsb
  267.          or    al,al
  268.          jz    namedone
  269.          cmp   al,'.'
  270.          jnz   noperiod
  271.          sub   cx,3
  272.          mov   al,32
  273.          rep   stosb
  274.          add   cx,3
  275.          jmp   traname
  276. noperiod:
  277.          stosb
  278.          loop  traname
  279. namedone:
  280.          mov   al,32
  281.          rep   stosb
  282.          mov   si,22+offset dtabfr
  283.          mov   cx,4
  284.          rep   movsw
  285.          mov   ah,4fh
  286.          jmp   findfile
  287. nomofils:
  288.          mov   bx,di
  289.          add   bx,15
  290.          mov   cl,4
  291.          shr   bx,cl
  292.          mov   ah,4ah
  293.          int   33
  294. ;
  295. ;*   sort files
  296. ;
  297.          push  ds
  298.          push  es
  299.          pop   ds
  300.          sub   di,di
  301.          mov   cx,bp
  302.          jcxz  sad
  303.          dec   cx
  304.          jcxz  sad
  305. sortlp1:
  306.          push  cx
  307.          mov   si,di
  308. sortlp2:
  309.          add   si,20
  310.          push  cx
  311.          push  si
  312.          push  di
  313.          mov   cx,20
  314.          repz  cmpsb
  315.          jae   nosw
  316.          pop   di
  317.          pop   si
  318.          push  si
  319.          push  di
  320.          mov   cx,20
  321. swloop:
  322.          mov   al,es:[di]
  323.          movsb
  324.          mov   ds:[si-1],al
  325.          loop  swloop
  326. nosw:
  327.          pop   di
  328.          pop   si
  329.          pop   cx
  330.          loop  sortlp2
  331.          pop   cx
  332.          add   di,20
  333.          loop  sortlp1
  334. sad:
  335.          pop   ds
  336.          mov   ax,es
  337.          pop   es
  338.          mov   cx,bp
  339.          ret
  340. ;
  341. ;*   list files on screen
  342. ;
  343. lf1:
  344.          push  ds
  345.          lds   si,[filist1]
  346.          call  listfile
  347.          pop   ds
  348.          mov   word ptr[filist1],si
  349.          dec   [filcnt1]
  350.          ret
  351. lf2:
  352.          push  ds
  353.          lds   si,[filist2]
  354.          call  listfile
  355.          pop   ds
  356.          mov   word ptr[filist2],si
  357.          dec   [filcnt2]
  358.          ret
  359. listfile:
  360.          push  ax
  361.          push  si
  362.          push  di
  363.          mov   cx,12
  364.          rep   movsb
  365.          mov   al,32
  366.          mov   cx,27
  367.          rep   stosb
  368.          sub   di,6
  369.          lodsw
  370. ;
  371.          mov   bl,01fh
  372.          mov   bh,'0'
  373.          mov   cl,11
  374.          sub   dl,dl
  375.          mov   dh,':'
  376.          call  datime
  377. ;
  378.          mov   bx,3fh
  379.          mov   cl,5
  380.          mov   dh,32
  381.          call  datime
  382. ;
  383.          sub   di,16
  384.          lodsw
  385. ;
  386.          mov   bl,0fh
  387.          mov   bh,'0'
  388.          mov   cl,5
  389.          mov   dh,'-'
  390.          call  datime
  391. ;
  392.          mov   bx,1fh
  393.          mov   cl,0
  394.          call  datime
  395. ;
  396.          mov   bl,7fh
  397.          mov   cl,9
  398.          mov   dl,80
  399.          mov   dh,32
  400.          call  datime
  401.          sub   di,12
  402.          lodsw
  403.          mov   dx,ax
  404.          lodsw
  405.          mov   bx,10
  406.          std
  407. ascloop:
  408.          mov   cx,dx
  409.          sub   dx,dx
  410.          div   bx
  411.          xchg  ax,cx
  412.          div   bx
  413.          xchg  ax,dx
  414.          add   al,'0'
  415.          stosb
  416.          mov   ax,cx
  417.          or    cx,dx
  418.          jnz   ascloop
  419. ;
  420.          cld
  421.          pop   di
  422.          pop   si
  423.          pop   ax
  424.          add   si,20
  425.          add   di,39
  426.          ret
  427. ;
  428. ;   date and time display
  429. ;
  430. datime:
  431.          push  ax
  432.          push  bx
  433.          push  cx
  434.          push  dx
  435. ;
  436.          shr   ax,cl
  437.          and   al,bl
  438.          add   al,dl
  439.          sub   ah,ah
  440.          mov   bl,10
  441.          div   bl
  442.          add   ax,'00'
  443.          cmp   al,bh
  444.          jnz   lnz
  445.          mov   al,32
  446. lnz:
  447.          stosw
  448.          mov   al,dh
  449.          stosb
  450.          pop   dx
  451.          pop   cx
  452.          pop   bx
  453.          pop   ax
  454.          ret
  455. ;
  456. ; top of screen
  457. ;
  458. tos:
  459.          mov   ah,11
  460.          mov   bh,0
  461.          mov   bl,6
  462.          int   16
  463.          mov   ah,2
  464.          mov   bh,0
  465.          mov   dh,0
  466.          mov   dl,0
  467.          int   16
  468.          mov   ah,9
  469.          mov   al,32
  470.          mov   bh,0
  471.          mov   bl,110
  472.          mov   cx,4000
  473.          int   16
  474.          lea   dx,tosm
  475.          mov   ah,9
  476.          int   33
  477.          mov   slc,0
  478.          ret
  479. ;
  480. ; send cont or quit msg
  481. ;
  482. scoqm:
  483.          lea   dx,coqm
  484.          mov   ah,9
  485.          int   33
  486.          mov   ah,7
  487.          int   33
  488.          ret
  489. ;
  490. ; variable length data stored here
  491. ;
  492.          even
  493. ;
  494. filspec1 label byte
  495. ;
  496. filspec2 equ   filspec1 + 80
  497. ;
  498. dtabfr   equ   filspec2 + 80
  499. ;
  500. dspstr   equ   dtabfr + 43
  501. ;
  502. eod      equ   dspstr + 81
  503. ;
  504. stacktop equ   eod + 512
  505. ;
  506. codeseg  ends
  507. ;
  508.          end   entry
  509.