5.11 __indirect_jump_to Intrinsic Function
The IAR __indirect_jump_to
intrinsic function jumps to the specified address via
a ijmp
or eijmp
instruction.
Suggested Replacement
There is no MPLAB XC equivalent built-in function; however, these instructions can be inserted explicitly using in-line assembly code.
Use in-line assembly to directly write an ijmp
or
eijmp
instruction.
Caveats
Where an eijmp
instruction has been inserted, make sure to restore
the state of the EIND register afterward.
Examples
Consider migrating IAR code such
as:
void leap(unsigned long addr) {
__indirect_jump_to(addr);
}
to
MPLAB XC8 code similar
to:#include <xc.h>
unsigned char indirect_jump(unsigned long addr) {
#ifdef __AVR_HAVE_EIJMP_EICALL__
/* Extract 3rd byte of address to h */
unsigned char h = addr >> 16;
/* Record existing EIND reg val in res */
unsigned char res;
__asm__("in %[EIND_SAVED], %[EIND_REG] \n\t"
"out %[EIND_REG], %[HH] \n\t"
"movw r30, %[ADDR] \n\t"
"eijmp \n\t"
: [EIND_SAVED] "=&r" (res)
: [HH] "r" (h),
[ADDR] "r" ((unsigned int)addr),
[EIND_REG] "I" (_SFR_IO_ADDR(EIND))
: "r30","r31");
return res;
#else
__asm__("movw r30, %0 \n\t"
"ijmp \n\t"
: : "r" ((unsigned int)addr) : "r30","r31");
return 0;
#endif
}
void leap(unsigned long addr) {
indirect_jump(addr);
}
Further Information
See the In-line Assembly section in the MPLAB XC8 C Compiler User's Guide for AVR MCUs for more information on this qualifier.