The user can specify that a variable should be allocated in a specific RAM bank, or in unbanked RAM. The compiler associates a name with RAM banks or other arbitrary RAM areas. The name appears in #pragma memory declarations in the device header file. The available memory area names depend on the device. To place a variable in a certain named memory area, use the name in the variable declaration.
If required by the application, you can even specify the exact address of a variable. Use the @ symbol to declare the address of the variable. Because you are making a specific declaration for the address, the compiler will not check for conflicts with any other declaration.
The const modifier can be used to specify that the variable is a read-only variable. The compiler writes constant values into ROM.
Figure 5-3. named memory areas var2.lst
0008 int i; /* let the compiler choose the address */ 0300 0010 int bank3 arr[16]; /* allocated this variable in bank3 */ 00F1 int register fast_var; /* allocate this variable in unbanked RAM */ 000F int exact_var @ 0x0F; /* allocate this variable at 0x0F */ 00FE char * ptr @ BREG_ADDRESS; /* allocate this variable in union with the B register */ 7F00 9D FC LD A,X const char str[] = "Hello Byte Craft"; /* create this array in ROM */ 7F02 A4 LAID 7F03 8E RET 7F04 48 65 6C 6C 6F 20 42 79 74 65 7F0E 20 43 72 61 66 74 00