clingos 发表于 2010-5-25 09:36:00

Nucleus Plus移植疑惑?

看了Nucleus Plus有些移植代码觉得很多是可以用C实现的,不知为什么它选择用ASM不解,不知是我理解错误还是什么?
比如:
;VOIDTMT_Set_Clock(UNSIGNED new_value)
;{
      EXPORTTMT_Set_Clock
TMT_Set_Clock
;
;    /* Set the system clock to the specified value.*/
;    TMD_System_Clock =new_value;
;
      LDR   a2,; Build address of system clock
      STR   a1,                  ; Store new system clock value

      [ THUMB
      BX      lr                               ; Return to caller
      |
      MOV   pc,lr                     ; Return to caller
      ]
;}

个人觉得这个函数完全可以用C实现如下:
VOIDTMT_Set_Clock(UNSIGNED new_value)
{
    OS_CPU_SR();

    OS_DISABLE_INT();

    /* Set the system clock to the specified value.*/
   TMD_System_Clock =new_value;

   OS_RESTORE_INT();
}
我觉得TMT.S中的函数都可以这样实现
请高手们指点一下,能说下它为什么不用C来实现吗?

clingos 发表于 2010-5-25 10:01:30

STATUSTCT_Activate_HISR(TC_HCB *hisr)
{
    INT priority;   
    OS_CPU_SR();
    /* Lockout interrupts.*/
    OS_DISABLE_INT();   
    /* Determine if the HISR is already active.*/
    if (hisr -> tc_activation_count) {
      /* Increment the activation count.Make sure that it does not go
         to zero.*/
      hisr -> tc_activation_count++;
      if (hisr -> tc_activation_count == 0) {
            hisr -> tc_activation_count =0xFFFFFFFFUL;
      }
    }
    else {
      /* Set the activation count to 1.*/
      hisr -> tc_activation_count =1;
      /* Pickup the HISR's priority.*/
      priority =hisr -> tc_priority;
      /* Determine if there is something in the given priority list.*/
      if (TCD_Active_HISR_Tails) {
            /* Something is already on this list.Add after the tail.*/
            (TCD_Active_HISR_Tails) -> tc_active_next =hisr;
            TCD_Active_HISR_Tails =hisr;
      }
      else {
         /* Nothing is on this list.*/
         TCD_Active_HISR_Heads =hisr;
         TCD_Active_HISR_Tails =hisr;         
         /* Determine the highest priority HISR.*/
         if (TCD_Active_HISR_Heads) {
               TCD_Execute_HISR =TCD_Active_HISR_Heads;
         }
         else if (TCD_Active_HISR_Heads) {
               TCD_Execute_HISR =TCD_Active_HISR_Heads;
         }
         else {
               TCD_Execute_HISR =TCD_Active_HISR_Heads;
         }
      }
    }
    OS_RESTORE_INT();   
    return(NU_SUCCESS);
}

clingos 发表于 2010-5-25 12:06:18

自己顶起来,大侠们哪去了?

clingos 发表于 2010-5-26 13:11:31

等啊!!!

wc261034 发表于 2013-8-28 14:52:13

请问 这个问题解决吗
页: [1]
查看完整版本: Nucleus Plus移植疑惑?