assembly support for assert function

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

assembly support for assert function

654件の閲覧回数
kraig1
Contributor I

I am in the process of porting some software from TI to MPC8377. In the TI platform, there was an instruction (ESTOP0) that would halt the debugger if it was attached or no op if no debugger is attached. This instruction was useful for debugging for implementing an Assert function. Is there an equivalent instruction(s) in the MPC8377? I didn't see one in the programming manual or the forums and it seems like others implementing an assert would be interested in this. Ideally, there wouldn't be a need to build a debug version of software, but it would be acceptable if that is the only solution.

The other nifty thing our assert function does is store the program counter to a global variable. At runtime, you can inspect this variable to get the memory address of a potential problem. In the PowerPC, the program counter is not available. Is there a way to get the program counter value?

-Kraig

タグ(1)
0 件の賞賛
返信
1 返信

533件の閲覧回数
TomE
Specialist II

Finding if running under the debugger:

 

Searching this forum finds previous posts describing how I solved the "Debugger is Connected" problem on a Freescale MPC860. These may give hints on how to do something similar on your CPU. The second one is very similar to what you want - finding an equivalent to "assert".

 

https://community.freescale.com/message/97310#97310

 

https://community.freescale.com/message/84292#84292

 

Getting the program Counter:

 

I'd forgotten about this. Weird CPU, isn't it? From Assembly (or in-line assembly) you can perform a "bl" or "bla" to somewhere (even the next instruction), which will put the PC into the Link Register and then use "mflr" to get that value into a general purpose register. Then you have to store it somewhere. If you want to write in C and not use inline assembly, then call a simple assembly function. The call will put the PC into the Link Register and the assembly function can simply store the LR into a global. The other approach is to declare a label in your macro and then just load the address of that label. Remember you also have "__FILE__" and "__LINE__" available to give a "higher level" indication of where the Assert was.

 

Tom

 

0 件の賞賛
返信