This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Interface a assambler prog. in a C-Prog.

How Can I interface a assambler -file in a C-Code??

Parents
  • 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.

Reply
  • 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.

Children