Discuss HELP: assembly & C linking woes.... in the C Programming forum on Dev Shed. HELP: assembly & C linking woes.... C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
Take your business to the next level, with "The
Edge of Success: 9 Building Blocks to Double Your Sales."
Inside, you will discover how to easily capture more leads,
get repeat sales, and significantly grow your business.
Posts: 18
Time spent in forums: 4 h 36 m 6 sec
Reputation Power: 0
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?
Location: Glendale, Los Angeles County, California, USA
Posts: 8,738
Time spent in forums: 1 Month 2 Weeks 3 Days 4 h 1 m 21 sec
Reputation Power: 3271
C compilers usually mangle a function name by adding an _ to the front of each function name and variable. This has been traditionally done by C compilers since the days of K&R. You can do one of two things:
1. Rename your asm function as _ASMCIsV and reassemble it
2. Go to your Options --> Compiler --> Advanced Code Generation and turn off the Generate Underbars option and then rebuild your C files completely.
Either way, it should link correctly now
Note that C++ mangling rules differ from C rules. So, if your compiler thinks it is compiling a C++ file, it will mangle the function names differently. To control this, google for 'extern "C" '
__________________ Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home. "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne Diary of a first time dog owner <-- my cousin's blog
Posts: 18
Time spent in forums: 4 h 36 m 6 sec
Reputation Power: 0
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
Posts: 18
Time spent in forums: 4 h 36 m 6 sec
Reputation Power: 0
I read the cool document about Fixup Overflow at /~jakov/community.borland.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?
Create the Optimal Architecture for your Critical Applications Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.
Gartner Magic Quadrant for Application Delivery Controllers Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.
Knowledge is Power What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.
Rationalizing the Multi-Tool Environment The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.