Search code examples
assemblydosx86-16dosboxlong-filenames

creating file in assembly 16 bit with long file name


a have made a proc which create a file for me (in assembly 16 bit in dos box) and it work just fine with short file name(see below). however, when the name is above 8 chars all the others are deleted. for example for the path: 'logs\log_YYYY_MM_DD.log', 0 it will create a file with the name log_YYYY.log how can i make a file with name longer than 8 chars. Thank you.

;---------------------------CreateFile-----------------------------
; Description:  create a file.
; param 1:      [in] address of File name path.
; Param 2:      [out] address of File handle.
; Return:       File handle.
;------------------------------------------------------------------
proc CreateFile
    pusha
    mov bp, sp

    @CreateFile@FileName        equ [word ptr bp + 20]
    @CreateFile@FileHandle      equ [word ptr bp + 18]

    mov ah, 3ch                     ; create file
    mov cx, 0                       ; file attribute
    mov dx, @CreateFile@FileName    ; file name 
    int 21h

    jc @CreateFile@Error
    mov bx, @CreateFile@FileHandle  
    mov [word ptr bx], ax

    jmp @CreateFile@End
@CreateFile@Error:
    call PrintFileError     ;prints an error msg

@CreateFile@End:    
    popa
    ret 2
endp CreateFile

Solution

  • how can i make a file with name longer than 8 chars

    You can't. DOS supports only 8.3 filenames.


    More specifically, the version of DOS implemented in DOSBox does not support long filenames.

    From Wikipedia:

    Forks such as DOSBox SVN Daum and DOSBox SVN-lfn provide additional features, which include support for save states and long filenames (LFN)

    So there are variants of DOSBox that do support long filenames, but the core version does.