Question

I have to write a TASM program in which a read-only file is created. I created the file but it is not read-only. What's wrong? Here's the code:

model small
.data
    handle dw 0
    filename db "file2.txt",0
.stack 256
.code
main:

    mov ax,@data
    mov ds,ax

    mov ah,3ch 
    mov cx,1         
    lea dx,filename 
    int 21h 
    jc exit

    mov handle,ax
exit:
    mov ax,4c00h
    int 21h
end main

Edit: I changed mov cx,1 to mov cx,01h and it worked.

P.S: I also want the file to be hidden so once again I changed to mov cx,03h and done. The created file is read-only and hidden.

Was it helpful?

Solution

Bit 7 = 1: Shareable
Bit 6 = 1: Archive
Bit 5 = 1: Directory
Bit 4 = 1: Volume (ignored)
Bit 3 = 1: Label
Bit 2 = 1: System
Bit 1 = 1: Hidden
Bit 0 = 1: Read-only

Edit: My original answer was incorrect as the values I stated were bitwise, so for clarity decimal would be:

mov cx, 0       ;  No attributes. 
mov cx, 1       ;  Read-only. 
mov cx, 2       ;  Hidden. 
mov cx, 4       ;  System 
mov cx, 16      ;  Archive

For multiple attributes add the values together.

This means the value of CX was correct in your original post as 1 is 1 whether in decimal or hex (or binary), so whatever changes you made, that should not be what solved it.

Glad you got it working though.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top