Turbo C Fixup Error

Reply

Join Date: Apr 2008
Posts: 22
Reputation: paolomontero is an unknown quantity at this point 
Solved Threads: 0
paolomontero paolomontero is offline Offline
Newbie Poster

Turbo C Fixup Error

 
0
  #1
May 26th, 2008
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:

  1. BITS 16
  2.  
  3. GLOBAL _Add4
  4.  
  5. n_Add4 equ 4
  6.  
  7. _Add4:
  8. push bp
  9. mov bp,sp
  10.  
  11. mov ax, [bp + n_Add4]
  12. add ax, 4
  13.  
  14. mov sp,bp
  15. pop bp
  16. ret

And here is my Turbo C code:

  1. extern int Add4(int);
  2.  
  3. void main() {
  4. int n;
  5. n = Add4(77);
  6. }

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?
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 1
Reputation: xrysf03 is an unknown quantity at this point 
Solved Threads: 0
xrysf03 xrysf03 is offline Offline
Newbie Poster

Re: Turbo C Fixup Error

 
0
  #2
Jun 4th, 2008
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:

  1. SEGMENT _TEXT PUBLIC CLASS=CODE USE16 ALIGN=16

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

  1. 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 :-))
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Legacy and Other Languages Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC