Topic : Possible problem with the STM8 compiler

Forum : ST7/STM8

Original Post
Post Information Post
March 4, 2010 - 5:14pm
Guest

Hello,

I am porting the ChibiOS/RT RTOS to STM8 using your excellent development environment. The work is almost finished and I am really enjoying Ride7, I am thinking to make a Ride7/GCC version for ARM too.

While debugging the new port, I ran into an unexpected problem. Please consider the following code:

/**
 * @brief   Evaluates to TRUE if the thread has pending messages.
 */
#define chMsgIsPendingI(tp) \
        ((tp)->p_msgqueue.p_next != (Thread *)&(tp)->p_msgqueue)

/**
 * @brief   Returns the first message in the queue.
 */
#define chMsgGetI(tp) \
        ((tp)->p_msgqueue.p_next->p_msg)

msg_t chMsgWait(void) {
  msg_t msg;

  chSysLock();
  if (!chMsgIsPendingI(currp))
    chSchGoSleepS(THD_STATE_WTMSG);
  msg = chMsgGetI(currp);
  chSysUnlock();
  return msg;
}

The pointer "currp" does not change after invoking chSchGoSleepS() but the data pointed by "currp" does change. It is a queue of incoming messages for the currently running thread.

The compiler generates the following code:

              ; FUNCTION ?chMsgWait (BEGIN)
              ; SOURCE LINE # 74 
0000 5206                              SUB    SP,#006H
              ; SOURCE LINE # 77 
0002 9B                                SIM    
              ; SOURCE LINE # 78 
0003 CE0000     F                      LDW    X,rlist + 0DH
0006 1C0013                            ADDW   X,#00013H
0009 1F03       F                      LDW    (003H,SP),X
000B FE                                LDW    X,(X)
000C 1F05       F                      LDW    (005H,SP),X
000E 1303       F                      CPW    X,(003H,SP)
0010 2605                              JRNE   ?NXT_0003
              ; SOURCE LINE # 79 
0012 A60B                              LD     A,#00BH
0014 CD0000     F                      CALL   ?chSchGoSleepS
0017         ?NXT_0003:
              ; SOURCE LINE # 80 
0017 1E05       F                      LDW    X,(005H,SP)
0019 EE17                              LDW    X,(017H,X)
001B 1F01       F                      LDW    (001H,SP),X   ; [ msg ]
              ; SOURCE LINE # 81 
001D 9A                                RIM    
              ; SOURCE LINE # 82 
001E 5B06                              ADD    SP,#006H
0020 81                                RET    

As you can see it seems to not consider that the data pointed by "currp" can change after invoking chSchGoSleepS(), after exiting from that function the queue is no more empty. I am doing simply something wrong there ?

If I modify the code as follow:

  if (!chMsgIsPendingI(currp))
    chSchGoSleepS(THD_STATE_WTMSG);
  msg = chMsgGetI((volatile Thread *)currp);

Then everything works and the generated code becomes:

              ; FUNCTION ?chMsgWait (BEGIN)
              ; SOURCE LINE # 74 
0000 5204                              SUB    SP,#004H
              ; SOURCE LINE # 77 
0002 9B                                SIM    
              ; SOURCE LINE # 78 
0003 CE0000     F                      LDW    X,rlist + 0DH
0006 1C0013                            ADDW   X,#00013H
0009 1F03       F                      LDW    (003H,SP),X
000B FE                                LDW    X,(X)
000C 1303       F                      CPW    X,(003H,SP)
000E 2605                              JRNE   ?NXT_0003
              ; SOURCE LINE # 79 
0010 A60B                              LD     A,#00BH
0012 CD0000     F                      CALL   ?chSchGoSleepS
0015         ?NXT_0003:
              ; SOURCE LINE # 80 
0015 1E03       F                      LDW    X,(003H,SP)
0017 FE                                LDW    X,(X)
0018 EE17                              LDW    X,(017H,X)
001A 1F01       F                      LDW    (001H,SP),X   ; [ msg ]
              ; SOURCE LINE # 81 
001C 9A                                RIM    
              ; SOURCE LINE # 82 
001D 5B04                              ADD    SP,#004H
001F 81                                RET    

I am compiling with size optimization level 3. I think the compiler should never assume that the data pointed by a global variable cannot change across function calls.

Note that the posted fix is not a solution for me nor I can simply declare the pointer "currp" as volatile, the efficiency of the OS would suffer (it is very critical code) and the kernel is supposed to be portable so it should not contain vendor specific workarounds. Another problem is that I could get an unpredictable behavior in other points of the kernel and simply do not discover them until it is too late.

I hope to find a better solution, except for this problem everything else seems to be working perfectly.

best regards,
Giovanni Di Sirio

Replies
Post Information Post
+1
0
-1
March 5, 2010 - 11:37am
Raisonance Support Team

Hi Giovanni,

We are very glad that you enjoy working on Ride7 and with our Compiler. Thanks a lot!

We tried to reproduce your problem in our labs with no success.
Can you do the following:
Add the following line as the first line of the problematic .C file:
#pragma PREPRINT

Compile you file. The compiler will generate a preprocessed file with the same name as your C file, and extension ".I"
Send me this .I file, along with the compiler listing file which has extension ".LST". You can post these right here.
Using these files we will be able to better characterize and reproduce the problem.

Regards,
Bruno

+1
0
-1
March 5, 2010 - 1:59pm
Guest

This is the preprocessed file:

typedef unsigned short size_t ;
typedef unsigned char wchar_t ;
typedef int ptrdiff_t ;
typedef unsigned char uint8_t ;
typedef signed char int8_t ;
typedef unsigned int uint16_t ;
typedef signed int int16_t ;
typedef unsigned long uint32_t ;
typedef signed long int32_t ;
typedef uint8_t uint_fast8_t ;
typedef uint16_t uint_fast16_t ;
typedef uint32_t uint_fast32_t ;
typedef int8_t bool_t ;
typedef uint8_t tmode_t ;
typedef uint8_t tstate_t ;
typedef uint8_t trefs_t ;
typedef uint8_t tprio_t ;
typedef int16_t msg_t ;
typedef int16_t eventid_t ;
typedef uint16_t eventmask_t ;
typedef uint16_t systime_t ;
typedef int16_t cnt_t ;
typedef struct Thread Thread ;
typedef struct {
    Thread * p_next ;
    Thread * p_prev ;
    }
ThreadsQueue ;
typedef struct {
    Thread * p_next ;
    }
ThreadsList ;
void prio_insert ( Thread * tp , ThreadsQueue * tqp ) ;
void queue_insert ( Thread * tp , ThreadsQueue * tqp ) ;
Thread * fifo_remove ( ThreadsQueue * tqp ) ;
Thread * lifo_remove ( ThreadsQueue * tqp ) ;
Thread * dequeue ( Thread * tp ) ;
void list_insert ( Thread * tp , ThreadsList * tlp ) ;
Thread * list_remove ( ThreadsList * tlp ) ;
typedef void ( * _fctptr_t ) ( void ) ;
extern void _halt_ ( void ) reentrant ;
extern void _jmp_ ( _fctptr_t Addr ) reentrant ;
extern void _nop_ ( void ) reentrant ;
extern void _rim_ ( void ) reentrant ;
extern void _sim_ ( void ) reentrant ;
extern void _trap_ ( void ) reentrant ;
extern void _wfe_ ( void ) reentrant ;
extern void _wfi_ ( void ) reentrant ;
extern unsigned char _getCC_ ( void ) reentrant ;
extern void _setCC_ ( unsigned char Value ) reentrant ;
extern unsigned int _getSP_ ( void ) reentrant ;
extern void _setSP_ ( unsigned int newsp ) reentrant ;
extern unsigned int _swapbyte_ ( unsigned int Value ) reentrant ;
extern unsigned char _swapnibble_ ( unsigned char Value ) reentrant ;
typedef uint8_t stkalign_t ;
struct extctx {
    uint8_t _next ;
    uint16_t cx ;
    uint16_t bx ;
    uint8_t cc ;
    uint8_t a ;
    uint16_t x ;
    uint16_t y ;
    uint8_t pce ;
    uint8_t pch ;
    uint8_t pcl ;
    }
;
struct intctx {
    uint8_t _next ;
    uint16_t pc ;
    }
;
struct startctx {
    uint8_t _next ;
    uint16_t ts ;
    uint16_t arg ;
    uint16_t pc ;
    uint16_t ret ;
    }
;
struct context {
    struct intctx * sp ;
    }
;
void port_halt ( void ) ;
void port_switch ( Thread * otp , Thread * ntp ) ;
void _port_thread_start ( void ) ;
void chSysInit ( void ) ;
void chSysTimerHandlerI ( void ) ;
typedef void ( * vtfunc_t ) ( void * ) ;
typedef struct VirtualTimer VirtualTimer ;
struct VirtualTimer {
    VirtualTimer * vt_next ;
    VirtualTimer * vt_prev ;
    systime_t vt_time ;
    vtfunc_t vt_func ;
    void * vt_par ;
    }
;
typedef struct {
    VirtualTimer * vt_next ;
    VirtualTimer * vt_prev ;
    systime_t vt_time ;
    volatile systime_t vt_systime ;
    }
VTList ;
extern VTList vtlist ;
void vt_init ( void ) ;
void chVTSetI ( VirtualTimer * vtp , systime_t time , vtfunc_t vtfunc , void * par ) ;
void chVTResetI ( VirtualTimer * vtp ) ;
bool_t chTimeIsWithin ( systime_t start , systime_t end ) ;
typedef struct {
    ThreadsQueue r_queue ;
    tprio_t r_prio ;
    struct context p_ctx ;
    Thread * p_newer ;
    Thread * p_older ;
    cnt_t r_preempt ;
    Thread * r_current ;
    }
ReadyList ;
extern ReadyList rlist ;
void scheduler_init ( void ) ;
Thread * chSchReadyI ( Thread * tp ) ;
void chSchGoSleepS ( tstate_t newstate ) ;
msg_t chSchGoSleepTimeoutS ( tstate_t newstate , systime_t time ) ;
void chSchWakeupS ( Thread * tp , msg_t msg ) ;
void chSchDoRescheduleI ( void ) ;
void chSchRescheduleS ( void ) ;
bool_t chSchIsRescRequiredExI ( void ) ;
void chSchDoYieldS ( void ) ;
typedef struct Semaphore {
    ThreadsQueue s_queue ;
    cnt_t s_cnt ;
    }
Semaphore ;
void chSemInit ( Semaphore * sp , cnt_t n ) ;
void chSemReset ( Semaphore * sp , cnt_t n ) ;
void chSemResetI ( Semaphore * sp , cnt_t n ) ;
msg_t chSemWait ( Semaphore * sp ) ;
msg_t chSemWaitS ( Semaphore * sp ) ;
msg_t chSemWaitTimeout ( Semaphore * sp , systime_t time ) ;
msg_t chSemWaitTimeoutS ( Semaphore * sp , systime_t time ) ;
void chSemSignal ( Semaphore * sp ) ;
void chSemSignalI ( Semaphore * sp ) ;
msg_t chSemSignalWait ( Semaphore * sps , Semaphore * spw ) ;
typedef struct EventListener EventListener ;
struct EventListener {
    EventListener * el_next ;
    Thread * el_listener ;
    eventmask_t el_mask ;
    }
;
typedef struct EventSource {
    EventListener * es_next ;
    }
EventSource ;
typedef void ( * evhandler_t ) ( eventid_t ) ;
void chEvtRegisterMask ( EventSource * esp , EventListener * elp , eventmask_t mask ) ;
void chEvtUnregister ( EventSource * esp , EventListener * elp ) ;
eventmask_t chEvtClear ( eventmask_t mask ) ;
eventmask_t chEvtPend ( eventmask_t mask ) ;
void chEvtSignal ( Thread * tp , eventmask_t mask ) ;
void chEvtSignalI ( Thread * tp , eventmask_t mask ) ;
void chEvtBroadcast ( EventSource * esp ) ;
void chEvtBroadcastI ( EventSource * esp ) ;
void chEvtDispatch ( const evhandler_t * handlers , eventmask_t mask ) ;
eventmask_t chEvtWaitOneTimeout ( eventmask_t mask , systime_t time ) ;
eventmask_t chEvtWaitAnyTimeout ( eventmask_t mask , systime_t time ) ;
eventmask_t chEvtWaitAllTimeout ( eventmask_t mask , systime_t time ) ;
msg_t chMsgSend ( Thread * tp , msg_t msg ) ;
msg_t chMsgWait ( void ) ;
msg_t chMsgGet ( void ) ;
void chMsgRelease ( msg_t msg ) ;
typedef void * align_t ;
typedef void * ( * memgetfunc_t ) ( size_t size ) ;
struct Thread {
    Thread * p_next ;
    Thread * p_prev ;
    tprio_t p_prio ;
    struct context p_ctx ;
    Thread * p_newer ;
    Thread * p_older ;
    tstate_t p_state ;
    tmode_t p_flags ;
    volatile systime_t p_time ;
    union {
        msg_t rdymsg ;
        msg_t exitcode ;
        void * wtobjp ;
        eventmask_t ewmask ;
        }
    p_u ;
    ThreadsList p_waiting ;
    ThreadsQueue p_msgqueue ;
    msg_t p_msg ;
    eventmask_t p_epending ;
    }
;
typedef msg_t ( * tfunc_t ) ( void * ) ;
Thread * init_thread ( Thread * tp , tprio_t prio ) ;
Thread * chThdInit ( void * wsp , size_t size , tprio_t prio , tfunc_t pf , void * arg ) ;
Thread * chThdCreateStatic ( void * wsp , size_t size , tprio_t prio , tfunc_t pf , void * arg ) ;
tprio_t chThdSetPriority ( tprio_t newprio ) ;
Thread * chThdResume ( Thread * tp ) ;
void chThdTerminate ( Thread * tp ) ;
void chThdSleep ( systime_t time ) ;
void chThdSleepUntil ( systime_t time ) ;
void chThdYield ( void ) ;
void chThdExit ( msg_t msg ) ;
msg_t chThdWait ( Thread * tp ) ;
Thread * chRegFirstThread ( void ) ;
Thread * chRegNextThread ( Thread * tp ) ;
typedef void ( * qnotify_t ) ( void ) ;
typedef struct {
    uint8_t * q_buffer ;
    uint8_t * q_top ;
    uint8_t * q_wrptr ;
    uint8_t * q_rdptr ;
    Semaphore q_sem ;
    qnotify_t q_notify ;
    }
GenericQueue ;
typedef GenericQueue InputQueue ;
typedef GenericQueue OutputQueue ;
void chIQInit ( InputQueue * qp , uint8_t * bp , size_t size , qnotify_t infy ) ;
void chIQResetI ( InputQueue * qp ) ;
msg_t chIQPutI ( InputQueue * qp , uint8_t b ) ;
msg_t chIQGetTimeout ( InputQueue * qp , systime_t time ) ;
size_t chIQReadTimeout ( InputQueue * qp , uint8_t * bp , size_t n , systime_t time ) ;
void chOQInit ( OutputQueue * queue , uint8_t * bp , size_t size , qnotify_t onfy ) ;
void chOQResetI ( OutputQueue * queue ) ;
msg_t chOQPutTimeout ( OutputQueue * queue , uint8_t b , systime_t time ) ;
msg_t chOQGetI ( OutputQueue * queue ) ;
size_t chOQWriteTimeout ( OutputQueue * queue , const uint8_t * bp , size_t n , systime_t time ) ;
struct BaseSequentialStreamVMT {
    size_t ( * write ) ( void * instance , const uint8_t * bp , size_t n ) ;
    size_t ( * read ) ( void * instance , uint8_t * bp , size_t n ) ;
    }
;
typedef struct {
    const struct BaseSequentialStreamVMT * vmt ;
    }
BaseSequentialStream ;
struct BaseChannelVMT {
    size_t ( * write ) ( void * instance , const uint8_t * bp , size_t n ) ;
    size_t ( * read ) ( void * instance , uint8_t * bp , size_t n ) ;
    bool_t ( * putwouldblock ) ( void * instance ) ;
    bool_t ( * getwouldblock ) ( void * instance ) ;
    msg_t ( * put ) ( void * instance , uint8_t b , systime_t time ) ;
    msg_t ( * get ) ( void * instance , systime_t time ) ;
    size_t ( * writet ) ( void * instance , const uint8_t * bp , size_t n , systime_t time ) ;
    size_t ( * readt ) ( void * instance , uint8_t * bp , size_t n , systime_t time ) ;
    }
;
typedef struct {
    const struct BaseChannelVMT * vmt ;
    }
BaseChannel ;
struct BaseAsynchronousChannelVMT {
    size_t ( * write ) ( void * instance , const uint8_t * bp , size_t n ) ;
    size_t ( * read ) ( void * instance , uint8_t * bp , size_t n ) ;
    bool_t ( * putwouldblock ) ( void * instance ) ;
    bool_t ( * getwouldblock ) ( void * instance ) ;
    msg_t ( * put ) ( void * instance , uint8_t b , systime_t time ) ;
    msg_t ( * get ) ( void * instance , systime_t time ) ;
    size_t ( * writet ) ( void * instance , const uint8_t * bp , size_t n , systime_t time ) ;
    size_t ( * readt ) ( void * instance , uint8_t * bp , size_t n , systime_t time ) ;
    }
;
typedef struct {
    const struct BaseAsynchronousChannelVMT * vmt ;
    EventSource ievent ;
    EventSource oevent ;
    }
BaseAsynchronousChannel ;
msg_t chMsgSend ( Thread * tp , msg_t msg ) {
    Thread * ctp = rlist . r_current ;
    {
        ( void ) ( tp != 0L ) , ( void ) "\"chMsgSend\"(), line __LINE__";
        }
    ;
    _sim_ ( ) ;
    ctp -> p_msg = msg ;
    ctp -> p_u . wtobjp = & tp -> p_msgqueue ;
    queue_insert ( ctp , & tp -> p_msgqueue ) ;
    if ( tp -> p_state == 11 ) chSchReadyI ( tp ) ;
    chSchGoSleepS ( 10 ) ;
    msg = ctp -> p_u . rdymsg ;
    _rim_ ( ) ;
    return msg ;
    }
msg_t chMsgWait ( void ) {
    msg_t msg ;
    _sim_ ( ) ;
    if ( ! ( ( rlist . r_current ) -> p_msgqueue . p_next != ( Thread * ) & ( rlist . r_current ) -> p_msgqueue ) ) chSchGoSleepS ( 11 ) ;
    msg = ( ( rlist . r_current ) -> p_msgqueue . p_next -> p_msg ) ;
    _rim_ ( ) ;
    return msg ;
    }
msg_t chMsgGet ( void ) {
    msg_t msg ;
    _sim_ ( ) ;
    msg = ( ( rlist . r_current ) -> p_msgqueue . p_next != ( Thread * ) & ( rlist . r_current ) -> p_msgqueue ) ? ( ( rlist . r_current ) -> p_msgqueue . p_next -> p_msg ) : ( msg_t ) 0L ;
    _rim_ ( ) ;
    return msg ;
    }
void chMsgRelease ( msg_t msg ) {
    _sim_ ( ) ;
    {
        ( void ) ( ( ( rlist . r_current ) -> p_msgqueue . p_next != ( Thread * ) & ( rlist . r_current ) -> p_msgqueue ) ) ;
        }
    ;
    chSchWakeupS ( fifo_remove ( & rlist . r_current -> p_msgqueue ) , msg ) ;
    _rim_ ( ) ;
    }

And the generated code:

  21          /**
  22           * @file    chmsg.c
  23           * @brief   Messages code.
  24           *
  25           * @addtogroup messages
  26           * @{
  27           */
  28          
  29          #include "ch.h"
  30          
  31          #if CH_USE_MESSAGES
  32          
  33          #if CH_USE_MESSAGES_PRIORITY
              #define msg_insert(tp, qp) prio_insert(tp, qp)
              #else
  36          #define msg_insert(tp, qp) queue_insert(tp, qp)
  37          #endif
  38          
  39          /**
  40           * @brief   Sends a message to the specified thread.
  41           * @details The sender is stopped until the receiver executes a
  42           *          @p chMsgRelease()after receiving the message.
  43           *
  44           * @param[in] tp        the pointer to the thread
  45           * @param[in] msg       the message
  46           * @return              The answer message from @p chMsgRelease().
  47           */
  48          msg_t chMsgSend(Thread *tp, msg_t msg) {
  49   1        Thread *ctp = currp;
  50   1      
  51   1        chDbgCheck(tp != NULL, "chMsgSend");
  52   1      
  53   1        chSysLock();
  54   1        ctp->p_msg = msg;
  55   1        ctp->p_u.wtobjp = &tp->p_msgqueue;
  56   1        msg_insert(ctp, &tp->p_msgqueue);
  57   1        if (tp->p_state == THD_STATE_WTMSG)
  58   1          chSchReadyI(tp);
  59   1        chSchGoSleepS(THD_STATE_SNDMSG);
  60   1        msg = ctp->p_u.rdymsg;
  61   1        chSysUnlock();
  62   1        return msg;
  63   1      }
  64          
  65          /**
  66           * @brief   Suspends the thread and waits for an incoming message.
  67           * @note    You can assume that the data contained in the message is stable
  68           *          until you invoke @p chMsgRelease() because the sending thread is
  69           *          suspended until then.
  70           *
  71           * @return              The pointer to the message structure. Note, it is
  72           *                      always the message associated to the thread on the
  73           *                      top of the messages queue.
  74           */
  75          msg_t chMsgWait(void) {
  76   1        msg_t msg;
  77   1      
  78   1        chSysLock();
  79   1        if (!chMsgIsPendingI(currp))
  80   1          chSchGoSleepS(THD_STATE_WTMSG);
  81   1        msg = chMsgGetI(currp);
  82   1      /*  msg = chMsgGetI((volatile Thread *)currp);*/ /* Temporary hack.*/
  83   1        chSysUnlock();
  84   1        return msg;
  85   1      }
  86          
  87          /**
  88           * @brief   Returns the next message in the queue.
  89           * @note    You can assume that the data pointed by the message is stable until
  90           *          you invoke @p chMsgRelease() because the sending thread is
  91           *          suspended until then. Always remember that the message data is not
  92           *          copied between the sender and the receiver, just a pointer is
  93           *          passed.
  94           *
  95           * @return              The pointer to the message structure. Note, it is
  96           *                      always the message associated to the thread on the
  97           *                      top of the messages queue.
  98           * @retval NULL         if the queue is empty.
  99           */
 100          msg_t chMsgGet(void) {
 101   1        msg_t msg;
 102   1      
 103   1        chSysLock();
 104   1        msg = chMsgIsPendingI(currp) ? chMsgGetI(currp) : (msg_t)NULL;
 105   1        chSysUnlock();
 106   1        return msg;
 107   1      }
 108          
 109          /**
 110           * @brief   Releases the thread waiting on top of the messages queue.
 111           * @note    You can call this function only if there is a message already in
 112           *          the queue else the result will be unpredictable (a crash most likely).
 113           *          Exiting from the @p chMsgWait() ensures you have at least one
 114           *          message in the queue so it is not a big deal.<br />
 115           *          The condition is only tested in debug mode in order to make this
 116           *          code as fast as possible.
 117           *
 118           * @param[in] msg       the message returned to the message sender
 119           */
 120          void chMsgRelease(msg_t msg) {
 121   1      
 122   1        chSysLock();
 123   1        chDbgAssert(chMsgIsPendingI(currp),
 124   1                    "chMsgRelease(), #1",
 125   1                    "no message pending");
 126   1        chSchWakeupS(fifo_remove(&currp->p_msgqueue), msg);
 127   1        chSysUnlock();
 128   1      }
 129          
 130          #endif /* CH_USE_MESSAGES */
 131          
 132          /** @} */
 133          
RCSTM8 COMPILER V2.26.09.317
ASSEMBLY LISTING OF GENERATED OBJECT CODE

              ; FUNCTION ?chMsgSend (BEGIN)
              ; Register-parameter tp (XW) is relocated (auto)
              ; SOURCE LINE # 48 
0000 89                                PUSHW  X
0001 89                                PUSHW  X
              ; SOURCE LINE # 49 
0002 CE0000     F                      LDW    X,rlist + 0DH
0005 1F01       F                      LDW    (001H,SP),X   ; [ ctp ]
0007         ?LAB_0003:
              ; SOURCE LINE # 53 
0007 9B                                SIM    
              ; SOURCE LINE # 54 
0008 1E01       F                      LDW    X,(001H,SP)   ; [ ctp ]
000A 1607       F                      LDW    Y,(007H,SP)   ; [ msg ]
000C EF17                              LDW    (017H,X),Y
              ; SOURCE LINE # 55 
000E 1E03       F                      LDW    X,(003H,SP)   ; [ tp ]
0010 1C0013                            ADDW   X,#00013H
0013 1601       F                      LDW    Y,(001H,SP)   ; [ ctp ]
0015 90EF0F                            LDW    (00FH,Y),X
              ; SOURCE LINE # 56 
0018 1E03       F                      LDW    X,(003H,SP)   ; [ tp ]
001A 1C0013                            ADDW   X,#00013H
001D 89                                PUSHW  X
001E 93                                LDW    X,Y
001F CD0000     F                      CALL   ?queue_insert
0022 85                                POPW   X
              ; SOURCE LINE # 57 
0023 1E03       F                      LDW    X,(003H,SP)   ; [ tp ]
0025 A60B                              LD     A,#00BH
0027 E10B                              CP     A,(00BH,X)
0029 2603                              JRNE   ?NXT_0001
              ; SOURCE LINE # 58 
002B CD0000     F                      CALL   ?chSchReadyI
002E         ?NXT_0001:
              ; SOURCE LINE # 59 
002E A60A                              LD     A,#00AH
0030 CD0000     F                      CALL   ?chSchGoSleepS
              ; SOURCE LINE # 60 
0033 1E01       F                      LDW    X,(001H,SP)   ; [ ctp ]
0035 EE0F                              LDW    X,(00FH,X)
0037 1F07       F                      LDW    (007H,SP),X   ; [ msg ]
              ; SOURCE LINE # 61 
0039 9A                                RIM    
              ; SOURCE LINE # 62 
003A 5B04                              ADD    SP,#004H
003C 81                                RET    
              ; tp           pointer to ( Thread-struct (size=27-Alg) in )(size=2).  parameter in AUTO
              ; msg          short  (size=2-Alg).  parameter in AUTO
              ; ctp          pointer to ( Thread-struct (size=27-Alg) in )(size=2). Automatic variable  in AUTO

              ; FUNCTION ?chMsgSend (END)

              ; FUNCTION ?chMsgWait (BEGIN)
              ; SOURCE LINE # 75 
0000 5206                              SUB    SP,#006H
              ; SOURCE LINE # 78 
0002 9B                                SIM    
              ; SOURCE LINE # 79 
0003 CE0000     F                      LDW    X,rlist + 0DH
0006 1C0013                            ADDW   X,#00013H
0009 1F03       F                      LDW    (003H,SP),X
000B FE                                LDW    X,(X)
000C 1F05       F                      LDW    (005H,SP),X
000E 1303       F                      CPW    X,(003H,SP)
0010 2605                              JRNE   ?NXT_0003
              ; SOURCE LINE # 80 
0012 A60B                              LD     A,#00BH
0014 CD0000     F                      CALL   ?chSchGoSleepS
0017         ?NXT_0003:
              ; SOURCE LINE # 81 
0017 1E05       F                      LDW    X,(005H,SP)
0019 EE17                              LDW    X,(017H,X)
001B 1F01       F                      LDW    (001H,SP),X   ; [ msg ]
              ; SOURCE LINE # 83 
001D 9A                                RIM    
              ; SOURCE LINE # 84 
001E 5B06                              ADD    SP,#006H
0020 81                                RET    
              ; msg          short  (size=2-Alg). Automatic variable  in AUTO

              ; FUNCTION ?chMsgWait (END)

              ; FUNCTION ?chMsgGet (BEGIN)
              ; SOURCE LINE # 100 
0000 5206                              SUB    SP,#006H
              ; SOURCE LINE # 103 
0002 9B                                SIM    
              ; SOURCE LINE # 104 
0003 CE0000     F                      LDW    X,rlist + 0DH
0006 1C0013                            ADDW   X,#00013H
0009 1F03       F                      LDW    (003H,SP),X
000B FE                                LDW    X,(X)
000C 1303       F                      CPW    X,(003H,SP)
000E 2707                              JREQ   ?ELSE_0005
0010 1E03       F                      LDW    X,(003H,SP)
0012 FE                                LDW    X,(X)
0013 EE17                              LDW    X,(017H,X)
0015 2001                              JRA    ?NXT_0005
0017         ?ELSE_0005:
0017 5F                                CLRW   X
0018         ?NXT_0005:
0018 1F01       F                      LDW    (001H,SP),X   ; [ msg ]
              ; SOURCE LINE # 105 
001A 9A                                RIM    
              ; SOURCE LINE # 106 
001B 5B06                              ADD    SP,#006H
001D 81                                RET    
              ; msg          short  (size=2-Alg). Automatic variable  in AUTO

              ; FUNCTION ?chMsgGet (END)

              ; FUNCTION ?chMsgRelease (BEGIN)
              ; Register-parameter msg (XW) is relocated (auto)
              ; SOURCE LINE # 120 
0000 89                                PUSHW  X
0001 89                                PUSHW  X
              ; SOURCE LINE # 122 
0002 9B                                SIM    
0003         ?LAB_0007:
              ; SOURCE LINE # 126 
0003 1E03       F                      LDW    X,(003H,SP)   ; [ msg ]
0005 89                                PUSHW  X
0006 CE0000     F                      LDW    X,rlist + 0DH
0009 1C0013                            ADDW   X,#00013H
000C CD0000     F                      CALL   ?fifo_remove
000F CD0000     F                      CALL   ?chSchWakeupS
0012 85                                POPW   X
              ; SOURCE LINE # 127 
0013 9A                                RIM    
0014 5B04                              ADD    SP,#004H
0016 81                                RET    
              ; msg          short  (size=2-Alg).  parameter in AUTO

              ; FUNCTION ?chMsgRelease (END)

RCSTM8 COMPILER V2.26.09.317


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    147    ----
   CONSTANT SIZE    =     29    ----
   DATA SIZE        =   ----    ----
   PAGE0 SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.

RCSTM8 COMPILATION COMPLETE.  0 WARNING,  0 ERROR

The whole thing can be accessed here (it is a temporary branch): https://chibios.svn.sourceforge.net/svnroot/chibios/branches/stm8_dev

It contains the R7 project and runs on the REva 3 board.

thank you,
Giovanni

+1
0
-1
March 29, 2010 - 11:34pm
Guest

Hi,

I'm currently evaluating the STM8 Raisonance compiler for a commercial product and have been working with this RTOS. Are there any updates to the status of this problem?

Thanks