problem assigning value to global variables

Nicole Cook
Tue May 2 07:37:00 GMT 2000

I'm trying to debug some fairly simple code that worked when compiled by
the person who wrote it - I'm not sure if the problem is in the code or
the compiler, but I can't find anything wrong with the code itself.  

(Sorry for such a long message - I'm not sure exactly where the problem
is, even though I've narrowed down where it isn't)

The compilers:

It was originally compiled using "gcc version
2.9-ecosSWtools-arm-990321".  The version of arm-elf-gcc installed on my
machine is "gcc version 2.95.2 19991024 (release)".  

The code:

The program is trying to read id information from an ide drive and write
it to a global variable. The id buffer can be read in and dumped to
stdout word by word, so it's not an issue of not being able to
communicate with or getting wrong information from the drive. 

So, in some file there's a global variable declared:

unsigned short buffer[];

The program calls a function that sends an IDDrive command to the drive
and zeros the buffer.  Then it calls a function to read the information
in from the drive:

int readBuffer(unsigned short *buffer) {
	unsigned short *temp;
	int i;

	temp = buffer;
	for (i=0;i<256;i++) {
	     *temp = *((unsigned long *)DATA_PORT;

This is almost identical to the code that correctly dumps the buffer
read from DATA_PORT to stdout.  However, instead of reading the real
data, temp is always set to some value (sometimes its 0x70, or 0x070070,
or 0x90... it's not always the same value). 

The code worked before, and I haven't made any changes to it, nor can I
see anything wrong with the way it's reading from memory (the drive is
memory mapped on an aeb-1c).  Is there some difference in the way the
two versions of arm-elf-gcc work that would break this? Which is doing
the correct thing? Is this a compiler bug?

Thanks for any help you can give me.

Nicole Cook

Want more information?  See the CrossGCC FAQ,
Want to unsubscribe? Send a note to

More information about the crossgcc mailing list