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

Combining C and assembly codes

Would appreciate if someone can tell/show me how to combine C and assembly code in the Uvision 2?

Parents
  • Hi Mark/Andrew,

    Read through your advice to others. Splendid! Maybe either of you can assist me too.
    I came across this forum when I am seeking for some quick guide of sharing code of different files of C and .a51.

    Calling each other from C to get the function written in .a51 or vice-versa is completed. Went through c2asm2c.zip and it worked perfectly. However, I encounter some trouble when I need to pass on some variables that need to be manipulated from .a51 to .c
    My case:-

    Main code is in .a51. Requires to call a function that adds 20 slightly different 8bit data bytes and then take its average (i.e. by division).

    Writing the function above in .a51 is a pain due to unavailable 16bit-addition in 8051 done under Keil uV2.

    My solution thought:- is to write the addition function in C so addition can be done much more easily.

    Problem:- how do I pass the variables/registers defined in .a51 to the C function to be called from .a51 environment? The C function failed to recognize the similar declared register under .a51 before. Do I need to declare them under a new name OR use the similar name of data registers OR can use some global declaration of data registers. But how?

    Appreciate some really cool advice if available.

    Cheers,
    James

Reply
  • Hi Mark/Andrew,

    Read through your advice to others. Splendid! Maybe either of you can assist me too.
    I came across this forum when I am seeking for some quick guide of sharing code of different files of C and .a51.

    Calling each other from C to get the function written in .a51 or vice-versa is completed. Went through c2asm2c.zip and it worked perfectly. However, I encounter some trouble when I need to pass on some variables that need to be manipulated from .a51 to .c
    My case:-

    Main code is in .a51. Requires to call a function that adds 20 slightly different 8bit data bytes and then take its average (i.e. by division).

    Writing the function above in .a51 is a pain due to unavailable 16bit-addition in 8051 done under Keil uV2.

    My solution thought:- is to write the addition function in C so addition can be done much more easily.

    Problem:- how do I pass the variables/registers defined in .a51 to the C function to be called from .a51 environment? The C function failed to recognize the similar declared register under .a51 before. Do I need to declare them under a new name OR use the similar name of data registers OR can use some global declaration of data registers. But how?

    Appreciate some really cool advice if available.

    Cheers,
    James

Children
No data