Home > Back-end >  Changing file attribute to read-only on assembly with INT 21,43 does not work
Changing file attribute to read-only on assembly with INT 21,43 does not work

Time:10-31

I am quite new to assembly and recently I have been struggling to make INT 21,43 (changing file attribute to read-only) work. I am using Windows 10, DOSBox x86, and Turbo Assembler/Linker/Debugger if that makes any difference. As far as I can tell using the debugger, it should work (CF is NOT set and I am not getting error code as I should, according to documentation). Also, if I use the same INT 21,43 to GET (setting al to 0) file attribute of a file, that was already set to read-only manually, CX is set to 20, which as far as I know does not make sense, but CF is not set as well, so it says it worked. I hope you can help me fix it, thanks in advance.

.model small
.stack 100h

.data
    filename db "temp.txt",0 ; my file name 

.code

start:

    mov dx, @data
    mov ds, dx
    
    mov ah, 43h
    mov al, 01h ; Set file attribute
    mov cx, 01h ; 1 = read-only
    lea dx, filename ; Set pointer to filename
    int 21h
    
    mov ah, 4ch ; Return to DOS       
    mov al, 0               
    int 21h  


end start

This is what debugger shows after INT 21,43 interrupt has been called

CodePudding user response:

I just tried setting the ReadOnly attribute from a program running in DOSBox and it didn't work.

DOSBox's help via help /all, reports that the ATTRIB command does nothing and that it's provided for compatibility only. Therefore it stands to reason that the DOS.function 43h (Get/Set File Attributes) will not have been implemented.

Since DOSBox is primarily meant to emulate old DOS games, there's perhaps little reason to want to change attributes.

  • Related