The reason for this post is to see if something can be done regarding this code, what happens is that I cannot delete a file as long as the 3CH function to create it is executed with INT 21H, since I did tests and remove the execution of the interrupt to create a file and if the delete works if I put in NMF the name of a file directly, and when I try again executing the create interrupt with the direct name in NMF it stops working.
;Enter the file name
MOV AH, 0AH
LEA DX, NMF
INT 21H
MOV BL, NMF[1]
MOV NMF[BX 2], ' '
;Create the file
MOV AH, 3CH
MOV CX, 0H
LEA DX, NMF 2
INT 21H
MOV HND, AX
;Close the file
MOV AH, 3EH
MOV BX, HND
INT 21H
;Delete the file
MOV AH, 41H
LEA DX, NMF 2
INT 21H
NMF and HND are defined as follows.
NMF DB 100 DUP(' '), 0
HND DW 0
And it is worth mentioning that the CF = 0 and AX = 00003 at the time of launching the interrupt to delete the file, so I would not know if it is an error since CF is not 1. I hope and you can help me, thanks.
CodePudding user response:
DOS function CREATE OR TRUNCATE FILE and DELETE FILE expect a zero-terminated filename in DS:DX but you have provided a space-terminated name:
MOV BL, NMF[1]
MOV NMF[BX 2], ' '
should be
MOVZX BX,[NMF 1] ; Load BX with the filename size.
MOV [NMF BX 2],BH ; Zero-terminate the filename (using BH=0).
The instruction MOV BX, HND
loads BX with the offset of the memory variable reserved for the handle instead of the handle itself; it should be MOV BX,[HND]
.
CodePudding user response:
I was already able to solve it as follows: Just before deleting the file I opened and closed it.