C Board  

Go Back   C Board > Community Boards > Tech Board

Reply
 
LinkBack Thread Tools Display Modes
Old 09-27-2007, 05:27 AM   #1
Registered User
 
Join Date: Jun 2007
Posts: 9
HELP: assembly & C linking woes....

I am having problems linking an assembly object with my C object files. Am getting:

Linker Warning: DOSSEG directive ignored in module asm.asm
Linker Error: Undefined symbol _ASMClsV in module main.c
Linker Error: Undefined symbol VADDR in module asm.asm

In my asm.asm file I've got:

DOSSEG
.MODEL huge
.386

.DATA
EXTRN vaddr : word;

.CODE
PUBLIC ASMClsV

ASMClsV PROC Near
;bla bla
ASMClsV EndP

In main.c I've got:

extern void ASMClsV();

Am trying to link using Borland C++ 4.5 since my source files are all 16-bit. I successfully linked the same asm.asm file with a 16-bit pascal object using Turbo Pascal 7.0. Why can't I link using Borland C++ 4.5 to a 16-bit C file?

Also, I used Microsoft Macro Assembler 5. Should I use Turbo Assembler?
andrewwan1980 is offline   Reply With Quote
Old 09-27-2007, 06:31 AM   #2
Registered User
 
Join Date: Jun 2007
Posts: 9
Excellent! I managed to get the C & assembly files recognise each others variables & functions. Thanks to Scorpions4ever for telling me about C mangles variable & function names by prefixing an underscore in front. Now I get a different problem:

Linker Error: Fixup overflow at _TEXT:0002, target = vaddr in module asm.asm
...

It appears there's a linker error line for each of my variables surrounded by [ ], eg.

ASMClsV PROC Near
mov es, [vaddr]
; bla bla
ASMClsV EndP


What does this Fixup overflow mean?
andrewwan1980 is offline   Reply With Quote
Old 09-27-2007, 06:41 AM   #3
and the hat of Jobseeking
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,665
http://forums.devshed.com/c-programm...es-477579.html
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.

Salem is offline   Reply With Quote
Old 09-27-2007, 08:30 AM   #4
Registered User
 
Join Date: Jun 2007
Posts: 9
I read the cool document about Fixup Overflow at http://vmlinux.org/~jakov/community....com/15961.html but still unsuccessful. I fixed this problem myself by moving the variables from the C file to assembly file.

C file:
extern unsigned short vaddr; //Pascal word type
extern long AsmY; //Pascal integer type
extern void *ScrOfsPtr; //Pascal pointer type

Assembly file:
.DATA
PUBLIC vaddr, AsmY, ScrOfsPtr
vaddr label word
AsmY label word
ScrOfsPtr label dword


Now I don't know why I need the label before word/dword. What does that mean? And is that correct corresponding to the C & Pascal types?
andrewwan1980 is offline   Reply With Quote
Old 09-28-2007, 04:17 PM   #5
Registered User
 
Join Date: Oct 2001
Posts: 2,936
>And is that correct corresponding to the C & Pascal types?
>AsmY label word
This one should probably be a dword:
Code:
AsmY label dword
__________________
http://www.freechess.org
swoopy is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
linking to assembly xixpsychoxix C Programming 21 07-16-2008 03:51 PM
Linking C++ and Assembly Warlax C++ Programming 6 10-19-2007 04:33 PM
True ASM vs. Fake ASM ???? DavidP A Brief History of Cprogramming.com 7 04-02-2003 04:28 AM
Linking an assembly routine into a GCC project huh C++ Programming 3 11-21-2002 03:14 PM
C,C++,Perl,Java brusli C Programming 9 12-31-2001 03:35 AM


All times are GMT -6. The time now is 08:58 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22