Hello,
I am using a C compiler on ARM processor based system (32 bit).
I m executing following code on this system:
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Foo (void)
{
unsigned long base_addr = 0x3001E000; // sizeof (unsigned long)
== 4
unsigned long temp;
temp = ((volatile t_uint16*) base_addr + 0x0220); // STATEMENT 3
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
I thought that the value of temp would be 0x3001E220. But when I
execute this function, I get the value of temp as 0x3001E440.
Can anyone please explain why this is happening?
I tried to see the assembly language (ARM) code for STATEMENT 3.
It is generated as following:
///////////////////////////////////////////////////////////////////////////
LDR r0,0x37548 // &base_addr = 0x37548
LDR r0,[r0]
ADD r4,r0, #0x440 // ??????
///////////////////////////////////////////////////////////////////////////
The compiler directly generates the code to add 0x440.
Please help me understand why this happens.
Thanks in advance.