Configuration :
MS-DOS 16 BIT (writing in a .asm file, then compiling them with TASM and TLINK)
Windows 7 x64
I've made a simple program in Assembly that should only OPEN a file and write a text to it.
Here is the code to it:
assume cs:code, ds:data
data segment
fileName db "input.txt", 0 ; We assure it is an ASCIIZ(ero) file.
toWrite db "Hello World!", "$"
data ends
code segment
writeToFile:
; pentru functia 3Dh
mov AH, 3Dh
mov AL, 0h
mov dx, offset fileName
int 21h
ret
start_program:
mov ax, data
mov ds, ax
CALL writeToFile
mov ax, 4c00h
int 21h
code ends
end start_program
I used TurboDebugger to see what happens. Strangely, it always puts in AX
value 0005
meaning Access Denied
Everything I could find on the internet for searching ASSEMBLY access denied open file
was about DLL
's and that did not help.
I've tried anything, from restarting my program to opening dosbox "As an administrator". Sadly, nothing worked and I am out of ideas.
What's also strange is, that a friend of mine said that after activating his windows 10, everything worked just fine.
What is the reason for getting only "access denied"? I mention that I was able to create, delete and close files, but I cannot open them.
AX
being5
doesn't mean access denied by itself, only ifCF
is set to indicate an error. Otherwise it's just your file handle. So, have you checked value ofCF
? – GlottalizedCF
and forgot about it. Yeah, you are right!CF
is 0. Thanks. I shall delete this post. – Primate0
in theAL
register, which is the access mode.0
means "read only", which isn't going to help you write to the file! – Carmelitacarmelite