This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

pointer problem


We just got our boot code running and I'm trying to make a simple C++
program. But here's my problem:

#define REGBASE  0x3FF0000
#define IOPDATA  (REGBASE+0x5008)

// LED class
class LED
{
	public:
		LED( unsigned long * );
	...
}

 ... in main

// This code will not work
unsigned long * ioport = ( unsigned long * )IOPDATA;
LED * pLED = new LED( ioport );

// ... but this works!
LED * pLED = new LED( ( unsigned long * )IOPDATA );

Looking at the dump for the code that doesn't work.

	unsigned long * ioport = ( unsigned long * )IOPDATA
10001d4:      e3a03008        mov     r3, #8               ; 0x08
10001d8:      e28337ff        add     r3, r3, #66846720    ; 0x3fc0000
10001dc:      e2833a35        add     r3, r3, #217088      ; 0x35000
10001e0:      e50b3030        str     r3, [fp -#48]
      LED * pLED = new LED( ioport );
10001e4:      e3a00004        mov     r0, #4               ; 0x4
10001e8:      eb00022d        bl      1000aa4 <__builtin_new>
      ...

What happens if I set a breakpoint at 10001e4 is r3 will have a value of
0x3fc0008 which is 0x3ff5008 - 0x35000 but if I set a breakpoint at 10001d4
and step through until 10001e4, r3 will have 0x3ff5008. Then I hit go the
program would run okay. Somehow address 10001dc gets ignored, any ideas.
BTW, our target is a Samsung ARM7TDMI (S3C4530A). Thanks.

John Gonzaga
jgonzaga@pnicorp.com 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]