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

Is it mistake to force PC to specific address?

I want to make mechanism to force my processor (LPC2378) to do one program if some flag is set and to do another if that flag isn't set.
But that two programs may have functions with same name and I want to insure that right one will be executed.

Parents
  • If you want to jump to a fixed address in C you can just do something like:

    #define FN_ADDR 0x6000 // be sure to set the low bit if the destination is Thumb state code

    ...

        ((void (*)(void))FN_ADDR)();

    ...

    Or, if you're not a fan of brevity:

    ...

        typedef void fn_t(void);

        ((fn_t *)FN_ADDR)();

    ...

    The cast is technically undefined behavior, but it'll do "the right thing".

Reply
  • If you want to jump to a fixed address in C you can just do something like:

    #define FN_ADDR 0x6000 // be sure to set the low bit if the destination is Thumb state code

    ...

        ((void (*)(void))FN_ADDR)();

    ...

    Or, if you're not a fan of brevity:

    ...

        typedef void fn_t(void);

        ((fn_t *)FN_ADDR)();

    ...

    The cast is technically undefined behavior, but it'll do "the right thing".

Children
No data