Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

DTA file size problem

I want to move file size from DTA to a seperate string. I managed to copy file size from DTA to AL, but I can't copy it to another string. I get 1 digit of file size from int 10h and nothing from int 21h. Why wouldn't it store it in fsize string?
[code].Model small
.Stack 100H
.Data
CurDir db '', 64 dup (0)
Dir db "C:/temp",0
file db "*.*",0
fsize db 128 dup(?)
cr db 10,13,"$"
DTA db 128 dup(?) ;buffer to store the DTA
ErrorMsg db "An Error has occurred - exiting.$"
.Code
start:
mov ax, @data
mov ds, ax
xor ax, ax
mov ah,47h
lea si,CurDir+1
mov dl,0
int 21h

mov ah,3bh
lea dx,dir
int 21h

mov dx,OFFSET DTA ; DS:DX points to DTA
mov ah,1AH ; function 1Ah - set DTA
int 21h ; call DOS service

mov cx,3Fh ; attribute mask - all files
mov dx,OFFSET File ; DS:DX points ASCIZ filename
mov ah,4Eh ; function 4Eh - find first
int 21h ; call DOS service

jc error ; jump if carry flag is set

LoopCycle:

mov dx,OFFSET File ; DS:DX points to file name
mov ah,4Fh ; function 4fh - find next
int 21h ; call DOS service

jc exit ; exit if carry flag is set


mov cx,1 ; length of filename
mov si,OFFSET DTA+26 ; DS:SI points to filename in DTA
xor bh,bh ; video page - 0
mov ah,0Eh ; function 0Eh - write character
lodsb

add al,48 ;makes an integer
cmp al,48 ;skips if it's a zero
je LoopCycle
mov di,offset fsize
stosb ;stores it in fsize
int 10h ;prints out AL
mov dx,offset fsize
mov ah,9
int 21h ;prints out fsize

mov dx,offset cr
mov ah,9
int 21h ;new line

mov di,OFFSET DTA+26 ; ES:DI points to DTA
mov cx,1 ; length of filename
xor al,al ; fill with zeros
stosb ; erase DTA

jmp LoopCycle ; continue searching

error:
mov ah,9
lea dx,ErrorMsg
int 21h

exit:
mov ah,3bh
lea dx,CurDir
int 21h
mov ah,4ch
int 21h

End start[/code]

Comments

  • 3y3ty3y3ty Posts: 15Member
    FindFirst 4e and FindNext 4f writes
    a FileInfo Structure to the current DTA.

    FORMAT OF FILEINFO STRUCTURE
    0000 DB 21 DUP (?) RESERVED
    0015 DB ? Attributes
    0016 DW ? Time of last write
    0018 DW ? Date of last write
    001A DD ? File size ;;;;
    001E DB 13 DUP (?) filename.ext

    Your saying you wan't to copy the file size
    from the DTA to another string, but file size
    is not a string, it is a double word containing
    a 32-bit value.

Sign In or Register to comment.