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 write some code for a microcontroller (251 family) in C language. depending on some stuff, i will continue in a way or another way, so i will call the desired function as Function(); This will lead to an ECALL in asm, which mean PC up on the stack.. How can i explain to compiler that a EJMP is desired in my case, i do not need to come back ever, i do not need the PC on the stack (remember, i do this in C...) The function called is (also) in another C file (not the same file), where there are more files into one project. Any suggestion would be appreciated, thanX
Hi Ioan! I'm a begginer, but if I were in your place, I would try to use the "barbarian" goto. I mean that I would try to put a label at the beginning of Function() like: void function (void) label: { ... }
and use the goto label; // when I want to go somewhere I will // never come back from It is completely wrong? Adrian
Hi, is not working, the function I want to EJMP instead of ECALL is in another C file... or is there any way to do it ? (I don't care about avoiding "goto" instruction as long it will translate into a JMP while there are, anyway, tons of jmp (or variants) in the generated code...)...
"It is completely wrong?"
Yes. That's not valid C plus goto labels are limited to having function scope.
In C the goto is local to the function.
Ioan Why you want to do that . If you elaborate the requirement may be somebody can come up with some solution.
Suvidh
i have some intrinsic functions defined in keil stuff which tells to compiler to use basic asm commands (intrinsic.h), so, using this command _ejmp_ (<address>); will be translated in ASM as EJMP <address> but i cannot see how the locator will write inside the address... any suggestion ?
i have a software with some branches with <no_return> statements I was just wondering how can i do that avoiding an ECALL...
"In C the goto is local ..."
There seems to be an echo in here.
Is _ejmp_ an intrinsic command in keil c51 ?
I had never came across such intinsic command.
What we have in keil intrins.h is _chkfloat_ _crol_ _cror_ _irol_ _iror_ _nop_ _pop_ _push_ _testbit_
And for proper functioning of your program even if you jump from C routine you will have to come back to the point you left the function.
the function I want to EJMP instead of ECALL is in another C file
That shouldn't make any difference. The change from CALL to JMP can be decided on by the compiling seeing only the calling function and a prototype declaration of the called one. And the called function has to have the same return type as the called one --- preferrably void.
Ioan, you've now explained multiple times what you're doing, but you still haven't answered the question why you think this is what you should be trying to do.
In a nutshell, what you're trying is fundamentally impossible in C (or any other mainstream language, for what it's worth). So your best bet is to re-evaluate the steps that lead you to this program structure, and find another approach.