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

array pb

 a Assembly file
dis_buffer:  DS  (%END_ACQ_CHAP+1)*1024+(3*1024)   ;[1][1024]

 a C file
extern unsigned char xdata dis_buffer[8][1024];
.
.
.
dis_buffer[15][(5 * 15) + k] = (dis_buffer[15][k] & mask[(k % 15) % 3]);

I've such an array defined in a assemler module and I try to acces to the same array with the following assignment and compiler dont mention any error. Program built with succes.

I think there must be a problem but nothing happens not any error nor warning...

any help

  • It's quite impossible to judge what might or might not be wrong here, given the incomplete example:

    *) That '%' in your ASM file is a typo, I guess?

    *) what is END_ACQ_CHAP defined to be?

    There is an obvious error in the C part (you're addressing beyond the span of the first index), but due to the way C works, that may be impossible to catch by the compiler, depending on what the part of your C code you snippet away actually is.

  • "dis_buffer: ... ;[1][1024]"

    First dimension: 1

    "extern unsigned ... dis_buffer[8][1024];"

    First dimension: 8

    "dis_buffer[15][(5 * 15) + k] =..."

    First dimension: indexed with '15'.

    What's going on?

  • dis_buffer[15][(5 * 15) + k] = (dis_buffer[15][k] & mask[(k % 15) % 3]);
    What is mask[] ?

    You need to break this down into steps so that you can actually see & check what's going on!

  • ""Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."
    --Brian Kernighan

    That's why I say, "You need to break this down into steps so that you can actually see & check what's going on!"

    You may also need to turn the optimisation down - otherwise the compiler might just optimise it back to where you started!