| ??? 02/05/04 00:16 Read: times |
#64024 - RE: how define the buffer at particular memo Responding to: ???'s previous message |
// this declares the buffer
xdata volatile unsigned char Buffer[100] _at_ 0x8000; But there is generally no reason at all to fix it at a specific address. Why do you want to? // this puts the address of the buffer into the pointer
xdata volatile unsigned char *ptrBuff = Buffer; Which illustrates why there is usually no need to fix the address at compile time! Apart from the 'xdata' keyword extension, this is all standard 'C' - not specifically Keil To store the byte:
*ptrBuff = value; To read the byte: value = *ptrBuff; to increment the pointer to look at the next location: ptrBuff++; the read the value THEN increment the pointer: value = *ptrBuff++; All of this is completely vanilla, plain, standard 'C' - nothing specific to Keil at all The same end can be achieved by indexing - again, completely standard and nothing specifically to do with Keil: To store the byte: Buffer[index] = value; To read the byte: value = Buffer[index]; to increment the index to look at the next location: index++; To read the byte and then increment the index to look at the next location: value = Buffer[index++]; People often say that the pointer approach is more efficient than indexing, but this is not necessarily so - it depends very much on the precise structure of your code. As always, if this is really important to you, the only thing to do is to inspect the generated code. |
| Topic | Author | Date |
| how define the buffer at particular memo | 01/01/70 00:00 | |
| RE: how define the buffer at particular memo | 01/01/70 00:00 | |
RE: how define the buffer at particular memo | 01/01/70 00:00 | |
| RE: how define the buffer at particular memo | 01/01/70 00:00 |



