We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
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
What optimisation level are you using? Could the common entry/exit code merging be mesing you up? Any clues from sinlge-stepping?
I thought the same thing about losing my registers so I tried to PUSH and POP them before and after the call (in reverse order). That did not solve the problem. I will post additional info on the problem soon. Thanks so far.
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?
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.