--- a/STM8S_StdPeriph_Driver/inc/stm8s.h
+++ b/STM8S_StdPeriph_Driver/inc/stm8s.h
@@ -75,6 +75,8 @@
  #define _RAISONANCE_
 #elif defined(__ICCSTM8__)
  #define _IAR_
+#elif defined(SDCC)
+ #define _SDCC_
 #else
  #error "Unsupported Compiler!"          /* Compiler defines not found */
 #endif
@@ -130,7 +132,8 @@
  #endif /* STM8S208 or STM8S207 or STM8S007 or STM8AF62Ax or STM8AF52Ax */ 
 #else /*_IAR_*/
  #define FAR  __far
- #define NEAR __near
+// #define NEAR __near
+ #define NEAR //hack SDCC gets confused by __near
  #define TINY __tiny
  #define EEPROM __eeprom
  #define CONST  const
@@ -143,7 +146,9 @@
 #if defined (STM8S105) || defined (STM8S005) || defined (STM8S103) || defined (STM8S003) || \
     defined (STM8S903) || defined (STM8AF626x)
 /*!< Used with memory Models for code smaller than 64K */
+ //#define PointerAttr NEAR
  #define PointerAttr NEAR
+
 #else /* STM8S208 or STM8S207 or STM8AF62Ax or STM8AF52Ax */
 /*!< Used with memory Models for code higher than 64K */
  #define PointerAttr FAR
@@ -195,6 +200,9 @@
 #define     __O     volatile         /*!< defines 'write only' permissions    */
 #define     __IO    volatile         /*!< defines 'read / write' permissions  */
 
+#if defined(SDCC)
+#include <stdint.h>
+#else
 /*!< Signed integer types  */
 typedef   signed char     int8_t;
 typedef   signed short    int16_t;
@@ -204,6 +212,7 @@
 typedef unsigned char     uint8_t;
 typedef unsigned short    uint16_t;
 typedef unsigned long     uint32_t;
+#endif 
 
 /*!< STM8 Standard Peripheral Library old types (maintained for legacy purpose) */
 
@@ -2615,6 +2624,15 @@
  #define trap()                {_asm("trap\n");} /* Trap (soft IT) */
  #define wfi()                 {_asm("wfi\n");}  /* Wait For Interrupt */
  #define halt()                {_asm("halt\n");} /* Halt */
+#elif defined(_SDCC_)
+ #define enableInterrupts()    {__asm__("rim\n");}  /* enable interrupts */
+ #define disableInterrupts()   {__asm__("sim\n");}  /* disable interrupts */
+ #define rim()                 {__asm__("rim\n");}  /* enable interrupts */
+ #define sim()                 {__asm__("sim\n");}  /* disable interrupts */
+ #define nop()                 {__asm__("nop\n");}  /* No Operation */
+ #define trap()                {__asm__("trap\n");} /* Trap (soft IT) */
+ #define wfi()                 {__asm__("wfi\n");}  /* Wait For Interrupt */
+ #define halt()                {__asm__("halt\n");} /* Halt */
 #else /*_IAR_*/
  #include <intrinsics.h>
  #define enableInterrupts()    __enable_interrupt()   /* enable interrupts */