I wonder how the LAC, LAS and LAT instructions work.
I can imagine two possibilities. I think they simply combine 3 instructions into 1. They do a fetch of 8 bits, wiggle one of them, and store 8 bits. That would be a nice instruction but I don't think I need it bad enough to figure out how to get the compiler to use it.
The other possibility would be more interesting. It could set or clear one bit without touching the other 7 bits. I'm guessing this is not the case, but I'd like to find out.
I'm attaching a bit of the datasheet where it seems to use "AND" or "OR" to describe them, which makes me think the first description is the right one.
I'm interested because I've been looking at the USB description in the data sheet. The endpoint registers are interesting as they are in RAM. Even more interesting is the status register. It seems that the software needs to be able to clear at least one of the bits. To make it yet more interesting, some of the bits are cleared by writing a 1 to their bit position and others are cleared by writing a 0 to their bit position. This could be a typo, there seem to be several of them. But this is so bizarre, I think it is true.
I looked at the ASF and it seems to use macros LASR16..... and LACR16..... to do this. These turn into assembler code. I'm including a bit of the code but using
// Load and Clear #ifdef __GNUC__ #define LACR16(addr,msk) \ __asm__ __volatile__ ( \ "ldi r16,
1" "\n\t" \ ".dc.w 0x9306" "\n\t"\ ::"z" (addr), "M" (msk):"r16") #else #define LACR16(addr,msk) __lac((unsigned char)msk,(unsigned char*)addr) #endif