Hi all,
I am stuck onto a rare problem that I try to expose next.
First, I got somewhere within the code the variable W_dp_0 declared like:
extern unsigned char W_dp_0;
W_dp_0 is actually initialized inside a library into which I don't have access at all.
Now I show you the beginning code of function Compose_Prot(), the last line of which is the one that's causing the problem:
void Compose_Prot (void){ bool is_valid = FALSE; char val[7]; char st1, st2, st3; unsigned char j = (unsigned char) W_dp_0;
At the disassembler window I have the lines shown next, that correspond to the assignment to j:
0x080006BA 4882 LDR r0,[pc,#520] ; @0x080008C4 0x080006BC 7805 LDRB r5,[r0,#0x00]
The memory map is like:
0x080008c4 C7 01 00 20 0x080008c8 13 01 00 20
and at the address of W_dp_0:
0x200001c6 02 03 04 01 0x200001ca 00 00 0A 00
So that after the execution, R0 is
0x200001C7
and R5, which corresponds to j variable:
0x00000003
But, if I now print values of variables in the command window I see that:
> W_dp_0 0x01040302 > &W_dp_0 0x200001C6 > (unsigned char) W_dp_0; 0x02 > j 0x03
So why j equals 0x03 and not 0x02 as expected and agreed to the Command Window? What else can I do to find any clue that helps me find a reason? And finally, why the disassembler computes the address 0x080008C4, instead of 0x80008c2 that would correspond to the addition of PC + 520 ( 0x080006ba + 520 ) ?
Thanks in advance,
Carles