Hi,

> > in the example stackcheck there are some confusing comments:
> > Due to the line
> > 
> > extern unsigned short _end;  ///<Last used byte of the last segment in RAM 
> > (defined by the linker)
> > 
> > _end is an uint16_t but the comment says byte = unsigned char (=uint8_t).
> > Is this a bug in the comment?
> 
> _end is an address (and thus 16 bits wide on an msp), that points to the 
> first free byte (or after the last used byte) in RAM.
> as i want to write a 16 bit "stack marker", i declare a short variable 
> and not a pointer. this also assumes that _end points to an even address 
> (which is usualy the case wih mspgcc).

ok, but that's not safe because sometimes that address is odd:

> msp430-gcc -mmcu=msp430x168 -o aout.elf flag.o i2c.o main.o rand.o rs232.o 
> signal.o temp.o times.o stackcheck.o -lm
stackcheck.o(.text+0x4): In function `stackCheck':
/home/nobody/c/mspgcc/par/stackcheck.c:70: internal error: unsupported 
relocation error
stackcheck.o(.text+0x12): In function `stackProtectionInit':
/home/nobody/c/mspgcc/par/stackcheck.c:46: internal error: unsupported 
relocation error
msp430-objcopy -O ihex aout.elf aout.a43
msp430-objdump -dSt aout.elf >aout.lst

With 

    void * ptr_void = &_end;
    unsigned short * address = (unsigned short *)(ptr_void +(((int)ptr_void) 
bitand 1));

it always works.

Regards,

Rolf




Reply via email to