Found Compiler Bug

Discussion and support of the compiler from ImageCraft for the M8C.

Moderator: richard@imagecraft.com

Found Compiler Bug

Postby bobmarlowe » Fri Mar 22, 2013 4:10 am

Built with ICCM8C STD V7.05.00

I never thought to find one in my life, but here it is
Code: Select all
//----------------------------------------------------------------------------
// C main line
//----------------------------------------------------------------------------

#include <m8c.h>        // part specific constants and macros
#include "PSoCAPI.h"    // PSoC API definitions for all User Modules

#define StackTop (* (int*)0x7fe)
#define forever 1
void InitializeHardware(void)
{
   StackTop = 0xDead;   // Works correctly
   LCD_Init();
   LCD_Position(0,0);
   LCD_PrCString("Stack Test");
}

void CheckStack(void)
{
int MyInt;
   MyInt = StackTop;   // Absolutely correct
   if(MyInt != 0xDead)
   {
      LCD_Position(1,0);   // Branch never executes because stack is intact
      LCD_PrCString("Overflow");
   }
   if(StackTop != 0xDead)   // This comparision looks at the wrong Ram-Page
   {
      LCD_Position(1,0);   //... and tells me wrongly stack is blown
      LCD_PrCString("Overflow");
   }
}

void main(void)
{
   InitializeHardware();
   while(forever)
   {
      CheckStack();
   }
}


In the second if there is generated
MOV REG[0xD0],0x0
but must be
MOV REG[0xD0],0x07
as with the assignment to MyInt. The consequence is that the first if is always false and the second one always true.


Bob
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany

Return to “%s” ImageCraft ICCv7 for M8C Compiler

Who is online

Users browsing this forum: No registered users and 1 guest