Hello everybody.
I've been trying to put some code written in asm to my c program but there is a strange problem I get.
I use visual c and put my asm file in my project, compile it etc etc. and everything works. BUT, when I try to include this small piece of code into a big project then I gate strange problem - Unresolved externals from LINK.
I tryied everything already - it works in a small console app, but not in a big gui program.
By the way - I tryied to exclude object files compiled by ml from my small app and got something like "Unresloved external _MyProcedure@4", but in gui project it complains that there's "Unresolved externals _stdcall MyProcedure@XABCD3232@@3232" something this way ;))
Surelly there's some simple problem - but I have no idea what it is....
Please help me :)

Thank you.
Posted on 2004-02-11 07:54:23 by pps
Posted on 2004-02-11 08:20:48 by donkey
Thanks for your reply - I already read that, I always spent too much time seeking some specific info on Microsoft's pages. For example, the link you posted leads to explanation what was the problem -> from there it leads to some topics, where they say that I'll need decorated names etc and if you need then go here... I browesed like 5 minutes back and forth and didn't find any info where I need decorated names... It's not possible to use decorated names in c prog directly, as the '@' char isn't acceptable I think...
Anyways, 20 seconds on google gave me results:
http://www.google.ca/search?q=asm+in+c%2B%2B&ie=UTF-8&oe=UTF-8&hl=en&meta=
and from there:
http://www.gamedev.net/community/forums/topic.asp?topic_id=151407

...the answer was I needed to add extern "C" to my header.
tada!

Thanks.
Posted on 2004-02-11 16:25:15 by pps
Glad you found the solution pps, I don't use high level languages so I never run into the problem much. BTW I'm originally from Hochelaga Maisoneuve, grew up on Ontario near PieIX. Live in northern Ontario now but good to see another Montreal guy doing assembly ;)
Posted on 2004-02-11 16:46:31 by donkey
OH, really??
What a coincedence:))
I grew up quite far (aprox. opposite side of the globe :)) from this place, but now I live in mtl - near metro Charlevoix.

Why you aren't using high level languages? (Ofcourse it's ok if your profession requires it) but what I found out is that I simply cannot write code in asm that would run faster than c/c++ equivalent compiled with full optimizations using visual c or intel compiler. I have written a piece of code that needed LOTS of cpu power mostly for loops and simple operations as shifts and bitwise operations. So, my best bet was to use mmx registry and write code in pure asm - result was strange: almost no improvement over c implmentation - looking at asmebly listings generated by visual c, I really trust this tool, as it really does it's job well enough. I also once needed to optimize someone else's code - it was really havy on cpu... So, without going inside, in a few hours I improved it - it run something like 100 times faster. Man you don't believe me probably :)) but it's true - ~100times faster with right optimizations. It was for real-time sound processing stuff - secret was some cosmetic optimizations and mostly __forceinline and __fastcall plus pragma for icreasing number of consequtive inlining. So, it became at lest 100 times faster - there was something like 40 000 000 procedure calls per sec. less than it was before. Simply executable became two-three times bibber ~400Kb. After I did this optimization I tried to improve most frequently run parts with asm. Spending a few days gave 0 results - I just cannot make it faster anymore - even mmx with 8 bytes/per instruction give me almost no improvement...
Asm is really for VERY high-end very specific needs, and is just isn't for gui programming - as this routines that draw all the lines of windows and dots of fonts aren't written in asm... It's just isn't possible to jump over that. Not to mention, many other areas are simply not designed for asm... but it's always better to know what asm actually is.
PS> I'm no saying that you program only gui using only asm - it's just a small comment on the iczelions tutorials that were my introduction to asm :))
Posted on 2004-02-13 01:35:31 by pps