Hi I am writing an assembly procedure as shown below,

;addASM.asm

.model medium

.code

public _add

_add proc far
    push bp
mov bp, sp
mov ax,
mov bx,
add ax, bx
xor dx, dx
pop bp
ret
_add endp

end



Now I want to call this _add procedure in C code,


//mainFile.c

#include<stdio.h>
#include<conio.h>


extern int add(int, int);

void main()
{
int num1, num2, output;

    num1 = 5; // initialize the first number
num2 = 7; // initialize the second number
output = 0; // initialize the output to zero

output = add(num1,num2);

printf("result = %d",output);

getch();
}     



I assembled the addASM.asm file using MASM as
C:\ex>ml /c addASM.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: addASM.asm


and I got the OBJ file addASM.obj
I then compiled mainFile.c and addASM.obj using Borland C++ 3.1 as
C:\bc\BIN>bcc -IC:\bc\INCLUDE -LC:\bc\LIB mainFile.c addASM.obj
Borland C++  Version 3.1 Copyright (c) 1992 Borland International
mainfile.c:
Turbo Link  Version 5.1 Copyright (c) 1992 Borland International
Error: Fixup overflow at _TEXT:001A, target = _add in module mainfile.c

        Available memory 4201624 

Now what is : Error: Fixup overflow at _TEXT:001A, target = _add in module mainfile.c


Please help me how to use far assembly procedures in c, please send me code as it will be good for better understanding for me.

Please help me it is urgent.

Thanks in advance. Please help me.
Posted on 2011-03-10 10:15:15 by aashishasm
My guess is that the .obj file that MASM generates (a much newer version) is not compatible with your version of BC++.
Therefore I would suggest using TASM instead (which should have come with your copy of BC++).

Other than that, you haven't specified in your C++ code that add() is a far proc. That could also be a problem (not sure what the default model is for BC++).
So try: extern far int add(int, int);
(Or whatever the syntax was).
Posted on 2011-03-10 12:27:35 by Scali