AnsweredAssumed Answered

Calling C function from assembly code

Question asked by Iks on Jun 6, 2012
Latest reply on Jun 13, 2012 by Mitesh

Hello everybody.


I have a problem calling a C function from assembly code for SHARC-21369. This is my test function which is located in file ping_detect.c:


unsigned int ping_detect(void)


    return 7;



And this is a piece of my assembly code (all project is written in assembly except for the function above):


.EXTERN _ping_detect; // this is defined in ping_detect.c

.TYPE   _ping_detect, STT_FUNC;






   // calling function

          cjump _ping_detect (db);


          // returning

          dm(i7, m7) = r2;

          dm(i7, m7) = pc;


   nop; // <-- BREAKPOINT HERE






When I try to execute the program, ping_detect function executes ok and r2 contains 7 (expected return value). But after cjump program returns to _main. So the breakpoint never hits. What's wrong here?