problem opening a file using dos services..PLEASE HELP - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

problem opening a file using dos services..PLEASE HELP

mirkovmirkov Posts: 3Member
I write a program in C but i have not the right to use the standard library. I want to open a file so i use an assembly procedure that i have write, open_file. Here is what i mean:
At C code part: int fp;
int open_file(char* filename);
fp = open_file(filename);

Assembly part:
global open_file


push bp
mov bp,sp
push bx
push dx

mov ah, 0x3d

mov al, 0x00 ; read-only

mov bx, [bp + 4] ; file_name segment in DS

mov ds, bx

mov dx, [bp + 6] ; file_name offset in DX

int 0x21 ; open file

jc open_error ; if carry is set file could not open
mov handler, ax
pop dx
pop bx
pop bp
ret 4


mov ah,1
pop dx
pop bx
pop bp

ret 4

The problem is that when i execute my program, when it comes to the part of opening the file it aborts. What do you think is wrong? Other functions that i wrote in such a way, for example function that prints a string or clear the monitor, works well.

I would appreciate your help. Thanks a lot for your time

Sign In or Register to comment.