DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Legacy and Other Languages (http://www.daniweb.com/forums/forum42.html)
-   -   Turbo C Fixup Error (http://www.daniweb.com/forums/thread126087.html)

paolomontero May 26th, 2008 12:25 am
Turbo C Fixup Error
 
Hi,

Im writing a program in Turbo C but i also want to use some assembly functions, for this im using nasm.

This is my assembly code:

BITS 16

GLOBAL _Add4

n_Add4 equ 4

_Add4:
        push bp
        mov bp,sp
       
        mov ax, [bp + n_Add4]
        add ax, 4
       
        mov sp,bp
        pop bp
        ret

And here is my Turbo C code:

extern int Add4(int);

void main() {
        int n;
        n = Add4(77);
}

Im linking this way:

nasm -o asmmodule.obj -f obj asmmodule.asm
tcc -mt -c cmodule.c
tlink cmodule.obj asmmodule.obj

But tlink gives me the following error:

Fixup overflow in module CMODULE.C at _TEXT:000B, target = _ADD4

Anyone knows how to fix this?

xrysf03 Jun 4th, 2008 10:24 am
Re: Turbo C Fixup Error
 
Seems to be a common problem, only explained in some usenet news threads.

You don't seem to have any segments declared in your ASM code.

Try putting this just above your assembly function definition:

SEGMENT _TEXT PUBLIC CLASS=CODE USE16 ALIGN=16

In addition, I'd suggest putting the following above your single variable declaration:

SEGMENT data

For a more thorough discussion, search "google groups" (USENET news, really) with the following query:

nasm "Fixup overflow" borland

The thread I'm referring to has the following subject:

Help linking a (trivial) NASM object file (.obj) with Borland C++ 3.0

Nice to know that others are still playing with Borland C for DOS + NASM, just like I do :-))


All times are GMT -4. The time now is 10:25 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC