ARM C compiler expression evaluation doubt!



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.

.



Relevant Pages

  • Re: expression evaluation doubt!
    ... I am using a C compiler on ARM processor based system. ... I m executing following code on this system: ... void Foo (void) ... Usenet, 67 is better. ...
    (comp.lang.c)
  • expression evaluation doubt!
    ... I am using a C compiler on ARM processor based system. ... I m executing following code on this system: ... void Foo (void) ...
    (comp.lang.c)
  • Re: expression evaluation doubt!
    ... I am using a C compiler on ARM processor based system. ... I m executing following code on this system: ... void Foo (void) ... I thought that the value of temp would be 0x3001E220. ...
    (comp.lang.c)
  • Re: expression evaluation doubt!
    ... I am using a C compiler on ARM processor based system. ... I m executing following code on this system: ... void Foo (void) ...
    (comp.lang.c)
  • Re: Non-constant initializers
    ... and one in which variable declarations ... logically "executed" as you hit them, except that executing them consists of ... In C, though, things aren't being "executed" when the compiler sees them. ... int bar ...
    (comp.lang.c)