[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [avr-gcc-list] Memory clobbered

From: Ömer Sinan KAYA
Subject: RE: [avr-gcc-list] Memory clobbered
Date: Tue, 20 May 2003 16:03:26 +0300

i had a very similar problem , which was solved by the help of Joerg.
The problem is that although the compiler doesnt have any idea about the
symbol , it doesnt complain and pass the wrong parameters to the

My case was that i was using memmove command for moving memory.The
definition of memmove command is at string.h . When i included string.h
in the source code the problem was resolved.

-----Original Message-----
From: address@hidden
[mailto:address@hidden On Behalf Of Peter Bosscha
Sent: Tuesday, May 20, 2003 2:59 PM
To: <AVR GCC List
Subject: [avr-gcc-list] Memory clobbered


We're running a large project on a MEGA128, now using the latest WIN
AVRGCC (24-April).
In one call a single byte of memory is unexpectedly being overwritten.

The call starts:

byte MenuLoop(void)

  static byte menu_level;       
  byte type;
  static byte menu_mode=ITEM_SUB;
  static byte lcdpos = 0;
  static byte oldlang = 0;
  static byte indexed = 0;
  static byte index_base = 0;
  byte i, breg, bval;
  float ftemp;
  unsigned char indexstr[] = "12345";


The effect we're seeing is that indexstr[0] byte is being overwritten.
I've tried to pin-point where the code goes wrong with all kinds of
debug statements and have even disabled interrupts.
For some reason the indexstr is being copied onto local workspace on the
stack and that's where things seem to go wrong:

 2427 02be 86E0                 ldi r24,lo8(6)
 2428 02c0 4E01                 movw r8,r28
 2429 02c2 0894                 sec
 2430 02c4 811C                 adc r8,__zero_reg__
 2431 02c6 911C                 adc r9,__zero_reg__
 2432 02c8 D401                 movw r26,r8
 2433 02ca E0E0                 ldi r30,lo8(.LC0)
 2434 02cc F0E0                 ldi r31,hi8(.LC0)
 2435 02ce 0190                 ld __tmp_reg__,Z+
 2436 02d0 0D92                 st X+,__tmp_reg__
 2437 02d2 8A95                 dec r24
 2438 02d4 E1F7                 brne .-8

Where R28/29 points to the workspace and .LCO is the address of the

As far as I'm concerned the above code is correct, nevertheless it is
this exact section that overwrites a single byte at .LCO

Anyone any ideas ?
Am I missing something ?

Peter Bosscha
CSIR South Africa

This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Mailscanner thanks transtec Computers for their support.

avr-gcc-list mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]