A.1.3 Generating a Code that Accesses Variables in the Declared Size

When accessing a variable in its declared size, the __evenaccess extended function should be used.

The __evenaccess declaration guarantees access in the size of the variable type. The guaranteed size is a scalara type (signed char, unsigned char, signed short, unsigned short, signed int, unsigned int, signed long, or unsigned long) of four bytes or less.

The __evenaccess is invalid to the case of accessing of members by a lump of these structure and union frame.

When a structure or union is specified, the __evenaccess declaration is effective for all members. In such a case, the access size of a scalara type member of four bytes or less is guaranteed but the access size for the whole structure or union is not guaranteed.

 

[Example]

C source code

#pragma address A=0xff0178
unsigned long __evenaccess A;
void test(void)
{
     A &= ~0x20;
}

 

Output code (when __evenaccess is not specified)

_test:
     MOV.L #16712056,R1
     BCLR #5,[R1] ; 1-byte memory access
	     RTS

 

Output code (when __evenaccess is specified)

_test:
     MOV.L #16712056,R1
     MOV.L [R1],R5 ; 4-byte memory access
     BCLR #5,R5
     MOV.L R5,[R1] ; 4-byte memory access
     RTS