5.14 __las Intrinsic Function
The IAR __las
intrinsic function provides access to the las
(Load And Set) instruction, available on AVRxm devices. The las
(Load
And Set) instruction loads the memory contents at the address held by the Z register
into the Rd register specified while simultaneously setting those bits at that same
address held by the Z register that were set in the Rd register.
Suggested Replacement
There is no MPLAB XC8 equivalent built-in function; however, the instruction can be inserted explicitly using in-line assembly code.
Use in-line assembly to directly write an las
instruction.
Caveats
None
Examples
unsigned char loadAndSet(unsigned char regD, unsigned char * Zptr) {
unsigned char set = __las(regD, Zptr);
return set;
}
to MPLAB XC8 code similar to:#include <xc.h>
unsigned char las(unsigned char v, unsigned char * addr) {
__asm__("movw r30, %[ADDR] \n\t"
"las Z, %[Rd] \n\t"
: [Rd] "+r" (v), "+m" (*addr)
: [ADDR] "r" ((unsigned int)addr)
: "r30", "r31");
return v;
}
unsigned char loadAndSet(unsigned char regD, unsigned char * Zptr) {
unsigned char set = las(regD, Zptr);
return set;
}
Further Information
See the In-line Assembly section in the MPLAB XC8 C Compiler User's Guide for AVR MCUs for more information on adding in-line assembly.