GCC ARM: Memory not written

Thomas Kolejka Thomas.Kolejka@gmx.at
Fri Feb 11 10:12:00 GMT 2005


Hello,

I'm working on an Arm processor and tried to make the following program run:


typedef unsigned char U1;
typedef U1 * P_U1;


U1 data[100];

int main()
{
  int i;

  U1 *p = 0x87654321;

  P_U1 *p2;

  printf("p: -> %p\n", (void *)p);

  for (i = 0; i < 10; i++)
  {
	 p2 = (P_U1)&data[i];
	 //  ldr	r2, .L10+4
	 //  ldr	r3, [fp, #-16]	@  i
	 //  add	r3, r2, r3
	 //  str	r3, [fp, #-24]	@  p2


	 printf("p2: -> %p\n", (void *)p2);

	 *p2 = p;
	 //   ldr	r2, [fp, #-24]	@  p2
	 //   ldr	r3, [fp, #-20]	@  p
	 //   str	r3, [r2, #0]
	 }

  for (i=0; i < 10; i++)
	 printf("0x%0x ", data[i]);

  printf("\n");
}



The program should write 0x87654321 into every position of data[100] -
therefore overwrite 3 bytes 
of the last write. 
On the PC (Pentium III) this works alright; on the ARM only every fourth
value 
is written to the memory: "str	r3, [r2, #0]" is executed (gdb, ddd: ni), but
nothing happens. 

Including 'asm("str r3, [r2]");' into the code does not work, too.

I've tested a lot of options for gcc and arm-options, but nothing changed. 

This happens with gcc version 2.95.3 and 3.3.2.


Thanks in advance for any help,

Thomas

-- 
Lassen Sie Ihren Gedanken freien Lauf... z.B. per FreeSMS
GMX bietet bis zu 100 FreeSMS/Monat: http://www.gmx.net/de/go/mail

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com



More information about the crossgcc mailing list