⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 os_task.ls1

📁 UCOS在51上的移植,绝对经典!可以较少开发人员的工作量
💻 LS1
📖 第 1 页 / 共 3 页
字号:
                     213     ;                     OSRdyGrp &= ~ptcb->OSTCBBitY;
                     214     ;                 }
                     215     ;                 OSRdyGrp    |= bity;                            /* Make new priority read
                             y to run      */
                     216     ;                 OSRdyTbl[y] |= bitx;
                     217     ; #if OS_EVENT_EN > 0
                     218     ;             } else {
                     219     ;                 pevent = ptcb->OSTCBEventPtr;
                     220     ;                 if (pevent != (OS_EVENT *)0) {                  /* Remove from event wait
                              list  */
                     221     ;                     if ((pevent->OSEventTbl[ptcb->OSTCBY] &= ~ptcb->OSTCBBitX) == 0) {
                     222     ;                         pevent->OSEventGrp &= ~ptcb->OSTCBBitY;
                     223     ;                     }
                     224     ;                     pevent->OSEventGrp    |= bity;              /* Add new priority to wa
                             it list       */
                     225     ;                     pevent->OSEventTbl[y] |= bitx;
                     226     ;                 }
                     227     ; #endif
                     228     ;             }
                     229     ;             OSTCBPrioTbl[newprio] = ptcb;                       /* Place pointer to TCB @
                              new priority */
                     230     ;             ptcb->OSTCBPrio       = newprio;                    /* Set new task priority 
                                           */
                     231     ;             ptcb->OSTCBY          = y;
                     232     ;             ptcb->OSTCBX          = x;
                     233     ;             ptcb->OSTCBBitY       = bity;
A51 MACRO ASSEMBLER  OS_TASK                                                              05/17/2005 11:19:58 PAGE     5

                     234     ;             ptcb->OSTCBBitX       = bitx;
                     235     ;             OS_EXIT_CRITICAL();
                     236     ;             OS_Sched();                                         /* Run highest priority t
                             ask ready     */
                     237     ;             return (OS_NO_ERR);
                     238     ;         } else {
                     239     ;             OSTCBPrioTbl[newprio] = (OS_TCB *)0;                /* Release the reserved p
                             rio.          */
                     240     ;             OS_EXIT_CRITICAL();
                     241     ;             return (OS_PRIO_ERR);                               /* Task to change didn't 
                             exist         */
                     242     ;         }
                     243     ;     }
                     244     ; }
                     245     ; #endif
                     246     ; /*$PAGE*/
                     247     ; /*
                     248     ; *****************************************************************************************
                             ****************
                     249     ; *                                            CREATE A TASK
                     250     ; *
                     251     ; * Description: This function is used to have uC/OS-II manage the execution of a task.  Ta
                             sks can either
                     252     ; *              be created prior to the start of multitasking or by a running task.  A tas
                             k cannot be
                     253     ; *              created by an ISR.
                     254     ; *
                     255     ; * Arguments  : task     is a pointer to the task's code
                     256     ; *
                     257     ; *              pdata    is a pointer to an optional data area which can be used to pass p
                             arameters to
                     258     ; *                       the task when the task first executes.  Where the task is concern
                             ed it thinks
                     259     ; *                       it was invoked and passed the argument 'pdata' as follows:
                     260     ; *
                     261     ; *                           void Task (void *pdata)
                     262     ; *                           {
                     263     ; *                               for (;;) {
                     264     ; *                                   Task code;
                     265     ; *                               }
                     266     ; *                           }
                     267     ; *
                     268     ; *              ptos     is a pointer to the task's top of stack.  If the configuration co
                             nstant
                     269     ; *                       OS_STK_GROWTH is set to 1, the stack is assumed to grow downward 
                             (i.e. from high
                     270     ; *                       memory to low memory).  'pstk' will thus point to the highest (va
                             lid) memory
                     271     ; *                       location of the stack.  If OS_STK_GROWTH is set to 0, 'pstk' will
                              point to the
                     272     ; *                       lowest memory location of the stack and the stack will grow with 
                             increasing
                     273     ; *                       memory locations.
                     274     ; *
                     275     ; *              prio     is the task's priority.  A unique priority MUST be assigned to ea
                             ch task and the
                     276     ; *                       lower the number, the higher the priority.
                     277     ; *
                     278     ; * Returns    : OS_NO_ERR        if the function was successful.
                     279     ; *              OS_PRIO_EXIT     if the task priority already exist
                     280     ; *                               (each task MUST have a unique priority).
                     281     ; *              OS_PRIO_INVALID  if the priority you specify is higher that the maximum al
                             lowed
                     282     ; *                               (i.e. >= OS_LOWEST_PRIO)
                     283     ; *****************************************************************************************
                             ****************
A51 MACRO ASSEMBLER  OS_TASK                                                              05/17/2005 11:19:58 PAGE     6

                     284     ; */
                     285     ; 
                     286     ; #if OS_TASK_CREATE_EN > 0
                     287     ; INT8U  OSTaskCreate (void (*task)(void *pd)TASK_REENTRANT, void *os_pdata, OS_STK *ptos, 
                             INT8U prio)TASK_REENTRANT
                     288     
----                 289             RSEG  ?PR?_?OSTaskCreate?OS_TASK
0000                 290     _?OSTaskCreate:
                     291             USING   0
                     292                             ; SOURCE LINE # 158
0000 90FFFD          293             MOV     DPTR,#0FFFDH
0003 120000   F      294             LCALL   ?C?ADDXBP
0006 120000   F      295             LCALL   ?C?PSTXDATA
0009 90FFFC          296             MOV     DPTR,#0FFFCH
000C 120000   F      297             LCALL   ?C?ADDXBP
                     298     ; {
                     299     ; #if OS_CRITICAL_METHOD == 3                  /* Allocate storage for CPU status register 
                                           */
                     300     ;     OS_CPU_SR  cpu_sr;
                     301     ; #endif
                     302     ;     OS_STK    *psp;
                     303     ;     INT8U      err;
                     304     ; 
                     305     ; 
                     306     ; #if OS_ARG_CHK_EN > 0
                     307     ;     if (prio > OS_LOWEST_PRIO) {             /* Make sure priority is within allowable ra
                             nge           */
                     308                             ; SOURCE LINE # 168
000F 90000D          309             MOV     DPTR,#0DH
0012 120000   F      310             LCALL   ?C?XBPOFF
0015 E0              311             MOVX    A,@DPTR
0016 FE              312             MOV     R6,A
0017 D3              313             SETB    C
0018 9409            314             SUBB    A,#09H
001A 4005            315             JC      ?C0001
                     316     ;         return (OS_PRIO_INVALID);
                     317                             ; SOURCE LINE # 169
001C 7F2A            318             MOV     R7,#02AH
001E 020000   F      319             LJMP    ?C0002
                     320     ;     }
                     321                             ; SOURCE LINE # 170
0021                 322     ?C0001:
                     323     ; #endif
                     324     ;     OS_ENTER_CRITICAL();
                     325                             ; SOURCE LINE # 172
0021 C2AF            326             CLR     EA
                     327     ;     if (OSTCBPrioTbl[prio] == (OS_TCB *)0) { /* Make sure task doesn't already exist at t
                             his priority  */
                     328                             ; SOURCE LINE # 173
0023 EE              329             MOV     A,R6
0024 75F003          330             MOV     B,#03H
0027 A4              331             MUL     AB
0028 2400     F      332             ADD     A,#LOW (OSTCBPrioTbl)
002A F582            333             MOV     DPL,A
002C E4              334             CLR     A
002D 3400     F      335             ADDC    A,#HIGH (OSTCBPrioTbl)
002F F583            336             MOV     DPH,A
0031 120000   F      337             LCALL   ?C?PLDXDATA
0034 E9              338             MOV     A,R1
0035 4A              339             ORL     A,R2
0036 4B              340             ORL     A,R3
0037 6003            341             JZ      $ + 5H
0039 020000   F      342             LJMP    ?C0003
                     343     ;         OSTCBPrioTbl[prio] = (OS_TCB *)1;    /* Reserve the priority to prevent others fr
                             om doing ...  */
                     344                             ; SOURCE LINE # 174
A51 MACRO ASSEMBLER  OS_TASK                                                              05/17/2005 11:19:58 PAGE     7

003C FB              345             MOV     R3,A
003D FA              346             MOV     R2,A
003E 7901            347             MOV     R1,#01H
0040 90000D          348             MOV     DPTR,#0DH
0043 120000   F      349             LCALL   ?C?XBPOFF
0046 E0              350             MOVX    A,@DPTR
0047 75F003          351             MOV     B,#03H
004A A4              352             MUL     AB
004B 2400     F      353             ADD     A,#LOW (OSTCBPrioTbl)
004D F582            354             MOV     DPL,A
004F E4              355             CLR     A
0050 3400     F      356             ADDC    A,#HIGH (OSTCBPrioTbl)
0052 F583            357             MOV     DPH,A
0054 120000   F      358             LCALL   ?C?PSTXDATA
                     359     ;                                              /* ... the same thing until task is created.
                                           */
                     360     ;         OS_EXIT_CRITICAL();
                     361                             ; SOURCE LINE # 176
0057 D2AF            362             SETB    EA
                     363     ;         psp = (OS_STK *)OSTaskStkInit(task, os_pdata, ptos, 0);    /* Initialize the task
                             's stack         */
                     364                             ; SOURCE LINE # 177
0059 90FFFE          365             MOV     DPTR,#0FFFEH
005C 120000   F      366             LCALL   ?C?ADDXBP
005F E4              367             CLR     A
0060 F0              368             MOVX    @DPTR,A
0061 A3              369             INC     DPTR
0062 F0              370             MOVX    @DPTR,A
0063 90000C          371             MOV     DPTR,#0CH
0066 120000   F      372             LCALL   ?C?XBPOFF
0069 120000   F      373             LCALL   ?C?PLDXDATA
006C 90FFFD          374             MOV     DPTR,#0FFFDH
006F 120000   F      375             LCALL   ?C?ADDXBP
0072 120000   F      376             LCALL   ?C?PSTXDATA
0075 90000C          377             MOV     DPTR,#0CH
0078 120000   F      378             LCALL   ?C?XBPOFF
007B 120000   F      379             LCALL   ?C?PLDXDATA
007E 90FFFD          380             MOV     DPTR,#0FFFDH
0081 120000   F      381             LCALL   ?C?ADDXBP
0084 120000   F      382             LCALL   ?C?PSTXDATA
0087 90000C          383             MOV     DPTR,#0CH
008A 120000   F      384             LCALL   ?C?XBPOFF
008D 120000   F      385             LCALL   ?C?PLDXDATA
0090 120000   F      386             LCALL   _?OSTaskStkInit
0093 850083   F      387             MOV     DPH,?C_XBP
0096 850082   F      388             MOV     DPL,?C_XBP+01H
0099 120000   F      389             LCALL   ?C?PSTXDATA
                     390     ;         err = OS_TCBInit(prio, psp, (OS_STK *)0, 0, 0, (void *)0, 0);
                     391                             ; SOURCE LINE # 178
009C 90FFFE          392             MOV     DPTR,#0FFFEH
009F 120000   F      393             LCALL   ?C?ADDXBP
00A2 E4              394             CLR     A
00A3 F0              395             MOVX    @DPTR,A
00A4 A3              396             INC     DPTR
00A5 F0              397             MOVX    @DPTR,A
00A6 FB              398             MOV     R3,A
00A7 FA              399             MOV     R2,A
00A8 F9              400             MOV     R1,A
00A9 90FFFD          401             MOV     DPTR,#0FFFDH
00AC 120000   F      402             LCALL   ?C?ADDXBP
00AF 120000   F      403             LCALL   ?C?PSTXDATA
00B2 90FFFC          404             MOV     DPTR,#0FFFCH
00B5 120000   F      405             LCALL   ?C?ADDXBP
00B8 120000   F      406             LCALL   ?C?LSTKXDATA
00BB 00              407             DB      00H
00BC 00              408             DB      00H
A51 MACRO ASSEMBLER  OS_TASK                                                              05/17/2005 11:19:58 PAGE     8

00BD 00              409             DB      00H
00BE 00              410             DB      00H
00BF 90FFFE          411             MOV     DPTR,#0FFFEH
00C2 120000   F      412             LCALL   ?C?ADDXBP
00C5 E4              413             CLR     A
00C6 F0              414             MOVX    @DPTR,A
00C7 A3              415             INC     DPTR
00C8 F0              416             MOVX    @DPTR,A
00C9 FB              417             MOV     R3,A
00CA FA              418             MOV     R2,A
00CB F9              419             MOV     R1,A
00CC 90FFFD          420             MOV     DPTR,#0FFFDH
00CF 120000   F      421             LCALL   ?C?ADDXBP

⌨️ 快捷键说明

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