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)();
First, why all the hoops (eg typedef)?
Just: void (code *jump)(void) = 0x4000; and: jump();
First, why all the hoops (eg typedef)? Just to make it more readable I suppose. Setjmp() and longjmp() save the state from one code point to another and doesn't allow for specifying an address. The reason I need an address is because I am going to dynamically program Flash and then execute code out of the just-programmed Flash.
Just to make it more readable I suppose. I'm not sure I'd agree that 5 lines is more readable than 2. To each their own. Setjmp() and longjmp() save the state from one code point to another and doesn't allow for specifying an address. Good point. If you don't like the LCALL then you'll have to use some assembler I'm afraid. How bad is the LCALL implementation for you? - Mark