os_task.ls1

来自「在51单片机上移植成功的UCOS-II操作系统源代码,包括源代码及相关注释」· LS1 代码 · 共 1,019 行 · 第 1/5 页

LS1
1,019
字号

015C E6              536             MOV     A,@R0
015D 602B            537             JZ      ?C0007
                     538     ;                 OSSched();
                     539                             ; SOURCE LINE # 195
015F 120000   F      540             LCALL   _?OSSched
                     541     ;             }
                     542                             ; SOURCE LINE # 196
                     543     ;         } else {
                     544                             ; SOURCE LINE # 197
0162 8026            545             SJMP    ?C0007
0164                 546     ?C0005:
                     547     ;             OS_ENTER_CRITICAL();
                     548                             ; SOURCE LINE # 198
0164 C2AF            549             CLR     EA
                     550     ;             OSTCBPrioTbl[prio] = (OS_TCB *)0;/* Make this priority available to others   
                                           */
                     551                             ; SOURCE LINE # 199
0166 7B00            552             MOV     R3,#00H
0168 7A00            553             MOV     R2,#00H
016A 7900            554             MOV     R1,#00H
016C 90000D          555             MOV     DPTR,#0DH
016F 120000   F      556             LCALL   ?C?XBPOFF
0172 E0              557             MOVX    A,@DPTR
0173 75F003          558             MOV     B,#03H
0176 A4              559             MUL     AB
0177 2400     F      560             ADD     A,#LOW (OSTCBPrioTbl)
0179 F582            561             MOV     DPL,A
017B E4              562             CLR     A
017C 3400     F      563             ADDC    A,#HIGH (OSTCBPrioTbl)
017E F583            564             MOV     DPH,A
0180 EB              565             MOV     A,R3
0181 F0              566             MOVX    @DPTR,A
0182 A3              567             INC     DPTR
0183 EA              568             MOV     A,R2
0184 F0              569             MOVX    @DPTR,A
0185 A3              570             INC     DPTR
0186 E9              571             MOV     A,R1
0187 F0              572             MOVX    @DPTR,A
                     573     ;             OS_EXIT_CRITICAL();
                     574                             ; SOURCE LINE # 200
0188 D2AF            575             SETB    EA
                     576     ;         }
                     577                             ; SOURCE LINE # 201
018A                 578     ?C0007:
                     579     ;         return (err);
                     580                             ; SOURCE LINE # 202
018A 900003          581             MOV     DPTR,#03H
018D 120000   F      582             LCALL   ?C?XBPOFF
0190 E0              583             MOVX    A,@DPTR
0191 FF              584             MOV     R7,A
0192 8004            585             SJMP    ?C0003
                     586     ;     } else {
                     587                             ; SOURCE LINE # 203
0194                 588     ?C0004:
                     589     ;         OS_EXIT_CRITICAL();
                     590                             ; SOURCE LINE # 204
0194 D2AF            591             SETB    EA
                     592     ;         return (OS_PRIO_EXIST);
                     593                             ; SOURCE LINE # 205
0196 7F28            594             MOV     R7,#028H
                     595     ;     }
                     596                             ; SOURCE LINE # 206
                     597     ; }
                     598                             ; SOURCE LINE # 207
0198                 599     ?C0003:
0198 90000E          600             MOV     DPTR,#0EH
A51 MACRO ASSEMBLER  OS_TASK                                                              09/09/2007 21:13:11 PAGE    11

019B 020000   F      601             LJMP    ?C?ADDXBP
                     602     ; END OF _?OSTaskCreate
                     603     
                     604     ; #endif
                     605     ; /*$PAGE*/
                     606     ; /*
                     607     ; *****************************************************************************************
                             ****************
                     608     ; *                                     CREATE A TASK (Extended Version)
                     609     ; *
                     610     ; * Description: This function is used to have uC/OS-II manage the execution of a task.  Ta
                             sks can either
                     611     ; *              be created prior to the start of multitasking or by a running task.  A tas
                             k cannot be
                     612     ; *              created by an ISR.  This function is similar to OSTaskCreate() except that
                              it allows
                     613     ; *              additional information about a task to be specified.
                     614     ; *
                     615     ; * Arguments  : task     is a pointer to the task's code
                     616     ; *
                     617     ; *              pdata    is a pointer to an optional data area which can be used to pass p
                             arameters to
                     618     ; *                       the task when the task first executes.  Where the task is concern
                             ed it thinks
                     619     ; *                       it was invoked and passed the argument 'pdata' as follows:
                     620     ; *
                     621     ; *                           void Task (void *pdata)
                     622     ; *                           {
                     623     ; *                               for (;;) {
                     624     ; *                                   Task code;
                     625     ; *                               }
                     626     ; *                           }
                     627     ; *
                     628     ; *              ptos     is a pointer to the task's top of stack.  If the configuration co
                             nstant 
                     629     ; *                       OS_STK_GROWTH is set to 1, the stack is assumed to grow downward 
                             (i.e. from high
                     630     ; *                       memory to low memory).  'pstk' will thus point to the highest (va
                             lid) memory 
                     631     ; *                       location of the stack.  If OS_STK_GROWTH is set to 0, 'pstk' will
                              point to the 
                     632     ; *                       lowest memory location of the stack and the stack will grow with 
                             increasing
                     633     ; *                       memory locations.  'pstk' MUST point to a valid 'free' data item.
                     634     ; *
                     635     ; *              prio     is the task's priority.  A unique priority MUST be assigned to ea
                             ch task and the
                     636     ; *                       lower the number, the higher the priority.
                     637     ; *
                     638     ; *              id       is the task's ID (0..65535)
                     639     ; *
                     640     ; *              pbos     is a pointer to the task's bottom of stack.  If the configuration
                              constant 
                     641     ; *                       OS_STK_GROWTH is set to 1, the stack is assumed to grow downward 
                             (i.e. from high
                     642     ; *                       memory to low memory).  'pbos' will thus point to the LOWEST (val
                             id) memory 
                     643     ; *                       location of the stack.  If OS_STK_GROWTH is set to 0, 'pbos' will
                              point to the 
                     644     ; *                       HIGHEST memory location of the stack and the stack will grow with
                              increasing
                     645     ; *                       memory locations.  'pbos' MUST point to a valid 'free' data item.
                     646     ; *
                     647     ; *              stk_size is the size of the stack in number of elements.  If OS_STK is set
                              to INT8U,
                     648     ; *                       'stk_size' corresponds to the number of bytes available.  If OS_S
A51 MACRO ASSEMBLER  OS_TASK                                                              09/09/2007 21:13:11 PAGE    12

                             TK is set to
                     649     ; *                       INT16U, 'stk_size' contains the number of 16-bit entries availabl
                             e.  Finally, if
                     650     ; *                       OS_STK is set to INT32U, 'stk_size' contains the number of 32-bit
                              entries
                     651     ; *                       available on the stack.
                     652     ; *
                     653     ; *              pext     is a pointer to a user supplied memory location which is used as 
                             a TCB extension.
                     654     ; *                       For example, this user memory can hold the contents of floating-p
                             oint registers
                     655     ; *                       during a context switch, the time each task takes to execute, the
                              number of times
                     656     ; *                       the task has been switched-in, etc. 
                     657     ; *
                     658     ; *              opt      contains additional information (or options) about the behavior o
                             f the task.  The 
                     659     ; *                       LOWER 8-bits are reserved by uC/OS-II while the upper 8 bits can 
                             be application 
                     660     ; *                       specific.  See OS_TASK_OPT_??? in uCOS-II.H.
                     661     ; *
                     662     ; * Returns    : OS_NO_ERR        if the function was successful.
                     663     ; *              OS_PRIO_EXIT     if the task priority already exist 
                     664     ; *                               (each task MUST have a unique priority).
                     665     ; *              OS_PRIO_INVALID  if the priority you specify is higher that the maximum al
                             lowed 
                     666     ; *                               (i.e. > OS_LOWEST_PRIO)
                     667     ; *****************************************************************************************
                             ****************
                     668     ; */
                     669     ; /*$PAGE*/
                     670     ; #if   OS_TASK_CREATE_EXT_EN    
                     671     ; INT8U OSTaskCreateExt (void   (*task)(void *pd), 
                     672     ;                        void    *ppdata, 
                     673     ;                        OS_STK  *ptos, 
                     674     ;                        INT8U    prio,
                     675     ;                        INT16U   id,
                     676     ;                        OS_STK  *pbos,
                     677     ;                        INT32U   stk_size,
                     678     ;                        void    *pext,
                     679     ;                        INT16U   opt) reentrant
                     680     ; {
                     681     ;     void    *psp;
                     682     ;     INT8U    err;
                     683     ;     INT16U   i;
                     684     ;     OS_STK  *pfill;
                     685     ; 
                     686     ; 
                     687     ;     if (prio > OS_LOWEST_PRIO) {             /* Make sure priority is within allowable ra
                             nge           */
                     688     ;         return (OS_PRIO_INVALID);
                     689     ;     }
                     690     ;     OS_ENTER_CRITICAL();
                     691     ;     if (OSTCBPrioTbl[prio] == (OS_TCB *)0) { /* Make sure task doesn't already exist at t
                             his priority  */
                     692     ;         OSTCBPrioTbl[prio] = (OS_TCB *)1;    /* Reserve the priority to prevent others fr
                             om doing ...  */
                     693     ;                                              /* ... the same thing until task is created.
                                           */
                     694     ;         OS_EXIT_CRITICAL();
                     695     ;         
                     696     ;         if (opt & OS_TASK_OPT_STK_CHK) {     /* See if stack checking has been enabled   
                                           */
                     697     ;             if (opt & OS_TASK_OPT_STK_CLR) { /* See if stack needs to be cleared         
                                           */
                     698     ;                 pfill = pbos;                /* Yes, fill the stack with zeros           
A51 MACRO ASSEMBLER  OS_TASK                                                              09/09/2007 21:13:11 PAGE    13

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?