From C, inline assembly LJMP to Numerical Address

How do I perform a long jump to a numerical address from my C code?
I'm pretty sure I have to do this with inline assembly - however that
seems complicated for C51. I figured in C I could do this:

typedef void (*jmpPtr)(void);
jmpPtr jmp;

...

unsigned int address = 0x4000U;
jmp = (jmpPtr) address;
(*jmp)();

Except for the call differences, I think this would be the same as doing
a jump to the numerical address? Keil, is this correct?

Parents
  • Having recently done this for a project, I know that the following code produces an LJMP instruction when placed at the end of a function (which it likely would be, given it's application):

    #define JMP_TARGET_ADDR ((unsigned char code *)0x4000)
    
    /* At end of function here... */
    
        ((void (*)())JMP_TARGET_ADDR)();
    }
    

    -- Dan Henry

Reply
  • Having recently done this for a project, I know that the following code produces an LJMP instruction when placed at the end of a function (which it likely would be, given it's application):

    #define JMP_TARGET_ADDR ((unsigned char code *)0x4000)
    
    /* At end of function here... */
    
        ((void (*)())JMP_TARGET_ADDR)();
    }
    

    -- Dan Henry

Children
More questions in this forum