Odd compiler error?

Ran into this and have no idea what its all upset about..

/var/folders/QT/QToGN6mK2RmPDU+1YrkbM++++TM/-Tmp-//ccyfZoTK.s: Assembler messages:
/var/folders/QT/QToGN6mK2RmPDU+1YrkbM++++TM/-Tmp-//ccyfZoTK.s:1304: Error: even register number required
/var/folders/QT/QToGN6mK2RmPDU+1YrkbM++++TM/-Tmp-//ccyfZoTK.s:1543: Error: even register number required

Any hints?

Thanks!

-jim lee

Looks like an ARM error.

ARM error? Sorry, what's an/the ARM? Really, anyone run into something like this before? I'm completely stumped..

-jim lee

Without any context, we're pretty stumped too.

Read this before posting a programming question

Point 6.

what's an/the ARM?

Sadly I don't have any context to give! I was coding along, minding my own business, did a little change. Moved a couple local variable to being global.. Then I got this error. So I quicly move them back and I still get the error.

Here's the library I was working on..

The .h file..

#include <Adafruit_GFX.h>       // Core graphics library
#include <Adafruit_TFTLCD.h>    // Hardware-specific library
#include <TouchScreen.h>
#include "mapper.h"

#if not defined USE_ADAFRUIT_SHIELD_PINOUT 
#error "For use with the shield, make sure to #define USE_ADAFRUIT_SHIELD_PINOUT in the TFTLCD.h library file"
#endif

// These are the pins for the shield!
#define YP A1  // must be an analog pin, use "An" notation!
#define XM A2  // must be an analog pin, use "An" notation!
#define YM 7   // can be a digital pin
#define XP 6   // can be a digital pin

// For better pressure precision, we need to know the resistance
// between X+ and X- Use any multimeter to read it
// For the one we're using, its 300 ohms across the X plate

#define OHMS   300
#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0 

// Color definitions
#define	BLACK           0x0000
#define	BLUE            0x001F
#define	RED             0xF800
#define	GREEN           0x07E0
#define CYAN            0x07FF
#define MAGENTA         0xF81F
#define YELLOW          0xFFE0 
#define WHITE           0xFFFF

// Rotation
#define PORTRAIT      0  // USB up
#define LANDSCAPE     1  // USB left
#define INV_PORTRAIT  2  // USB down
#define INV_LANDSCAPE 3  // USB right


// ****** colorObj ******

class colorObj {

public:
  colorObj(byte inRed, byte inGreen, byte inBlue);
  colorObj(word color16);
  colorObj(void);

  void setColor(byte red, byte green, byte blue);
  void setColor(word color16);
  word getColor16(void);

  byte getRed(void);
  byte getGreen(void);
  byte getBlue(void);

  void printRGB(void);

private :

  word  convertRGB(byte red, byte green, byte bue);

  byte red;
  byte green;
  byte blue;
};


// ****** colorMapper ******

class colorMapper {

public:
  colorMapper(colorObj* inStart, colorObj* inEnd);
  colorMapper(word startC16,word endC16);

  word Map(float percent);
  void printColors(void);
  
private :
  mapper* redMapper;
  mapper* greenMapper;
  mapper* blueMapper;
};


// ****** screenObj ******

class screenObj : 
public Adafruit_TFTLCD {

public:
  screenObj(int Dummy);

  boolean init(int inRotation=PORTRAIT);
  //void setRotation(int inRotation);

  Point getPoint();

private :
  mapper* xMapper;
  mapper* yMapper;
  TouchScreen* ts;
};

And the source code..

#include "screenObj.h"

#define TS_MINX 150
#define TS_MINY 120
#define TS_MAXX 920
#define TS_MAXY 940

/* These are the guys I moved and the compiler broke.

word redMask = (B11111000 * 256);
 word greenMask = (B00000111 * 256) + B11100000;
 word blueMask = B00011111;

 */

// ****** colorObj ******

colorObj::colorObj(byte inRed, byte inGreen, byte inBlue) { 
  setColor(inRed,inGreen,inBlue); 
}


colorObj::colorObj(word inColor16) { 
  setColor(inColor16); 
}


colorObj::colorObj(void) { 
  setColor(0,0,0); 
}


void colorObj::setColor(byte inRed, byte inGreen, byte inBlue) {

  red = inRed;
  green = inGreen;
  blue = inBlue;
  //Serial.println("setColor(byte inRed, byte inGreen, byte inBlue)");
  //Serial.print( "ColorObj RGB : ");Serial.print(red);Serial.print(", ");Serial.print(green);Serial.print(", ");Serial.println(blue);
}

void colorObj::setColor(word color16) {

  word redMask = (B11111000 * 256);
  word greenMask = (B00000111 * 256) + B11100000;
  word blueMask = B00011111;

  red = (color16 & redMask) >> 8;
  green = (color16 & greenMask) >> 5;
  blue = color16 & blueMask;
  //Serial.print("color16 : ");Serial.println(color16,BIN);
  //printRGB();
}


word colorObj::getColor16(void) { 
  return convertRGB(red,green,blue); 
}


byte colorObj::getRed(void) { 
  return red; 
}


byte colorObj::getGreen(void) { 
  return green; 
}


byte colorObj::getBlue(void) { 
  return blue; 
}


void colorObj::printRGB(void) {

  Serial.print( "ColorObj RGB : ");
  Serial.print(red);
  Serial.print(", ");
  Serial.print(green);
  Serial.print(", ");
  Serial.println(blue);
}


word  colorObj::convertRGB(byte inRed, byte inGreen, byte inBlue) {

  word color;

  color = inRed;
  color >>= 3;
  color <<= 6;

  inGreen >>= 2;
  color |= inGreen;
  color <<= 5;

  inBlue >>= 3;
  color |= inBlue;

  return color;
}


// ****** colorMapper ******

colorMapper::colorMapper(colorObj* inStart, colorObj* inEnd) {

  //Serial.println("colorMapper::colorMapper(colorObj* inStart, colorObj* inEnd)");
  redMapper = new mapper(0,100,inStart->getRed(),inEnd->getRed());
  greenMapper = new mapper(0,100,inStart->getGreen(),inEnd->getGreen());
  blueMapper = new mapper(0,100,inStart->getBlue(),inEnd->getBlue());
}


colorMapper::colorMapper(word startC16,word endC16) {


  //Serial.println("colorMapper::colorMapper(word startC16,word endC16)");
  colorObj startColor(startC16);
  colorObj endColor(endC16);

  redMapper = new mapper(0,100,startColor.getRed(),endColor.getRed());
  greenMapper = new mapper(0,100,startColor.getGreen(),endColor.getGreen());
  blueMapper = new mapper(0,100,startColor.getBlue(),endColor.getBlue());
}


word colorMapper::Map(float percent) {

  //Serial.println("colorMapper::Map(float percent)");
  colorObj tempColor(
  (byte)round(redMapper->Map(percent)),
  (byte)round(greenMapper->Map(percent)),
  (byte)round(blueMapper->Map(percent))
    );
  return tempColor.getColor16();
}


void colorMapper::printColors(void) {

  colorObj startColor(
  (byte)round(redMapper->Map(0)),
  (byte)round(greenMapper->Map(0)),
  (byte)round(blueMapper->Map(0))
    );
  colorObj endColor(
  (byte)round(redMapper->Map(100)),
  (byte)round(greenMapper->Map(100)),
  (byte)round(blueMapper->Map(100))
    );
  Serial.println("Mapper start / end");
  startColor.printRGB();
  endColor.printRGB();
}



// ****** screenObj ******

screenObj::screenObj(int dummy) 

:
Adafruit_TFTLCD(LCD_CS, LCD_CD, LCD_WR, LCD_RD, 0)
{
  ts = new TouchScreen(XP, YP, XM, YM, OHMS);
  xMapper  = new mapper(TS_MINX, TS_MAXX, width(), 0);
  yMapper  = new mapper(TS_MINY, TS_MAXY, height(), 0);
  int place = dummy;
}


boolean screenObj::init(int inRotation) {

  uint16_t identifier;

  pinMode(XM, OUTPUT);
  pinMode(YP, OUTPUT);
  reset();
  identifier = readRegister(0x0);
  if (identifier == 0x9325 || identifier == 0x9328) {
    begin(identifier); 
    setRotation(inRotation);
    return true;
  } 
  else
    return false;
}


Point screenObj::getPoint() {

  Point pt;

  pt = ts->getPoint();
  pinMode(XM, OUTPUT);
  pinMode(YP, OUTPUT);
  pt.x = xMapper->Map(pt.x);
  pt.y = yMapper->Map(pt.y);
  switch (getRotation()) {
  case 0:
    break;
  case 1:
    swap(pt.x,pt.y);
    pt.x = pt.x;
    pt.y = height() - pt.y;
    break;
  case 2:
    pt.x = width() - pt.x;
    pt.y = height() - pt.y;
    break;
  case 3:
    swap(pt.x,pt.y);
    pt.x = width() - pt.x;
    pt.y = pt.y;
    break;
  }
  return(pt);
}

And it gives me..

/var/folders/QT/QToGN6mK2RmPDU+1YrkbM++++TM/-Tmp-//ccbinRWR.s: Assembler messages:
/var/folders/QT/QToGN6mK2RmPDU+1YrkbM++++TM/-Tmp-//ccbinRWR.s:1278: Error: even register number required
/var/folders/QT/QToGN6mK2RmPDU+1YrkbM++++TM/-Tmp-//ccbinRWR.s:1288: Error: even register number required
/var/folders/QT/QToGN6mK2RmPDU+1YrkbM++++TM/-Tmp-//ccbinRWR.s:1478: Error: even register number required
/var/folders/QT/QToGN6mK2RmPDU+1YrkbM++++TM/-Tmp-//ccbinRWR.s:1488: Error: even register number required

-jim lee

Sketch?

Sadly I don't have any context to give!

IDE?

What version of avr-gcc are you using? There is a suggestion here that this is fixed in a later version:

http://lists.gnu.org/archive/html/avr-gcc-list/2008-05/msg00163.html

IDE? Its the Arduino 1.0 IDE. Where do I look for the other context bits?

-jim lee

You can go ahead and post /var/folders/QT/QToGN6mK2RmPDU+1YrkbM++++TM/-Tmp-//ccbinRWR.s too. Save it to pastebin if it's too large for the forum.

Oh, and it looks like you are running Linux? Open a command prompt and run "avr-gcc -v". And while you're at it, "avr-as -v". This will tell us which tools you're using. Also, which version of which distro are you running?

Ok..

I'm running an old Mac here not really Linux. After a bunch of poking around with google etc. I got some clues to what people were seeing this error over and from that I was able to locate where it was being generated in my code, but I still don't know why its upset..

void colorObj::setColor(word color16) {

  
  word redMask = (B11111000 * 256);
  //word greenMask = (B00000111 * 256) + B11100000;
  //word blueMask = B00011111;

  red = (color16 & redMask) >> 8;
  //green = (color16 & greenMask) >> 5;
 // blue = color16 & blueMask;
  //Serial.print("color16 : ");Serial.println(color16,BIN);
  //printRGB();
}

Seems its the line : red = (color16 & redMask) >> 8;

And there's a bug in the compiler? Doesn't the compiler come packaged in the IDE? How do I find the version of my compiler on a Mac?

Thanks!

-jim lee

Open a Console window. Type "avr-gcc --version", eg.

$ avr-gcc --version

avr-gcc (GCC) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

-bash: avr-gcc: command not found

You have me totally confused. The terminal on my Mac? Witch makes no sense to me 'cause I don't think I have any compilers there. Or, is there some sort of console window on the IDE that I don't know about. I'm assuming there's a complier in there.

-jim lee

How old is your Mac? Use Spotlight. Type "terminal". Accept the Terminal program. You will get a command-line prompt. You can type stuff there.

Find Arduino in your Applications folder. RH click and select Show Package Contents. Now search for avg-gcc.

Drag the resulting file into the terminal window, and append --version, eg.

/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-gcc --version

Hmm I got the same error, using Arduino IDE v1.0.1 on OSX:

Thats the line

g=(g*mulCol + g2*oppositeColor) >> 8

The error is a asm error when using the movw instruction... The funny thing is, I use this code in another project without a problem, I reuse this piece of code and this bug hit me... any hints?

Used Version:

bash-3.2$ /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-g++ --version
avr-g++ (GCC) 4.3.2
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

bash-3.2$ /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-gcc --version
avr-gcc (GCC) 4.3.2
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

pff I just found the solution seconds after this post

g was declared like this:

unsigned int g;

and I guess this addition will overflow the unsigned int:

g=(g*mulCol + g2*oppositeColor) >> 8

I fixed it with:

  g=((g*mulCol)>>8) + ((g2*oppositeColor)>>8);

However I have NO clue why it works in my previous project (ExpeditInvaders/ColorSet.ino at master · neophob/ExpeditInvaders · GitHub)...