MPC Product News

The following sections describe new features in Byte Craft Limited Products.

MPC supports aliases in declarations for variables and ports. Address aliases allow the compiler to make memory accesses without altering memory management control bits when possible. This reduces the number of instructions that must be generated for some memory accesses.

Aliases take the form of:

declaration @ addr1,addr2,addr3...

where declaration is the variable or #pragma port declaration, and where addr1 and others are alternate locations for the port or variable.

You can use the alias syntax in RAM and ROM declarations:

#pragma memory RAM ram_space_name [size] @ address1, address2;
#pragma memory ROM rom_space_name [size] @ address1, address2;

Later header files for MPC will use this notation. Older header files will work without this notation, but the compilers will create less efficient code as a result.

You can also use this notation in variable declarations, when specifying the variable's location using the @ sign:

char result @ 0x40, 0xC0;

This tells the compiler that the variable result is available at both locations 0x40 and 0xC0, and the compiler does not need to bank switch if it can access one of the alternate addresses.

The compiler will catch more obvious errors like

char result @ 0x41, 0x85;

because the two addresses are not in the same position within their banks. However, if you were to specify

char result @ 0x40, 0x80;

where 0x40 and 0x80 are not multiply-mapped (are separate memory locations) in your PIC variant, the compiler will not raise an error. The generated code will not bank switch as necessary, and will be therefore unreliable.