open file using int21-stack problem

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 written, open_file. Here is what i mean:
At code part: char* fp;
char* open_file(filename*);
....
fp = load_file(filename);

Assembly part:
....
global open_file

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



open_error:

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. So i think that i have use incorrectly the stack or the handler and not something typical like how i use linking or something about variables' or functions' statements, because 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

Comments

Sign In or Register to comment.

Howdy, Stranger!

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

Categories

In this Discussion