ARM C compiler expression evaluation doubt!
- From: "Bhavik" <bhavik.patel@xxxxxxxxx>
- Date: 5 Apr 2007 04:30:06 -0700
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.
.
- Follow-Ups:
- Re: ARM C compiler expression evaluation doubt!
- From: David Thomas
- Re: ARM C compiler expression evaluation doubt!
- Prev by Date: Re: Who is working with the SAM9263?
- Next by Date: Re: ARM C compiler expression evaluation doubt!
- Previous by thread: MX31 GPIO
- Next by thread: Re: ARM C compiler expression evaluation doubt!
- Index(es):
Relevant Pages
|