Microchip
直播中

邓天文

8年用户 268经验值
私信 关注
[问答]

DSPIC跳过指令

我在优化时遇到了这个问题。XC16 V1.30,-O1。DSPIC33 EV256GM106所发生的是调用一个函数,但其中一个参数不是校正函数原型。UE被加载到WrGe0.WRG1中,加载了结构的基地址,然后调用函数。两个地址是正确的。问题是……地址0x2550的指令被跳过!!!!从拆卸视图中退出。除了指令0x2550之外的所有单步骤(跳过)和W9的值在指令之前和之后都没有改变。**我在调用之前还添加了NOP,只是为了保证如果我禁用优化,这不会发生,但是代码变成20%个大的什么??

以上来自于百度翻译


      以下为原文

    I'm having this issue when optimization is enabled.

XC16 v1.30, -O1 enabled.
DSPIC33EV256GM106

what is happening is that a function is called but one of the parameter isn't correct

function prototype
void function(unsigned int param, mystruct_t *mystruct)

this is compiled as


0x2750: MOV #0x1514, W9
0x27A2: MOV #0x1300, W1
0x27A4: MOV [W9], W0
0x27A6: RCALL function



translated, WREG9 is loaded with the address of the variable and then its current value is loaded into WREG0.
WREG1 is loaded with the base address of the structure, then the function is called.
the two addresses are CORRECT

the problem is...
INSTRUCTION AT ADDRESS 0x2750 IS SKIPPED!!!
stepped from disassembly view.. all single steps besides instruction 0x2750 (skipped over) and value of W9 doesn't change before and after the instruction.

** I also added NOPs before the call just to be sure

this is not happening if i disable optimizations, however code becomes 20% bigger
what the??

回帖(2)

王璨

2019-3-6 14:43:33
如果你在0x2550之前向我们展示代码,这将非常有帮助。或者在调用函数时简单地检查寄存器是否包含正确的值。可能是“PARAM”的地址已经被保存在W9中。那么,为什么要重新加载呢?

以上来自于百度翻译


      以下为原文

    It would really help if you showed us the code prior 0x2750 as well.
Or simply check whether the Registers contain the correct values upon calling the function.
Could be that the address of 'param' is already held in W9. Then, why reload?
举报

王官君

2019-3-6 14:48:46
在我写的时候,我添加了一组NopSi,虽然它会很正确,因为传递的参数不正确,WReG9的内容是不正确的,因此它应该被更新。而且,DSPIC如何事先知道它可以跳过指令?不管怎样,为了增加陌生感,我在几行之后评论了一个不同的函数,它毫无问题地工作。我删除了注释,代码再次工作,没有问题。第一个功能是获得正确的参数。

以上来自于百度翻译


      以下为原文

    as i wrote, i added a bunch of NOPs
 
i though it would be ovious that since the passed parameter isn't correct, the content of WREG9 was not correct, therefore it should have been updated.
 
Also, how can the dspic know in advance that it can skip an instruction?
 
Anyway, to add to the strangeness i commented out a call to a different function several lines after, it worked without problems.
 
I removed the comment, the code is working without problems again.. first function is getting the correct parameters.
举报

更多回帖

发帖
×
20
完善资料,
赚取积分