Hi,
when I compiled the attached file with msp430-gcc version 3.2 I got the
following error messages:
--------------------------------------------------------------
msp430-gcc.exe -c CircularBuffer.c -o CircularBuffer.o
-I"C:/Dev-Cpp/include"   -mmcu=msp430x149

CircularBuffer.c: In function `CBUF_getElement':
CircularBuffer.c:30: unrecognizable insn:
(insn 47 45 49 (set (mem/s/j:HI (plus:HI (reg/f:HI 33)
                (const_int 8 [0x8])) [0
<variable>.number_used_elements+0 S2 A16])
        (minus:HI (const_int -1 [0xffffffff])
            (const_int 1 [0x1]))) -1 (nil)
    (expr_list:REG_DEAD (reg/f:HI 33)
        (nil)))
CircularBuffer.c:30: Internal compiler error in extract_insn, at
recog.c:2148
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
--------------------------------------------------------
I hope this information is somewhat helpful

Greetings,
Wolfgang


///////////////////////////////////////////
// CircularBuffer.h
//
// This module implenets an interrupt-save, adjustable size 
// circular buffer for chars.
// The buffer is capable of XON/XOFF-like signaling
//
// Author:  Wolfgang Heidl
// Date:    16.07.2002
//////////////////////////////////////////

#ifndef __CircularBuffer_h__
#define __CircularBuffer_h__


#define BUFFER_EMPTY      0x19  // ASCII control char 'End of Medium'

typedef void (*BufferNotify)(void);

struct CircularBuffer
{
  unsigned char *buffer;
  unsigned index_mask;
  unsigned rd_index;
  unsigned wr_index;
  unsigned number_used_elements;
  
  unsigned full_warning_level;
  unsigned recovered_level;

  BufferNotify nearly_full_notification;
  BufferNotify recovered_notification;
};

typedef struct CircularBuffer CircBuffer;

#define CBUF_isEmpty(buffer) ((buffer)->rd_index == (buffer)->wr_index)

void CBUF_init(CircBuffer *buffer, unsigned char *work_space, unsigned 
index_mask,
                unsigned full_warning_level, BufferNotify buffer_nearly_full,
                unsigned recovered_level, BufferNotify buffer_recovered);

void CBUF_putElement (CircBuffer *buffer, unsigned char element);

int CBUF_getElement (CircBuffer *buffer);

#endif

#include <signal.h>
#include "CircularBuffer.h"

int CBUF_getElement(CircBuffer *buffer)
{
  unsigned char element;

  dint();
   
  if (CBUF_isEmpty(buffer))
  {
    eint();
    //return BUFFER_EMPTY;
  }

  element = buffer->buffer[buffer->rd_index];
  buffer->rd_index++;
  buffer->rd_index &= buffer->index_mask;
  
  if (buffer->recovered_notification != 0)
  {
    buffer->number_used_elements--;
    if (buffer->number_used_elements == buffer->recovered_level)
      buffer->recovered_notification(); 
  }
    
  eint();
  return element;
}

Reply via email to