Want to know the difference

I want to know the differences between the following two definiations:

 (*((volatile char xdata *)( CHIP_BASE + i)))

 ((volatile char xdata *)( CHIP_BASE + PTR_BASE + PTR_SIZE * i))

Thank you.

Parents
  • (*((volatile char xdata *)( CHIP_BASE + i)))
    ((volatile char xdata *)( CHIP_BASE + PTR_BASE + PTR_SIZE * i))

    There are two major differences. First one of them is an object in an array (which you would usually just write as
    array[i]
    ), the other is a pointer to an object in an array (written as
    &array[i]
    by newbies, or just
    array + i
    by more experienced people). In other words, they differ by one level of referencing.

    The second difference is that the layout of those two arrays is rather different. One is accessed as if it actually was what the pointer type in the cast says it is: an array of chars; the other is accessed like an array of things called "PTR"s, of size "PTR_SIZE". The second one is thus likely a bad idea of doing whatever it's supposed to do.

Reply
  • (*((volatile char xdata *)( CHIP_BASE + i)))
    ((volatile char xdata *)( CHIP_BASE + PTR_BASE + PTR_SIZE * i))

    There are two major differences. First one of them is an object in an array (which you would usually just write as
    array[i]
    ), the other is a pointer to an object in an array (written as
    &array[i]
    by newbies, or just
    array + i
    by more experienced people). In other words, they differ by one level of referencing.

    The second difference is that the layout of those two arrays is rather different. One is accessed as if it actually was what the pointer type in the cast says it is: an array of chars; the other is accessed like an array of things called "PTR"s, of size "PTR_SIZE". The second one is thus likely a bad idea of doing whatever it's supposed to do.

Children
More questions in this forum