/*-----------------------------------------------------------------------------+
|                                                                              |
|       Copyright (c), Raisonance S.A., 1987-2006                              |
|                                                                              |
+------------------------------------------------------------------------------+
|                                                                              |
|       File: INTRIST7.H                                                       |
|                                                                              |
+--------------+-------+----------------------------------------------+--------+
|     DATE     |VERSION| HISTORY/CHANGES                              |   BY   |
|  (MM/DD/YY)  | VX.Y  |                                              |        |
+--------------+-------+----------------------------------------------+--------+
|   XX/XX/XX   |  1.0  | Start of implementation                      |   XX   |
|   01/03/06   |  1.1  | Reimplementation                             |   FL   |
+--------------+-------+----------------------------------------------+--------+
|Purpose    :                                                                  |
|   Intrinsic functions for ST7                                                |
+-----------------------------------------------------------------------------*/
#ifndef _INTRIST7_H
#define _INTRIST7_H

#pragma SAVE

/* _fctptr_t is a "pointer to function" type for _jmp_() */
typedef void (* _fctptr_t)(void);

/* Functions that generate inline assembly instructions */
extern void          _halt_             (void) reentrant;
extern void          _jmp_              (_fctptr_t Addr) reentrant;
extern void          _nop_              (void) reentrant;
extern void          _rim_              (void) reentrant;
#if defined(__STM8__) && (__STM8__!=1)  // RSP not available on STM8
extern void          _rsp_              (void) reentrant;
#endif
extern void          _sim_              (void) reentrant;
extern void          _trap_             (void) reentrant;
extern void          _wfi_              (void) reentrant;

/* Functions to handle the Condition Code register (CC) */
extern unsigned char _getCC_            (void) reentrant;
extern void          _setCC_            (unsigned char Value) reentrant;

/* Functions to handle the Stack Pointer (SP) */
extern unsigned int  _getSP_            (void) reentrant;
extern void          _setSP_            (unsigned int newsp) reentrant;

/* Helper functions */
extern unsigned int  _swapbyte_         (unsigned int  Value) reentrant;
extern unsigned char _swapnibble_       (unsigned char Value) reentrant;

#pragma RESTORE

#endif _INTRIST7_H
