C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 27th, 2007, 06:28 AM
andrewwan1980 andrewwan1980 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 18 andrewwan1980 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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?

Reply With Quote
  #2  
Old September 27th, 2007, 06:42 AM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 8th Plane (8500 - 8999 posts)
 
Join Date: Nov 2001
Location: Glendale, Los Angeles County, California, USA
Posts: 8,738 Scorpions4ever User rank is General 34th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 34th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 34th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 34th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 34th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 34th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 34th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 34th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 34th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 34th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 34th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 34th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 34th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 34th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 34th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 34th Grade (Above 100000 Reputation Level) 
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

Reply With Quote
  #3  
Old September 27th, 2007, 07:31 AM
andrewwan1980 andrewwan1980 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 18 andrewwan1980 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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


What does this Fixup overflow mean?

Reply With Quote
  #4  
Old September 27th, 2007, 07:44 AM
sizablegrin's Avatar
sizablegrin sizablegrin is offline
Permanently Banned
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Jun 2005
Posts: 5,959 sizablegrin User rank is General 58th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 58th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 58th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 58th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 58th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 58th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 58th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 58th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 58th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 58th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 58th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 58th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 58th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 58th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 58th Grade (Above 100000 Reputation Level)sizablegrin User rank is General 58th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 2 Days 12 h 46 m 36 sec
Warnings Level: 10
Number of bans: 1
Reputation Power: 0

Reply With Quote
  #5  
Old September 27th, 2007, 09:32 AM
andrewwan1980 andrewwan1980 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 18 andrewwan1980 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > HELP: assembly & C linking woes....


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
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.

 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

 
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.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.


© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 11 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek