Helmut Stettmaier

Setting CPUCR and Near Addressing Mode

Discussion created by Helmut Stettmaier on Dec 31, 2008
Latest reply on Jan 3, 2009 by kef
Hello,
currently I'm working to become familiar with the CodeWarrior 6.2 C-compiler and linker for the ColdFire V1 (what I got with the BadgeBoard). There arose some questions... Can please anybody help?

I want to set the CPUCR register and used the instruction "movec d0,CPUCR" ("movec d0,0x802" ended up in an "illegal addressing mode" and an "illegal use of asm inline function" error message).
This instruction "movec d0,CPUCR" is displayed in the simulator assembly window as "DC.W 0x4E7B; Invalid opcode" and causes in an illegal instruction interrupt.
What went wrong? I could not find out how to write the CPUCR register. How can I write new contents into the CPUCR register?

Near data addressing mode:
CF-V1's RAM is small enough such that it could be addresed entirely in near addresing mode an I want to take advantage of this. Therefore I chose in the project settings / ColdFire Processor / Data Model the selection "Near (16 bit)". But all standard accesses (data not explicitely declared as "near") are still accessed in far mode.

I tried to understand the role of A5, the base address register for near accesses.
Its value, the address _SDA_BASE, seems quite arbitrary, just behind the sections with the data to be predefined (are these data not near addressable?) if you look at a sample or default linker control script. Additionally _SDA_BASE is defined *before* alignment to a long word boundary.
All this made me think, the value of A5, the symbolic address _SDA_BASE, may in fact be defined arbitrarily, just in the RAM area and before the 'near' data. So I tried out to define _SDA_BASE to the beginning of the RAM, 0xFF8000; without any other change a variable attributed 'near' was appearingly addressed correctly.
The help texts do not contain anything about _SDA_BASE or a general hint how the compiler treats near addresses. Or have I overseen it?
Possibly, I guess, any short address is translated to (<variables address>-_SDA_BASE) by the compiler and the linker computes the correct address as long as _SDA_BASE has a compatible definition. If this is true it should be documented...
Is this correct? Can anybody confirm or reject this or give me hints where to find more information or even a tutorial?

I whish you all a happy new year!
Thank you in advance and kind regards,
Helmut

Outcomes