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
  • probably ";Do alotta other stuff" blow up because it depend on the C fumction not changing registers.

    a C function may change any register and there is not guarantee that changing release, optimization or whatever will not change which registers

    do not rely on stupid so called "testing" to see what has changed, save EVERYTHING, the next time you touch the C the registers changed will, most likely, change.

    Erik

Reply
  • probably ";Do alotta other stuff" blow up because it depend on the C fumction not changing registers.

    a C function may change any register and there is not guarantee that changing release, optimization or whatever will not change which registers

    do not rely on stupid so called "testing" to see what has changed, save EVERYTHING, the next time you touch the C the registers changed will, most likely, change.

    Erik

Children
No data