/*
 * @(#)ns32000.h	1.1 (National Semiconductor) 1/23/91 11:57:38
 * @(#) copyrights and other release restrictions may apply
 */

/*
 * set bit, clear bit, invert bit, test bit 
 */

typedef int _xbit(int offset,
		  void *base);

_xbit _cbit;
_xbit _ibit;
_xbit _sbit;
_xbit _tbit;
_xbit _cbiti;
_xbit _sbiti;


/*
 * ffs
 */

int _ffsb(unsigned char base,
	  unsigned char *offset);

int _ffsw(unsigned short base,
	  unsigned char *offset);

int _ffsd(unsigned int base,
	  unsigned char *offset);

/*
 * exti, insi 
 */

void _extb(int offset,
	   void *base,
	   char *dest,
	   int length);

void _extw(int offset,
	   void *base,
	   short *dest,
	   int length);

void _extd(int offset,
	   void *base,
	   int *dest,
	   int length);

void _ins(int offset,
	  unsigned int src,
	  void *base,
	  int length);

/*
 * cvtp
 */

int _cvtp(int offset,
	   void *base);

/* Rotate */

void	_rotb(char count,
	      unsigned char *base);

void	_rotw(char count, 
	      unsigned short *base);

void	_rotd(char count, 
	      unsigned int *base);


/* Move string, move string translated */

typedef void _movs( int n_elements,
		    void *src,
		    void *dest);

typedef void _movs_translate(
		    int  n_elements,
		    void *src, 
		    void *dest,
		    char *translation_table);

typedef int _movs_translate_match(			/* Returns PSR.F */
		    int  n_elements,
		    void *src, 
		    void *dest,
		    char *translation_table,
		    char match_value);

_movs		_movsb,
		_movsw,
		_movsd,
		_movsb_b,	/* Backward */
		_movsw_b,	/* Backward */
		_movsd_b;	/* Backward */

_movs_translate  
		_movst, 
		_movst_b;	/* Backwards */


_movs_translate_match
	        _movst_u,       /* Until */
	        _movst_ub,      /* Until, backwards */
	        _movst_w,       /* While */
	        _movst_wb;      /* While, backwards */

/*
 * Operations on Dedicated Registers
 */

void _lpr(char *procreg,
	  unsigned int src);

void _spr(char *procreg,
	  unsigned int *dest);

/*
 * Bit Operations on the PSR
 */
#define    _USER_MODE_FLAG            0x100
#define    _STACK_FLAG                0x200
#define    _TRAP_PENDING_FLAG         0x400
#define    _INTPT_ENABLE_FLAG         0x800

#define    _interrupt_enable()        _bispsrw(_INTPT_ENABLE_FLAG)
#define    _interrupt_disable()       _bicpsrw(_INTPT_ENABLE_FLAG)

#define    _select_user_stack()       _bispsrw(_STACK_FLAG)
#define    _select_supervisor_stack() _bicpsrw(_STACK_FLAG)


void _bicpsrw( unsigned short src );
void _bispsrw( unsigned short src );

void _setcfg( char *options );

/*
 * Traps
 */
void _bpt(void);

void _flag(void);

int  _svc(int r0,...);

/*
 * abs
 */

int    abs(int val);         /* integer absolute value */
double fabs(double val);     /* double absolute value */
float  ffabs(float val);     /* float absolute value */
