It looks like int 21, 3D
is "open file". Did you mean int 21, 3C
which is "create or truncate?"
If you checked the return value, you'd probably see CF
=1 indicating an error. I'm guessing AX
would be... 2?
Question
I wrote a 16 bit .com file which create a file
but it don't create any file.
I tried on windows 7 32 bit. and inside dosbox.
the source code is here
how can I write to a file?
org 100h
call open_new_file
mov ah, 40h;write
mov bx, [new_file_handle]
mov cx,2;write 2 bytes
mov dx, temp
int 21h
mov ah, 3eh;close file
mov bx, [new_file_handle]
int 21h
mov ah, 00
int 16h;wait key
mov ax, 4c00h
int 21h;exit
open_new_file:
push bp
mov bp, sp
mov ah, 3dh;open file
mov al, 02h;write only
mov dx, new_file_name ;out.kty
int 21h
mov [new_file_handle], ax
leave
ret
temp:
dw 0xffaa
new_file_handle:
dw 0
new_file_name:
db "out.bin", 0
thanks!
Solution
It looks like int 21, 3D
is "open file". Did you mean int 21, 3C
which is "create or truncate?"
If you checked the return value, you'd probably see CF
=1 indicating an error. I'm guessing AX
would be... 2?