home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / TASMSWAN.ZIP / DR.ASM < prev    next >
Assembly Source File  |  1989-07-17  |  2KB  |  110 lines

  1. %TITLE  "Display Disk Directory"
  2.  
  3.     IDEAL
  4.     DOSSEG
  5.     MODEL    small
  6.     STACK    256
  7.  
  8. ;----- Equates
  9. FileName    EQU    30
  10.  
  11.     DATASEG
  12.  
  13. exitCode    db    0
  14. defaultSpec    db    '*.*', 0
  15. DTAseg        dw    ?
  16. DTAofs        dw    ?
  17. dirData        db    43 DUP (?)
  18.  
  19.     CODESEG
  20.  
  21. ;---------- from PARAMS.obj
  22.     EXTRN    GetParams:proc, ParamCount:proc, GetOneParam:proc
  23.  
  24. ;---------- from STRINGS.obj
  25.     EXTRN    StrLength:proc, StrWrite:proc, NewLine:proc
  26.  
  27. Start:
  28.     mov    ax,@data
  29.     mov    es,ax
  30.     call    GetParams
  31.     call    NewLine
  32.     call    ParamCount
  33.     mov    di, offset defaultSpec
  34.     or    dx,dx
  35.     jz    @@10
  36.     xor    cx,cx
  37.     call    GetOneParam
  38. @@10:
  39.     mov    bx, offset Action
  40.     call    DirEngine
  41. Exit:
  42.     call    NewLine
  43.     mov    ah,04Ch
  44.     mov    al,[exitCode]
  45.     int    21h
  46. %NEWPAGE
  47. ;------------------------------------------------------------------------
  48. ; DirEngine - directory scan "engine"
  49. ;------------------------------------------------------------------------
  50. ;    Input:  cs:bx = address of subroutine
  51. ;        ds:di = address of ASCIIZ search string (e.g. *.ASM)
  52. ;    Output: routine at cs:bx called for each directory entry match
  53. ;       Registers:  ax,cx,dx + any changed in Action subroutine at cs:bx
  54. ;------------------------------------------------------------------------
  55. PROC    DirEngine
  56.     push    es
  57.     push    bx
  58.     mov    ah,2Fh
  59.     int    21h
  60.     mov    [DTAseg],es
  61.     mov    [DTAofs],bx
  62.     pop    bx
  63.     pop     es
  64.     mov    dx, offset dirData
  65.     mov    ah,1Ah
  66.     int    21h
  67.     mov    ah,4Eh
  68.     mov    cx,10h
  69.     mov    dx,di
  70.     jmp    short @@20
  71. @@10:
  72.     mov    ah,4Fh
  73. @@20:
  74.     int    21h
  75.     jc    @@99
  76.     call    bx
  77.     jmp    @@10
  78. @@99:
  79.     push    ds
  80.     mov    ds,[DTAseg]
  81.     mov    dx,[DTAofs]
  82.     mov    ah,1Ah
  83.     int    21h
  84.     pop    ds
  85.     ret
  86. ENDP    DirEngine
  87. %NEWPAGE
  88. ;------------------------------------------------------------------------
  89. ; Action - called for each directory entry "hit"
  90. ;------------------------------------------------------------------------
  91. ;    Input:  dirData = directory entry (as returned by DOS)
  92. ;    Output: one file/subdirectory name displayed
  93. ;       Registers: ah,dl,cx,di
  94. ;------------------------------------------------------------------------
  95. PROC    Action
  96.     mov    di, offset dirData + FileName
  97.     call    StrWrite
  98.     call    StrLength
  99.     sub    cx,16
  100.     neg    cx
  101. @@10:
  102.     mov    ah,2
  103.     mov    dl, ' '
  104.     int    21h
  105.     loop    @@10
  106.     ret
  107. ENDP    Action
  108.  
  109.     END    Start
  110.