C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming
The ASP Free website provides in-depth information on the latest developer tools available from Microsoft. Our cadre of writers, highly experienced industry experts, reveals the best ways to use established technologies as well as new and emerging technologies. Our coverage of Microsoft's development and administration technologies is among the most respected in the IT industry today.

ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month!
Download and Activate to enter!

Intel® Graphics Performance Analyzers is a powerful tool suite for analyzing and optimizing your games, media, and graphics-intensive applications. Used by some of the best developers on the planet, Intel GPA lets you maximize your app’s performance.


Tutorials
| Forums

Download to Enter
| Contest Rules

DOWNLOAD INTEL® GPA FOR FREE

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, 07: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, 07:42 AM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 8th Plane (8500 - 8999 posts)
 
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 8,978 Scorpions4ever User rank is General 39th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 39th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 39th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 39th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 39th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 39th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 39th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 39th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 39th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 39th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 39th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 39th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 39th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 39th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 39th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 39th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 6 Days 21 h 44 m 27 sec
Reputation Power: 3561
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, 08: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, 08: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 47 m 19 sec
Warnings Level: 10
Number of bans: 1
Reputation Power: 0

Reply With Quote
  #5  
Old September 27th, 2007, 10: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

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


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

© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 11 - Follow our Sitemap