[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] Memory clobbered
From: |
Peter Bosscha |
Subject: |
[avr-gcc-list] Memory clobbered |
Date: |
Tue, 20 May 2003 13:58:41 +0200 |
Hi,
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 indexstr.
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 ?
Regards
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] Memory clobbered,
Peter Bosscha <=