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

LJMP in C?

What's the best way to do this in C?

#pragma ASM
LJMP APP_START; //Run app
#pragma ENDASM

..or, is that it?

APP_START does not exist. This is the launch point of an application loader. The actual app will be done as an entirely different project to be loaded higher in memory at a later time.

Thanks.

Parents
  • The language per se doesn't really have the notion of a call that doesn't return.

    ... with the possible exception of the standard library function exit() which does just that ;-)

    A return from the end of main would achieve the same thing, i.e. the "C way" of doing this would be to terminate the loader's main() like this:

    typedef void (*t_application)(void);
    
    t_application application = 0;
    
    void main() {
      /* do stuff here */
      /* ... */
    
      if (!application)
         while(1)
            ; /* endless loop */
      application();
    }

    The compiler may implement the call to application() either as a LCALL followed by a RET, or (if the relevant optimization flag is on) it'll condense those two into an LJMP. To the application code that cannot make a big difference: at most, its stack is a couple of bytes smaller than it could be.

Reply
  • The language per se doesn't really have the notion of a call that doesn't return.

    ... with the possible exception of the standard library function exit() which does just that ;-)

    A return from the end of main would achieve the same thing, i.e. the "C way" of doing this would be to terminate the loader's main() like this:

    typedef void (*t_application)(void);
    
    t_application application = 0;
    
    void main() {
      /* do stuff here */
      /* ... */
    
      if (!application)
         while(1)
            ; /* endless loop */
      application();
    }

    The compiler may implement the call to application() either as a LCALL followed by a RET, or (if the relevant optimization flag is on) it'll condense those two into an LJMP. To the application code that cannot make a big difference: at most, its stack is a couple of bytes smaller than it could be.

Children
No data