Pointers gone mad!



Hello,

This is a simple questions about pointers! I can't believe I am asking this.
But here it goes. Please note that an integer is 8 bits long (1 byte)! Please
view question which is commented in code below.

=====================================Calling routine!
int spiA0=0,spiA1=0,spiA2=1;

//INCREMENT_ADDRESS BY AMOUNT OF INCREMENTATIONS REQUIRED
INC_ADDR(16,&spiA2, &spiA1,&spiA0);

=========================================Function!
void INC_ADDR( //***INCREMENT_ADDRESS***
int INCBY, //AMOUNT OF INCREMENTATIONS REQUIRED
int *A2, //MSB OF MESSAGE ADDRESS IN PAR FLASH
int *A1, //MIDSB OF MESSAGE ADDRESS IN PAR FLASH
int *A0) //LSB OF MESSAGE ADDRESS IN PAR FLASH
{
int i;

for(i=0;i<INCBY;i++)
{
if((*A0)==255) //Before A0 turns to 0, statement is true
{(*A1)++; //Increment central byte of flash adress
if((*A1)==255) //Before A1 to 0, statement is true
{ (*A2)++; //Increment MSBYTE of flash adress
}
}
/////////When the next line is executed (While i=0 during 1st iteration of
for loop)
//////// A0 increments to 1. But why does A1 get assigned the value of
256?????
(*A0)++;
}
}
================================================

Confused!

--
Best regards
Robert
.



Relevant Pages

  • Re: Pointers gone mad!
    ... Sincere regards and happy holidays Igor! ... int INCBY, //AMOUNT OF INCREMENTATIONS REQUIRED ... //MIDSB OF MESSAGE ADDRESS IN PAR FLASH ...
    (microsoft.public.vc.language)
  • Re: Pointers gone mad!
    ... This is why I was confused when you used an int! ... Best regards ... //MIDSB OF MESSAGE ADDRESS IN PAR FLASH ... if {// previous increment overflowed ...
    (microsoft.public.vc.language)
  • Re: Pointers gone mad!
    ... Robby wrote: ... int INCBY, //AMOUNT OF INCREMENTATIONS REQUIRED ... //MIDSB OF MESSAGE ADDRESS IN PAR FLASH ... the value of 256 (256 doesn't fit into 8 bits). ...
    (microsoft.public.vc.language)
  • Re: Pointers gone mad!
    ... You mean you're storing an 8-bit quantity in an int, ... //MIDSB OF MESSAGE ADDRESS IN PAR FLASH ... I reformatted your loop so I could read it more easily and changed all the ... postfix to prefix, because it's possible to do so here without changing the ...
    (microsoft.public.vc.language)
  • Re: A taxonomy of types
    ... I am describing how to represent the representation (and, ... if the system follows static typing rules (such as in a compiler), ... so, the hardware sees pointers and pointer arithmetic, but the compiler ... "Besides the char types, up to three sizes of integer, declared short int, ...
    (comp.lang.misc)