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

How to Mix C and assembly ?

Hello,
I have the following problem:
I need to know as assigning a position fixed of memory (code)to my functions in C and assembly.

Another consultation:
When I call to a function from C to assembly, the program doesn't continue running, it enters to a code section without "code" (without routine). How do I make so that when calling a function from C to assembly I make sure him to return to the main program?
the routine that I use is the following one:
In C:
extern void FUN1(void);
float a, b;

void main (void) {

while (1) {

FUN1();
a=b*5;

..
..
..

}
}

In Assembly:
NAME FUN1
FUNA SEGMENT CODE
FUNN SEGMENT IDATA RSEG FUNN
DS 2
EXTRN CODE (MAIN)
EXTRN CODE (?C_STARTUP)
PUBLIC FUN1
CSEG AT 80H
FUN1: LJMP WATCH
WDTREL DATA 86H
RSEG FUNA
WATCH:
MOV WDTREL,#80H

END

Thank You....

  • The Linker is responsible for assigning addresses to your code - so look up the Linker manual to achieve whatever it is that you require.
    See "Assembler/Utilities" on the 'Books' tab of the uVision Project window.

    In your assembler, I don't see a RET

    Don't forget, when posting code, to use the &ltpre&gt and &lt/pre&gt tags!

  • In general, you should use the linker/locator to place program segments in memory - see BL51 directive CODE.

    Do your assembly language functions have a return instruction at the end?