When will CCR.V be set? Could you give an example?

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

When will CCR.V be set? Could you give an example?

ソリューションへジャンプ
1,756件の閲覧回数
fqh
Contributor II

The MCU is MC9S12ZVCA96, and the IDE is codewarrior 10.7.

We need to check the overflow bit CCR.V after an addition operation.

There is no intrinsic function for CCR.V checking. So we can't let the compiler to generate BVC/BVS instruction except assembly language.

 

0 件の賞賛
返信
1 解決策
1,719件の閲覧回数
lama
NXP TechSupport
NXP TechSupport

Hi,

yes you can do any of ASM branch instructions or you can use following code and then work with C and defined variable. The OV test is not a standard function because it would require  application SW reaction. It would enter additional code which is usually not necessary. This must be handled by app. engineer which also leads him to think about used variables ranges.

//================= GLOBAL VARIABLES ===================================
unsigned char CCRbackup;  // temp variable to store CCRL, byte because CCRL is only used
//================= MACROS ==========================================

// save CCR to variable CCRbackup ... reg. D0 is used as an information carrier
#define getCCR() { asm PSH D0;   asm TFR CCL,D0;   asm ST D0, CCRbackup;   asm PUL D0; }

//==================================================================
// Main
//==================================================================
void main(void)
{
  //------------------------
  // example of reading CCR start, the CCR is tored into the global variable CCRbackup
  //------------------------
  getCCR();                              // the CCRL is stored in the CCRbackup variable
  //------------------------

 

Best regards,

Ladislav

元の投稿で解決策を見る

1 返信
1,720件の閲覧回数
lama
NXP TechSupport
NXP TechSupport

Hi,

yes you can do any of ASM branch instructions or you can use following code and then work with C and defined variable. The OV test is not a standard function because it would require  application SW reaction. It would enter additional code which is usually not necessary. This must be handled by app. engineer which also leads him to think about used variables ranges.

//================= GLOBAL VARIABLES ===================================
unsigned char CCRbackup;  // temp variable to store CCRL, byte because CCRL is only used
//================= MACROS ==========================================

// save CCR to variable CCRbackup ... reg. D0 is used as an information carrier
#define getCCR() { asm PSH D0;   asm TFR CCL,D0;   asm ST D0, CCRbackup;   asm PUL D0; }

//==================================================================
// Main
//==================================================================
void main(void)
{
  //------------------------
  // example of reading CCR start, the CCR is tored into the global variable CCRbackup
  //------------------------
  getCCR();                              // the CCRL is stored in the CCRbackup variable
  //------------------------

 

Best regards,

Ladislav

%3CLINGO-SUB%20id%3D%22lingo-sub-1963925%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ECCR%E3%81%AF%E3%81%84%E3%81%A4%E3%81%AB%E3%81%AA%E3%82%8A%E3%81%BE%E3%81%99%E3%81%8B%E3%80%82V%E3%81%AF%E8%A8%AD%E5%AE%9A%E3%81%95%E3%82%8C%E3%81%BE%E3%81%99%E3%81%8B%3F%E4%BE%8B%E3%82%92%E6%8C%99%E3%81%92%E3%81%A6%E3%81%84%E3%81%9F%E3%81%A0%E3%81%91%E3%81%BE%E3%81%99%E3%81%8B%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1963925%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EMCU%E3%81%AFMC9S12ZVCA96%E3%81%A7%E3%80%81IDE%E3%81%AFcodewarrior%2010.7%E3%81%A7%E3%81%99%E3%80%82%3C%2FP%3E%3CP%3E%E3%82%AA%E3%83%BC%E3%83%90%E3%83%BC%E3%83%95%E3%83%AD%E3%83%BC%E3%83%93%E3%83%83%E3%83%88CCR%E3%82%92%E7%A2%BA%E8%AA%8D%E3%81%99%E3%82%8B%E5%BF%85%E8%A6%81%E3%81%8C%E3%81%82%E3%82%8A%E3%81%BE%E3%81%99%E3%80%82%E5%8A%A0%E7%AE%97%E6%BC%94%E7%AE%97%E5%BE%8C%E3%81%AEV%E3%80%82%3C%2FP%3E%3CP%3ECCR%20%E3%81%AB%E3%81%AF%E5%9B%BA%E6%9C%89%E3%81%AE%E6%A9%9F%E8%83%BD%E3%81%AF%E3%81%82%E3%82%8A%E3%81%BE%E3%81%9B%E3%82%93%E3%80%82V%E3%83%81%E3%82%A7%E3%83%83%E3%82%AF%E3%80%82%E3%81%97%E3%81%9F%E3%81%8C%E3%81%A3%E3%81%A6%E3%80%81%E3%82%B3%E3%83%B3%E3%83%91%E3%82%A4%E3%83%A9%E3%81%AB%E3%82%A2%E3%82%BB%E3%83%B3%E3%83%96%E3%83%AA%E8%A8%80%E8%AA%9E%E4%BB%A5%E5%A4%96%E3%81%AEBVC%20%2F%20BVS%E5%91%BD%E4%BB%A4%E3%82%92%E7%94%9F%E6%88%90%E3%81%95%E3%81%9B%E3%82%8B%E3%81%93%E3%81%A8%E3%81%AF%E3%81%A7%E3%81%8D%E3%81%BE%E3%81%9B%E3%82%93%E3%80%82%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E