473,406 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Caaling assembly routine in c

Hi All,

I am working on MIPS architecture and I am
compiling my project using GHS tool chain.

I want to call a assembly routine into c function.
My code is like that:

..globl asm
..ent asm

asm:
----
----
..end asm

I am calling this routine in c function like that:

extern void asm(void);

void foo()
{
asm();
}

On compiling, error message comes that
symbol asm unresolved.

Could any one tell that how I can do it for GHS.

Regards,
Sachin
Nov 14 '05 #1
5 2123

"Sachin" <sb******@rediffmail.com> wrote in message
news:40**************************@posting.google.c om...
Hi All,

I am working on MIPS architecture and I am
compiling my project using GHS tool chain.

This has little topicality here. Does your tool chain allow you to make
working asm code from a C function? If so, use that as a template.
Nov 14 '05 #2


Sachin wrote:
Hi All,

I am working on MIPS architecture and I am
compiling my project using GHS tool chain.

I want to call a assembly routine into c function.
My code is like that:

.globl asm
.ent asm

asm:
----
----
.end asm

I am calling this routine in c function like that:

extern void asm(void);

void foo()
{
asm();
}

On compiling, error message comes that
symbol asm unresolved.

Could any one tell that how I can do it for GHS.

Regards,
Sachin


Hi,

There is not much said about assemby routines from C its more
implementation specific stuff.
However this is what the C89 standard has to say -

A.6.5.10 The asm keyword

The asm keyword may be used to insert assembly-language code
directly into the translator output. The most common implementation
is via a statement of the form

asm ( character-string-literal );

So make sure you pass a character-string-literal as a param, not a void !

- Ravi

Nov 14 '05 #3
Sachin wrote:
Hi All,

I am working on MIPS architecture and I am
compiling my project using GHS tool chain.

I want to call a assembly routine into c function.
My code is like that:

.globl asm
.ent asm

asm:
----
----
.end asm

I am calling this routine in c function like that:

extern void asm(void);

void foo()
{
asm();
}

On compiling, error message comes that
symbol asm unresolved.

Could any one tell that how I can do it for GHS.

Regards,
Sachin


I think you are havind asm code in a separate file.
You have to assemble asm code into an object file. And then
compile C code to an object file. After you have both object files,
link them and this creates an executable.

(I assume that your asm code handles all the code calling conventions,
that standard C specifies OR your compiler requires)
Nov 14 '05 #4
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ravi Uday wrote:


Sachin wrote:
Hi All,

I am working on MIPS architecture and I am
compiling my project using GHS tool chain.

I want to call a assembly routine into c function.
My code is like that:

.globl asm
.ent asm

asm:
----
----
.end asm

I am calling this routine in c function like that:

extern void asm(void);

void foo()
{
asm();
}

On compiling, error message comes that symbol asm unresolved.

Could any one tell that how I can do it for GHS.

Regards,
Sachin

Hi,

There is not much said about assemby routines from C its more
implementation specific stuff.
However this is what the C89 standard has to say -

A.6.5.10 The asm keyword


I think you will find Appendix A.6.5 (Appendix J.5 in ISO 9989-1999) is
a list of "common extensions". In 9989-1999, asm() and the rest of
appendix J.5 is headed with this caveat
"The following extensions are widely used in many systems, but are not
portable to all implementations. The inclusion of any extension that
may cause a strictly conforming program to become invalid renders an
implementation nonconforming. Examples of such extensions are new
keywords, extra library functions declared in standard headers, or
predefined macros with names that do not begin with an underscore."

asm() falls into this category (it is J.5.10 in 9989-1999).
- --

Lew Pitcher, IT Specialist, Enterprise Data Systems
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed here are my own, not my employer's)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFCcly0agVFX4UWr64RApMgAKCDR6AEjtfTcPlJNQmbrY Sk6M3a4ACgo8S5
49ppFsLG8fI/O9/n3/J0lWM=
=8zhb
-----END PGP SIGNATURE-----
Nov 14 '05 #5
Ravi Uday <ra******@gmail.com> writes:
Sachin wrote:

[...]
I am calling this routine in c function like that:

extern void asm(void);

void foo()
{
asm();
}

On compiling, error message comes that
symbol asm unresolved.

Could any one tell that how I can do it for GHS.


There is not much said about assemby routines from C its more
implementation specific stuff.
However this is what the C89 standard has to say -

A.6.5.10 The asm keyword

The asm keyword may be used to insert assembly-language code
directly into the translator output. The most common implementation
is via a statement of the form

asm ( character-string-literal );

So make sure you pass a character-string-literal as a param, not a void !


I think you've missed the point.

The use of "asm" as a keyword is mentioned as a common language
extension; it's non-standard. It's generally a way to insert assembly
language instructions inline into C code, as if they were statements.
For example:

...
printf("About to do some register manipulation\n");
asm("mov R0, R1");
printf("Done\n");
...

The OP's implementation obviously does not implement an "asm" keyword,
since he's using "asm" as a function name.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
by: nospam | last post by:
Just wondering, What do you think the difference in performance would be between (1.) Compiled C# (2.) Compiled C++ (3.) and Assembly Language And how would the mix be if some if any of...
1
by: Zachary Hartnett | last post by:
I was trying to write a routine this morning that would open a given assembly, walk the inheritance tree of classes in the assembly, and provide a list of classes in the assembly that inherit from...
13
by: Bern McCarty | last post by:
I have run an experiment to try to learn some things about floating point performance in managed C++. I am using Visual Studio 2003. I was hoping to get a feel for whether or not it would make...
4
by: Phil Galey | last post by:
I created an About box and am able to get all the assembly information from the program to show up in the About box except the Version. I created the About box as a separate Windows application,...
7
by: Kevin Frey | last post by:
Using .NET 1.1. We have a mixed-mode assembly written in Managed C++ that we are using from an ASP.NET application that has been coded using C#. The mixed-mode assembly has its own...
3
by: Shawnk | last post by:
I use two classes to manage the Main() command line (and alot of other stuff) for my prototyping environment. I tryed putting the MainClass in a DLL and just having the other class (which gets...
3
by: keith | last post by:
If I declare a variable and set it = nothing then pass it byref into a routine that accepts an optional argument of the same type with a default of nothing, is there anyway to determine where the...
2
by: Peted | last post by:
I have 2 samples of code bellow that work fine at the moment the first routine loads an dll assembley and instantiates the type in the dll which is always a form, and creates a child form from...
2
by: pvong | last post by:
I'm a newbie. I'm using VS2008 & VB.net I have a simple site and each page uses the same sub-routine. I copy and paste to each page and that's no big deal but that can get tiresome. I was...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.