2004-02-25 09:29 AM
2004-02-23 07:04 AM
This should be an easy one.... I am trying to write a function to modify physical registers by their address (not their name in the IO header file). How can I directly affect an address in C (assuming a Cosmic compiler)? Something like.....
function(char address, char modifier) { //Stub to modify value in address }2004-02-23 08:18 AM
Hi Drew
function(const unsigned int address, char modifier) { // Note address is now int char * pointer_to_register; pointer_to_register = address; // point pointer at the required register *pointer_to_register = modifier; // modify contents of address } // Another method would be to pass the address as a pointer function(char *address, char modifier) { *address = modifier; // modify contents of address } BM2004-02-23 09:15 AM
Hmmm... I got an invalid indirection operand message. Here is what my code looks like:
function() { char temp1, temp2; temp1 = array[offset]; //Array contains address to be modified temp2 = *temp1; } Shouldn't temp2 show the contents of the address stored in temp1? BTW, thanks for the quick response Battman.2004-02-23 10:19 AM
2004-02-25 09:29 AM
Battman,
You would have been 100% correct assuming that my array was initialized as the correct data type. All I had to do to your code was type cast the array. Thanks for your help!