This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Need explination of these two decloration software lines

What do the following lines do? Generaly not specificaly.

What do the terms mean/and or do? 1) xdata * xdata mean? 2) s_pSIN = (MASTER_2_AFPU*)&s_SIN;

static xdata uchar s_SIN[sizeof(MASTER_2_AFPU)];
static MASTER_2_AFPU xdata * xdata s_pSIN = (MASTER_2_AFPU*)&s_SIN;

  • Note that you can have a pointer that are stored in xdata memory.

    And you can have a pointer that points to an object stored in xdata memory.

    And then you can have a pointer stored in xdata memory, and pointing to an object in xdata memory. Hence the need for one xdata attribute before, and one after the star.

  • For question 1, please do consult the C51 manual. 'xdata' is a language extension, and you really have to study the documentation thoroughly to use it.

    As to what this:

    static xdata uchar s_SIN[sizeof(MASTER_2_AFPU)];
    static MASTER_2_AFPU xdata * xdata s_pSIN = (MASTER_2_AFPU*)&s_SIN;
    

    does: this is a somewhat silly detour for defining a pointer to an object of type MASTER_2_AFPU. s_SIN is a buffer of the right size for such an object, but of the wrong type. s_pSIN is meant to access that space as if it were of type MASTER_2_AFPU.

    Whether or not this code is correct or not depends on the unknown definition of MASTER_2_AFPU. If that's anything else but a an array of unsigned char itself, the code is sick.

  • Do you have a referance for xdata?

    This is a piece of contracted software that I suspect that the authors purposely making it obscure what are your thoughts? I appreciate your answer thank you very much.

  • This is a piece of contracted software that I suspect that the authors purposely making it obscure what are your thoughts?

    "Don't attribute to malice what can properly be explained with negligence."

    It's not all that obscure - if the author really wants to obscure the code, then he's doing a really poor job at it.

    It looks more like whoever wrote this is single-mindedly following conventions without considering if they make sense in the current context.

  • Do you have a referance for xdata?

    What kind of reference ? What the keyword xdata does ? That is explained, in great detail and with examples, in the C51 compiler manual.