|
From: Per W. <pw...@ia...> - 2006-05-04 20:10:53
|
All external C symbols have a leading underscore, i.e. from assembler, the
function is called _printf.
Are you planning to write device drivers for embedded systems? If not -
exactly why do you bother with learning assembler?
First of all, it is very hard to write more efficient code than a modern
compiler generates.
Then, you have to realize that different compilers uses different syntax
for the assembler code.
Also, different compilers have different calling conventions and layout of
memory objects. For C++, the name mangling differs between compilers and
even between different versions of the same compiler.
Finally, there are quite a number of other processors than the x86 series,
and most code that requires assembler routines are _not_ run on x86
machines.
/Per W
On Thu, 4 May 2006, Noorez Kassam wrote:
> I'm trying to learn how to use the __asm. Hear is something that i was
> trying to learn from:
>
> #include <stdio.h>
>
>
> char format[] asm("format") =3D "%s %s\n";
>
> char hello[] asm("hello") =3D "Hello" ;
>
> char world[] asm("world") =3D "world";
>
>
> int main( void )
>
> {
> __asm
>
> (
>
> "mov eax, offset world;"
> "push eax;"
> "mov eax, offset hello;"
> "push eax;"
> "mov eax, offset format;"
> "push eax;"
> "call printf;"
>
> //clean up the stack so that main can exit cleanly
> //use the unused register ebx to do the cleanup
>
> "pop ebx;"
> "pop ebx;"
> "pop ebx;"
> );
>
> return 0;
> }
>
> The compile error is that it could not find printf. How do make the print=
f
> function visible to the asm code?.
>
> And one more question... I all other tutorials i've seen, when examples o=
f
> inlining assembly are shown, they are shown with braces{} and not (). Whe=
n I
> compile, i need to use () for it to work.
> Is there something i'm missing here...?
>
> _________________________________________________________________
> Take advantage of powerful junk e-mail filters built on patented Microsof=
t=AE
> SmartScreen Technology.
> http://join.msn.com/?pgmarket=3Den-ca&page=3Dbyoa/prem&xAPID=3D1994&DI=3D=
1034&SU=3Dhttp://hotmail.com/enca&HL=3DMarket_MSNIS_Taglines
> Start enjoying all the benefits of MSN=AE Premium right now and get the
> first two months FREE*.
>
>
>
> -------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job ea=
sier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronim=
o
> http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&dat=
=3D121642
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|