Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

cheking files inside a drive A:

reyalreyal Member Posts: 8
Gud d 2 everyone here!

Anybody here know how 2 display number of files inside a drive A?

Any help is very much appreciated.

REYAL

Comments

  • Luke7Luke7 Member Posts: 156
    : Gud d 2 everyone here!
    :
    : Anybody here know how 2 display number of files inside a drive A?
    :
    : Any help is very much appreciated.
    :
    : REYAL

    Here some code to get you started. You'll need to modify it for drive a:

    ; showfile.asm Shows number of all files in current directory
    ;
    ; Bitfields for file attributes:
    ; Bit(s) Description (Table 0643)
    ; 7 shareable (Novell NetWare)
    ; 6 unused
    ; 5 archive
    ; 4 directory
    ; 3 volume label
    ; execute-only (Novell NetWare)
    ; 2 system
    ; 1 hidden
    ; 0 read-only
    ;
    ; What you have to do is set up the Find call like a wildcard filename search,
    ; but specify DIR attributes only in the call. Then, you simply process each
    ; subdirectory name as it is found. That way, no recursion or saving of the
    ; DTA or anything else is required. I wrote a program called KILLDIR which
    ; used exactly this method. A free tip: I found that there is a serious bug
    ; in the Find calls (4Eh and 4Fh), and it exists in all versions of DOS --
    ; 2.x to 6.x ! When the attributes are specified as files, DOS finds all
    ; files in the current directory; but when the attributes are specified
    ; as directories, DOS "finds" ALL directory entries (files and dirs) as
    ; directories. So, if you are going to delete files, do that *first*, so
    ; that DOS won't "find" them as valid directory entries.
    ; The default DTA = UPA. If you want to use the command line parameters,
    ; you should either finish parsing them before you begin the Find calls,
    ; or copy it to somewhere else, or move the DTA with function call 1Ah.

    .model small
    .stack 200h

    .data

    root db '',0
    parent db '..',0
    all db '*.*',0
    DTA db 43 dup (0)
    DTAitem equ DTA + 1Eh ; 1eh = 30d
    counter db 0
    files db 'Number of files in directory = $'

    .code

    start:
    mov ax,@data
    mov ds,ax

    xor bx,bx ; zero out counter
    again:
    mov dx,offset all
    mov cx,00100111b ; read-only,system,hidden,and archive
    mov ah,4Eh ; Find first dir entry.
    int 21h
    jc exit

    next:
    mov di,offset DTAitem ; matching item at offset 1Eh in DTA
    cmp byte ptr [di],'.' ; Ignore '.' and '..' dir entries
    je skip
    skip:
    mov ah,4Fh ; Find next dir entry.
    int 21h
    inc bx ; increment counter
    jnc next

    mov ah,9
    mov dx,offset files
    int 21h
    mov ax,bx ; move count into ax for processing
    call PrtDec ; print the count
    exit:
    mov ax,4c00h
    int 21h


    PrtDec proc
    push ax
    push cx
    push dx
    mov cx,0ffffh
    push cx
    mov cx,10
    pd1:
    mov dx,0
    div cx
    add dl,30h
    push dx
    cmp ax,0
    jne pd1
    pd2:
    pop dx
    cmp dx,0ffffh
    je pd3
    mov ah,2
    int 21h
    jmp pd2
    pd3:
    pop dx
    pop cx
    pop ax
    ret
    PrtDec endp

    end start


  • reyalreyal Member Posts: 8
    : : Gud d 2 everyone here!
    : :
    : : Anybody here know how 2 display number of files inside a drive A?
    : :
    : : Any help is very much appreciated.
    : :
    : : REYAL
    :
    : Here some code to get you started. You'll need to modify it for drive a:
    :
    : ; showfile.asm Shows number of all files in current directory
    : ;
    : ; Bitfields for file attributes:
    : ; Bit(s) Description (Table 0643)
    : ; 7 shareable (Novell NetWare)
    : ; 6 unused
    : ; 5 archive
    : ; 4 directory
    : ; 3 volume label
    : ; execute-only (Novell NetWare)
    : ; 2 system
    : ; 1 hidden
    : ; 0 read-only
    : ;
    : ; What you have to do is set up the Find call like a wildcard filename search,
    : ; but specify DIR attributes only in the call. Then, you simply process each
    : ; subdirectory name as it is found. That way, no recursion or saving of the
    : ; DTA or anything else is required. I wrote a program called KILLDIR which
    : ; used exactly this method. A free tip: I found that there is a serious bug
    : ; in the Find calls (4Eh and 4Fh), and it exists in all versions of DOS --
    : ; 2.x to 6.x ! When the attributes are specified as files, DOS finds all
    : ; files in the current directory; but when the attributes are specified
    : ; as directories, DOS "finds" ALL directory entries (files and dirs) as
    : ; directories. So, if you are going to delete files, do that *first*, so
    : ; that DOS won't "find" them as valid directory entries.
    : ; The default DTA = UPA. If you want to use the command line parameters,
    : ; you should either finish parsing them before you begin the Find calls,
    : ; or copy it to somewhere else, or move the DTA with function call 1Ah.
    :
    : .model small
    : .stack 200h
    :
    : .data
    :
    : root db '',0
    : parent db '..',0
    : all db '*.*',0
    : DTA db 43 dup (0)
    : DTAitem equ DTA + 1Eh ; 1eh = 30d
    : counter db 0
    : files db 'Number of files in directory = $'
    :
    : .code
    :
    : start:
    : mov ax,@data
    : mov ds,ax
    :
    : xor bx,bx ; zero out counter
    : again:
    : mov dx,offset all
    : mov cx,00100111b ; read-only,system,hidden,and archive
    : mov ah,4Eh ; Find first dir entry.
    : int 21h
    : jc exit
    :
    : next:
    : mov di,offset DTAitem ; matching item at offset 1Eh in DTA
    : cmp byte ptr [di],'.' ; Ignore '.' and '..' dir entries
    : je skip
    : skip:
    : mov ah,4Fh ; Find next dir entry.
    : int 21h
    : inc bx ; increment counter
    : jnc next
    :
    : mov ah,9
    : mov dx,offset files
    : int 21h
    : mov ax,bx ; move count into ax for processing
    : call PrtDec ; print the count
    : exit:
    : mov ax,4c00h
    : int 21h
    :
    :
    : PrtDec proc
    : push ax
    : push cx
    : push dx
    : mov cx,0ffffh
    : push cx
    : mov cx,10
    : pd1:
    : mov dx,0
    : div cx
    : add dl,30h
    : push dx
    : cmp ax,0
    : jne pd1
    : pd2:
    : pop dx
    : cmp dx,0ffffh
    : je pd3
    : mov ah,2
    : int 21h
    : jmp pd2
    : pd3:
    : pop dx
    : pop cx
    : pop ax
    : ret
    : PrtDec endp
    :
    : end start
    :
    :
    :
    :

    Thanks for the reply man. by the way, what are these codes means?

    .model small
    : .stack 200h
    :
    : .data

    ....and

    : mov ax,@data

    coz, we don't used that codes in our programming lessons. we used I think the oldest version of Assembly, we don't used any .model, .stack, .data and also we don't used and discussed @ symbol in assembly. Can you please tell me what's code are for?

    thanks,
    REYAL
  • opiumdreameropiumdreamer Member Posts: 19
    : : : Gud d 2 everyone here!
    : : :
    : : : Anybody here know how 2 display number of files inside a drive A?
    : : :
    : : : Any help is very much appreciated.
    : : :
    : : : REYAL
    : :
    : : Here some code to get you started. You'll need to modify it for drive a:
    : :
    : : ; showfile.asm Shows number of all files in current directory
    : : ;
    : : ; Bitfields for file attributes:
    : : ; Bit(s) Description (Table 0643)
    : : ; 7 shareable (Novell NetWare)
    : : ; 6 unused
    : : ; 5 archive
    : : ; 4 directory
    : : ; 3 volume label
    : : ; execute-only (Novell NetWare)
    : : ; 2 system
    : : ; 1 hidden
    : : ; 0 read-only
    : : ;
    : : ; What you have to do is set up the Find call like a wildcard filename search,
    : : ; but specify DIR attributes only in the call. Then, you simply process each
    : : ; subdirectory name as it is found. That way, no recursion or saving of the
    : : ; DTA or anything else is required. I wrote a program called KILLDIR which
    : : ; used exactly this method. A free tip: I found that there is a serious bug
    : : ; in the Find calls (4Eh and 4Fh), and it exists in all versions of DOS --
    : : ; 2.x to 6.x ! When the attributes are specified as files, DOS finds all
    : : ; files in the current directory; but when the attributes are specified
    : : ; as directories, DOS "finds" ALL directory entries (files and dirs) as
    : : ; directories. So, if you are going to delete files, do that *first*, so
    : : ; that DOS won't "find" them as valid directory entries.
    : : ; The default DTA = UPA. If you want to use the command line parameters,
    : : ; you should either finish parsing them before you begin the Find calls,
    : : ; or copy it to somewhere else, or move the DTA with function call 1Ah.
    : :
    : : .model small
    : : .stack 200h
    : :
    : : .data
    : :
    : : root db '',0
    : : parent db '..',0
    : : all db '*.*',0
    : : DTA db 43 dup (0)
    : : DTAitem equ DTA + 1Eh ; 1eh = 30d
    : : counter db 0
    : : files db 'Number of files in directory = $'
    : :
    : : .code
    : :
    : : start:
    : : mov ax,@data
    : : mov ds,ax
    : :
    : : xor bx,bx ; zero out counter
    : : again:
    : : mov dx,offset all
    : : mov cx,00100111b ; read-only,system,hidden,and archive
    : : mov ah,4Eh ; Find first dir entry.
    : : int 21h
    : : jc exit
    : :
    : : next:
    : : mov di,offset DTAitem ; matching item at offset 1Eh in DTA
    : : cmp byte ptr [di],'.' ; Ignore '.' and '..' dir entries
    : : je skip
    : : skip:
    : : mov ah,4Fh ; Find next dir entry.
    : : int 21h
    : : inc bx ; increment counter
    : : jnc next
    : :
    : : mov ah,9
    : : mov dx,offset files
    : : int 21h
    : : mov ax,bx ; move count into ax for processing
    : : call PrtDec ; print the count
    : : exit:
    : : mov ax,4c00h
    : : int 21h
    : :
    : :
    : : PrtDec proc
    : : push ax
    : : push cx
    : : push dx
    : : mov cx,0ffffh
    : : push cx
    : : mov cx,10
    : : pd1:
    : : mov dx,0
    : : div cx
    : : add dl,30h
    : : push dx
    : : cmp ax,0
    : : jne pd1
    : : pd2:
    : : pop dx
    : : cmp dx,0ffffh
    : : je pd3
    : : mov ah,2
    : : int 21h
    : : jmp pd2
    : : pd3:
    : : pop dx
    : : pop cx
    : : pop ax
    : : ret
    : : PrtDec endp
    : :
    : : end start
    : :
    : :
    : :
    : :
    :
    : Thanks for the reply man. by the way, what are these codes means?
    :
    : .model small
    : : .stack 200h
    : :
    : : .data
    :
    : ....and
    :
    : : mov ax,@data
    :
    : coz, we don't used that codes in our programming lessons. we used I think the oldest version of Assembly, we don't used any .model, .stack, .data and also we don't used and discussed @ symbol in assembly. Can you please tell me what's code are for?
    :
    : thanks,
    : REYAL
    :
    [green]
    .model small
    .stack 200h
    .data
    [/green]
    This is used when using the so called simplified segment definition instead of the full segment definition that you probably have been working with.
    There are 6 models:
    [b]tiny [/b](used with .com files in which data and code must fit in 64k together)
    [b]small [/b](uses 64k for data seg and 64k for code seg and you can specify a separate stack by using the .stack directive)
    [b]medium [/b](the data must fit into 64k)
    [b]compact [/b](data can exceed 64k)
    [b]large [/b](both data and code can exceed 64k, but no single set of data should exceed 64k)
    [b]huge [/b](both code and data can exceed 64k. data items, i.e arrays, can exceed 64k)

    [b].stack[/b] directive gives the size of the stack in simple segment mode
    [b].data[/b] implies the start of the data segment where to declare.
    [b].code[/b] indicates that code segment begins


    [code]and the last one
    mov ax,@data ;loads the data segment address
    mov ds,ax ;and assigns it to DS (Data Segment)
    [/code]



Sign In or Register to comment.