This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CLA中的MTESTTF 意思



请大家帮我回答下面两个问题,这是在调试28035的cla遇到的问题,谢谢

_Cla1Task2:

MMOV32 MR0, @_State
MCMPF32 MR0, #0.1 
MCMPF32 MR0, #0.01 
MTESTTF EQ ---------------问题1:---这块是什么意思?
MNOP
MBCNDD _Skip1, NEQ ----------问题2---这块的判断值是MR0与0.1的比较还是MR0与0.01的比较?
MMOV32 MR1, @_RampState 
MMOVXI MR2, #RAMPMASK 
MOR32 MR1, MR2 
MMOV32 @_RampState, MR1 
MSTOP
_Skip1:
MMOV32 MR3, @_SteadyState
MMOVXI MR2, #STEADYMASK
MOR32 MR3, MR2
MBCNDD _Skip2, NTF 
MMOV32 MR1, @_CoastState 
MMOVXI MR2, #COASTMASK 
MOR32 MR1, MR2
MMOV32 @_CoastState, MR1
MSTOP 

  • MCMPF32 MR0, #0.01
    MTESTTF EQ
    这块的意思是先比较MR0和#0.01的大小,前者等于后者MSTF寄存器的ZF=1, NF=0。大于:ZF=0, NF=0。小于:ZF=0, NF=1。然后MTESTTF EQ验证ZF等于1的话,则设置TF等于1,否则TF为0.

  • MBCNDD _Skip1, NEQ这一块是判断的MR0与0.01的比较,MCMPF32 MR0, #0.1的判断结果会被MCMPF32 MR0, #0.01的判断结果覆盖。

  • “MCMPF32 MR0, #0.1的判断结果会被MCMPF32 MR0, #0.01”,那就是说MCMPF32 MR0, #0.1在程序中没有实际的意义是吧,因为其结果被MCMPF32 MR0, #0.01覆盖了。但是我从ti的文档中看到,这两个的注解,好像不是被覆盖的意思?请看P145页MTESTTF CNDF的应用-MS320x2803x Piccolo Control Law Accelerator (CLA) Reference Guide

    _Cla1Task2:
    MMOV32 MR0, @_State
    MCMPF32 MR0, #0.1 ; Affects flags for 1st MBCNDD (A)
    MCMPF32 MR0, #0.01 ; Check used by 2nd MBCNDD (B)
    MTESTTF EQ ; Store EQ flag in TF for 2nd MBCNDD (B)
    MNOP
    MBCNDD _Skip1, NEQ ; (A) If State != 0.1, go to Skip1
    MMOV32 MR1, @_RampState ; Always executed
    MMOVXI MR2, #RAMPMASK ; Always executed
    MOR32 MR1, MR2 ; Always executed
    MMOV32 @_RampState, MR1 ; Execute if (A) branch not taken
    MSTOP ; end of task if (A) branch not taken
    _Skip1:
    MMOV32 MR3, @_SteadyState
    MMOVXI MR2, #STEADYMASK
    MOR32 MR3, MR2
    MBCNDD _Skip2, NTF ; (B) if State != .01, go to Skip2
    MMOV32 MR1, @_CoastState ; Always executed
    MMOVXI MR2, #COASTMASK ; Always executed
    MOR32 MR1, MR2 ; Always executed
    MMOV32 @_CoastState, MR1 ; Execute if (B) branch not taken
    MSTOP ; end of task if (B) branch not taken

  • 抱歉,之前的解释有误,MBCNDD _Skip1, NEQ是判断的MR0与0.1的比较。在MCMPF32 MR0, #0.1被执行完的时候,MBCNDD _Skip1, NEQ 处于pipeline的D2阶段,此时开始测试CNDF的状态,而此时CNDF状态已经被MCMPF32 MR0, #0.1修改,但是还没有被MCMPF32 MR0, #0.01覆盖掉。

  • 为何不能被覆盖呢?那在MBCNDD _Skip1, NEQ之前再增加两个MNOP指令的话,此时的CNDF就被MCMPF32 MR0, #0.01覆盖掉了是吗?

    MMOV32 MR0, @_State
    MCMPF32 MR0, #0.1 ; Affects flags for 1st MBCNDD (A)
    MCMPF32 MR0, #0.01 ; Check used by 2nd MBCNDD (B)
    MTESTTF EQ ; Store EQ flag in TF for 2nd MBCNDD (B)
    MNOP

    MNOP

    MNOP
    MBCNDD _Skip1, NEQ ; (A) If State != 0.1, go to Skip1
    MMOV32 MR1, @_RampState ; Always executed

    还是说在MCMPF32 MR0, #0.1与MCMPF32 MR0, #0.01之间增加三条MNOP指令的话,就会被MCMPF32 MR0, #0.01覆盖掉?

    MMOV32 MR0, @_State
    MCMPF32 MR0, #0.1 ; Affects flags for 1st MBCNDD (A)

    MNOP

    MNOP

    MNOP
    MCMPF32 MR0, #0.01 ; Check used by 2nd MBCNDD (B)
    MTESTTF EQ ; Store EQ flag in TF for 2nd MBCNDD (B)
    MNOP

    MBCNDD _Skip1, NEQ ; (A) If State != 0.1, go to Skip1

    MMOV32 MR1, @_RampState ; Always executed


  • 在CNDF状态被MCMPF32 MR0, #0.01覆盖前,CNDD _Skip1, NEQ的判断就已经发生了,然后CNDF的状态才被覆盖,但此时CNDF状态已经不能影响CNDD _Skip1, NEQ的判断。建议看一下user guide的pipeline部分。再增加一条MNOP指令,CNDF就会被MCMPF32 MR0, #0.01覆盖掉,当然增加两个三个也会被覆盖掉。增加的MNOP指令要放在MCMPF32 MR0, #0.01与MBCNDD _Skip1, NEQ之间。