How can I read Control Register VBR with CodeWarrior Coldfire assembler?

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

How can I read Control Register VBR with CodeWarrior Coldfire assembler?

568 Views
johnchan
Contributor I

I am porting Motorola M68000 assembly code to Coldfire M54452 processor using CodeWarrior

Coldfire version 7.1.

The assembly code I'm porting requires reading of some Control Register

for example VBR:

 

movec.l  VBR,a0

 

When I compile this line of code, the assembler generates the following error:

Error: Move from control register not allowed on the current processor type(s).

 

Is there a way to read the control register, in this case VBR?

 

Thanks,

 

John

Labels (1)
0 Kudos
1 Reply

386 Views
Carlos_Mendoza
NXP Employee
NXP Employee

Hi John,

The VBR contains the base address of the exception vector table in memory. The displacement of an exception vector is added to the value in this register to access the vector table. The lower 20 bits of the VBR are not implemented by ColdFire processors; they are zero, forcing the table to be aligned on a 1MByte boundary. If you want to change VBR register value, you just can modify upper 12 bits of the VBR. In CodeWarrior for ColdFire IDE tool this can be done by modifying the VBR register value at linker config file (*.lcf) in project, Usually the base is set in the processor RAM memory where the vector table is copied from flash.

You can use the code generated by CodeWarrior to perform the RAM vector table initialization:

/********************************************************************
 * MCF5xxx ASM utility functions
 */
asm void mcf5xxx_wr_vbr(unsigned long) { /* Set VBR */

     move.l     4(SP),D0
    movec d0,VBR 
     nop
     rts     
}     

/********************************************************************
 * MCF5xxx startup copy functions:
 *
 * Set VBR and performs RAM vector table initializatiom.
 * The following symbol should be defined in the lcf:
 * __VECTOR_RAM
 *
 * _vect is the start of the exception table in the code
 * In case _vect address is different from __VECTOR_RAM,
 * the vector table is copied from _vect to __VECTOR_RAM.
 * In any case VBR is set to __VECTOR_RAM.
 */ 
void initialize_exceptions(void)
{
     /*
      * Memory map definitions from linker command files used by mcf5xxx_startup
      */

     register uint32 n;
    
     /* 
     * Copy the vector table to RAM 
     */
     if (__VECTOR_RAM != (unsigned long*)_vect)
     {
          for (n = 0; n < 256; n++)
               __VECTOR_RAM[n] = (unsigned long)_vect[n];
     }
     mcf5xxx_wr_vbr((unsigned long)__VECTOR_RAM);
}


Hope it helps!

Best Regards,
Carlos Mendoza
Technical Support Engineer

0 Kudos