Accessing Control Registers with inline assembly

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Accessing Control Registers with inline assembly

跳至解决方案
2,127 次查看
MiataTexan
Contributor II

I am trying to port an existing 68K program to Coldfire using CodeWarrior.  The existing program was developed using a different tool years ago.  (The tool is obsolete and will not run with Windows 7)  The existing program used inline assembly to display the contents, and in some cases set the contents of the control registers. As an example,

 

asm(

movec VBR, D0

move D0,reg_value

);

where reg_value is a global C variable.

 

This works on the old tool but not with CodeWarrior and results in "illegal use of asm inline function" errors.  How can I access the control registers within C/C++?

Thanks for any help you can provide.

标签 (1)
标记 (1)
0 项奖励
回复
1 解答
1,813 次查看
CrasyCat
Specialist III

Hello

 

 I checked the ColdFire® Family Programmer’s Reference Manual.

 

Description of instruction MOVEC tells that it

"Moves the contents of the general-purpose register to the specified control

register."

 

So

asm{

    move regValue, d0

    movec d0, VBR

}

 

is valid code for Coldfire corem but

 

asm{

    movec VBR, do

    move  d0, regValue

}

 

Is not valid code.

 

CrasyCat

在原帖中查看解决方案

0 项奖励
回复
3 回复数
1,813 次查看
BlackNight
NXP Employee
NXP Employee

Hello,

the error you see might have been a problem with the context you are in.

I just quickly tried

int reg_value;void foo(void) {  asm(    move D0,reg_value  );}

and this works for me (MCU10.2, ColdFire V2 52259).

Of course if you are using the VBR, the compiler/assembler needs to have a declaration for it.

 

Hope this helps,

BK

0 项奖励
回复
1,814 次查看
CrasyCat
Specialist III

Hello

 

 I checked the ColdFire® Family Programmer’s Reference Manual.

 

Description of instruction MOVEC tells that it

"Moves the contents of the general-purpose register to the specified control

register."

 

So

asm{

    move regValue, d0

    movec d0, VBR

}

 

is valid code for Coldfire corem but

 

asm{

    movec VBR, do

    move  d0, regValue

}

 

Is not valid code.

 

CrasyCat

0 项奖励
回复
1,813 次查看
MiataTexan
Contributor II

Thanks.  It appears Coldfire cannot report the current value in the control registers whereas the 68K can.  The original application relied on that feature for error reporting.  Looks like I'll have to set up a structure to keep the last written values to those registers and filter those through the error routines.

 

You saved me a lot of experimentation.  I appreciate it.

0 项奖励
回复