LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-03-2003, 06:17 AM   #1
grub
Member
 
Registered: Mar 2003
Location: Kurnool, India.
Distribution: Redhat 9
Posts: 67

Rep: Reputation: 15
Using asm code in C program.


How can we access asm code in C.

suppose one file functions.asm contains all the functions defined.
And main.c contains the program.
Do I need to access the asm functions in my program using 'asm' keyword
or I can just use the function name given in the asm file.
Or do I need to compile the asm file and use it as include at the time of compilation of my main program.

Please do reply a sequence.
Though I did lot of programming in C, I never tried this.
 
Old 04-03-2003, 07:20 AM   #2
tda
Member
 
Registered: Mar 2002
Location: Ukraine, Kiev
Distribution: Mandrake 7.2
Posts: 37

Rep: Reputation: 15
It depends on what os/compiler you use.
In general you can declare functions in header file, define functions, in asm file and use them in c file. In this way you have to link object files generated from c and asm files together. But there are many specific things which is depend of os/compiler. For example in DOS/Windows you have to define function name in asm file with first char '_' (i.e. suppose in header you define "int dosomething()" but in asm defination yu have to declare it as "_dosomething" ).
Keyword asm (or __asm, _asm in some C dialects) is used to write asm commands direct in C code, i.e __asm cli;. In many cases this approach is preffer because can avoid many specific troubles. From other side embedded assembler can introduce some restriction to use some futures of assembler language (restricted command set etc.).
 
Old 04-03-2003, 11:00 PM   #3
grub
Member
 
Registered: Mar 2003
Location: Kurnool, India.
Distribution: Redhat 9
Posts: 67

Original Poster
Rep: Reputation: 15
Thanx tda, the information given is really good. I think now I have to give a try to check my skills.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Have you seen such asm code? snowing Programming 2 07-07-2005 05:13 AM
c code: how to exec a external program in c feetyouwell Programming 3 04-04-2005 10:44 PM
Viewing source code for a program... ksoma Programming 3 02-27-2005 04:05 AM
How do I code network analysis program.? sebustian Linux - Networking 0 09-19-2004 06:14 AM
The program returned an error code (3) Omega Linux - Software 1 05-04-2003 09:47 PM


All times are GMT -5. The time now is 11:08 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration