Accessing Control Registers with inline assembly

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Accessing Control Registers with inline assembly

Jump to solution
1,013 Views
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.

Labels (1)
0 Kudos
1 Solution
699 Views
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

View solution in original post

0 Kudos
3 Replies
699 Views
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 Kudos
700 Views
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 Kudos
699 Views
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 Kudos