Keil Logo Arm Logo

Discussion Forum

Interface a assambler prog. in a C-Prog.

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Read-Only
Author
Daniel Lembacher
Posted
3-May-2001 13:33 GMT
Toolset
C51
New! Interface a assambler prog. in a C-Prog.
How Can I interface a assambler -file in a C-Code??
Read-Only
Author
James Wilkinson
Posted
3-May-2001 14:00 GMT
Toolset
C51
New! RE: Interface a assambler prog. in a C-Prog.
Search the knowledgebase for an example maybe?

Read the C51 primer and/or the getting started and creating applications

Attempt to code it and then ask for help when problems arise.

There's a lot of information already on the keil site on this subject ( as its not exactly straightforward ), have you checked already?
Read-Only
Author
Jon Ward
Posted
3-May-2001 15:43 GMT
Toolset
C51
New! RE: Interface a assambler prog. in a C-Prog.
Check the following:

http://www.keil.com/support/docs/1671.htm

Jon
Read-Only
Author
Changhua Wang
Posted
8-May-2001 05:14 GMT
Toolset
C51
New! RE: Interface a assambler prog. in a C-Prog.
How to insert asm code in c file.
I don't want to generate asm file
and not to call asm function.
How can I do ?

example :

void f1(void)
{
...
...
nop
...
}

how to write in Keil C compile ?

Read-Only
Author
uu rt
Posted
8-May-2001 09:46 GMT
Toolset
C51
New! RE: Interface a assambler prog. in a C-Prog.
Out of curiosity, I found the answer to your question. Its easy, just dig the knowledge base....



QUESTION

Is there an example of how to mix C and assembly?


ANSWER

The following example program shows you how to mix C and assembly in your 8051 programs.

This example starts with a MAIN C function which calls a routine in assembly which then calls a C function.

The MAIN C module appears as follows:

extern void a_func (void);

void main (void)
{
a_func ();
}


The function a_func is an assembly routine:

NAME A_FUNC

?PR?a_func?A_FUNC SEGMENT CODE
EXTRN CODE (c_func)
PUBLIC a_func

RSEG ?PR?a_func?A_FUNC
a_func:
USING 0
LCALL c_func
RET

END


Note that this assembly routine calls c_func which is a C function:

void c_func (void)
{
}


The actual code for the assembly module was generated using the SRC pragma and the following C source file:

extern void c_func (void);

void a_func (void)
{
c_func ();
}


You may download C2ASM2C.ZIP from the Keil web site.
Read-Only
Author
Andrew Neil
Posted
8-May-2001 10:03 GMT
Toolset
C51
New! RE: Interface a assambler prog. in a C-Prog.
I found the answer to your question. Its easy, just dig the knowledge base....

Easier yet: just read the manuals which came with your compiler! ;-)



Read-Only
Author
Hans-Bernhard Broeker
Posted
21-Jul-2003 12:16 GMT
Toolset
C51
New! RE: Interface a assambler prog. in a C-Prog.
How to insert asm code in c file. I don't want to generate asm file and not to call asm function.

You've just said you want a recipe for making omelettes without breaking any eggs. The answer to that is the same as in the kitchen case: no way.
Read-Only
Author
Frank Hu
Posted
21-Jul-2003 17:44 GMT
Toolset
C51
New! RE: Interface a assambler prog. in a C-Prog.
Hi Changhua,

You can use #pragma asm, #pragma endasm to insert pure asm code in your c code, and please don't forget to check the options of Assemble SRC file and Generate Assembler SRC file.

But to me the best solution is to put the asm code into asm file, then you can avoid many headaches later. You will know what I mean when you go through it yourself.

Hope it will help you out!

Frank
Read-Only
Author
Andrew Neil
Posted
3-May-2001 16:32 GMT
Toolset
C51
New! RE: Interface a assambler prog. in a C-Prog.
Of course, you have read the section "Interfacing C Programs to Assembler" in the manual, haven't you?

Which bit was not clear to you?

(You can open the manual by going to the 'Books' tab in the uVision Project window, and choosing "C51 User's Guide")
Read-Only
Author
Manish Sharma
Posted
18-Jul-2003 17:33 GMT
Toolset
C51
New! RE: Interface a assambler prog. in a C-Prog.
I want to download this software as i wanted to convert an assambly prog. to c.
So do help me
Thanks
Read-Only
Author
erik malund
Posted
18-Jul-2003 18:10 GMT
Toolset
C51
New! RE: Interface a assambler prog. in a C-Prog.
i wanted to convert an assambly prog. to c.
a purely manual function. You can NOT 'convert' an assembly program to C, you can only code the same function in C.

Erik
Read-Only
Author
Andy Neil
Posted
19-Jul-2003 01:32 GMT
Toolset
C51
New! RE: Interface a assambler prog. in a C-Prog.
"i wanted to convert an assambly prog. to c."

Why?

Next Thread | Thread List | Previous Thread Start a Thread | Settings

arm-logo-small

Keil logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.