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

Can't return from C func called from ASM

Hello. I have an existing ASM progrom which I am going to convert, as needed, to C. I was succesful at overriding the UART interrupt function (in C). Now, in my main ASM loop I need to check for recieved chars which I will doing in C. When I call my C func from the MAIN func in ASM the 8051 appears to go into a reset loop and will not successfully boot.

===============================
My C Func:
code void CheckForRx (void)
{
if (RxCount!=0) //C global inc'd in INT
DoSomething();
}

==============================

My ASM Main:
extern code (CheckForRx)

Start:
;Do alotta other stuff
lcall CheckForRx
jmp Start

================================


I get no linker warnings (it finds my C func) however that call will not work. Remove the lcall CheckForRx and the system works again.

Any ideas of what I have most likely looked over?

Thanks, Chris

Parents
  • I have determined the problem. I am using a library call in a function that is called from MAIN in ASM. I have read up on reentrants but I cant seem to make this work. I also tried manipulating the function with the OVERLAY BL51 argument which had no results. What options do I have to use library calls in this method?

    If this was an all C project would I have similar problems?

Reply
  • I have determined the problem. I am using a library call in a function that is called from MAIN in ASM. I have read up on reentrants but I cant seem to make this work. I also tried manipulating the function with the OVERLAY BL51 argument which had no results. What options do I have to use library calls in this method?

    If this was an all C project would I have similar problems?

Children
  • I cant seem to make this work

    And until you get round to describing in usable detail how it fails to work, it's basically impossible that anyone else can. If you cannot do the diagnosis yourself, you must at least tell us the symptoms.

    What options do I have to use library calls in this method?

    You're not supposed to need any special options. Just call it, after reading very carefully the relevant sections of the manual on C/asm interaction.

    If this was an all C project would I have similar problems?

    Frankly, that's impossible to say, as long as nobody but you knows what those problems are.