ChipCenter Questlink
SEARCH CHIPCENTER
Search Type:
Search for:




Knowledge Centers
Product Reviews
Data Sheets
Guides & Experts
News
International
Ask Us
Circuit Cellar Online
App Notes
NetSeminars
Careers
Resources
FAQ
EE Times Network
Electronics Group Sites

The SHARC in the C


Circuit Cellar Online
THE MAGAZINE FOR COMPUTER APPLICATIONS
Circuit Cellar Online offers articles illustrating creative solutions
and unique applications through complete projects, practical
tutorials, and useful design techniques.

THE SHARC IN THE C

Lessons from the Trenches by Michael Smith

Start ý Register Comparison ý Memory Access ý Modify and Volatile Registers ý Length and Base Registers ý Hardware and Software ý Interrupt Handling ý Sources and PDF

MODIFY AND VOLATILE REGISTERS

The 21K modify registers (M0ýM7 and M8ýM15) can be used in conjunction with the index registers to access elements in an array. This is equivalent to using a 68K data register in conjunction with an address register. Access to the 32-bit array element data[3] will be programmed on the two processors as follows:

MOVE.L #data, A0 (68K)
MOVE.L #(4ý3), D0
MOVE.L (A0, D0), D1
Offset scale to 12 bytes
I4 = data; (21K)
M4 = 3;
R1 = dm(M4, I4)

Note that the offset of element data[3] from the start of the array data is 12 bytes on the 68K, but three words on the 21K. Youýll have to get deep into the 21K User Manual to discover the advantages of having three 21K words, 12 bytes long under some circumstances and 16 bytes long under others.

These simple code sequences also indicate the differences in the coding conventions adopted for volatile register usage in the two development environments. When program flow requires a subroutine call, it is important that key values remain undisturbed in registers for reuse when the subroutine exits. Volatile registers can be used in a subroutine without saving every register to slow memory.

With the SDS 68K compiler, there are two volatile data registers (D0 and D1) defined, and the 21K registers (R0 and R1) have a similar usage. However, there are four additional SHARC volatile data registersýR2, R4, R8, and R12. This strange choice is not arbitrary, but it meets the requirement to have volatile registers available to use with the 21K super-scalar operations.

Both 68K and 21K coding conventions allow for two volatile address registers. However, while the 68K volatile address registers are the obvious A0 and A1, the 21K equivalent index registers are I4 and I12. This choice matches the need to access both program and data memory. The volatile 21K data registers (unlike the volatile 68K data registers) canýt be used in conjunction with the index registers to step through an array. Specific volatile 21K modify registers (M4 and M12) are needed for this purpose.

Note that there are both PREMODIFY and POSTMODIFY memory accessing modes on the 21K.

M4 = 4;
R1 = dm(M4, I4); PREMODIFY
R2 = dm(I4, M4); POSTMODIFY

The value at memory location I4 + M4 is fetched during the premodify operation, with index register I4 left unchanged. In the postmodify operation, the memory at location I4 is fetched, and then the index register is autoincremented so that I4 = I4 + M4. The postmodify operation can be described in a few bits, which allows parallel postmodify operations to be described in a single opcode to program and data memory.

PREVIOUSNEXT


Circuit Cellar provides up-to-date information for engineers. Visit www.circuitcellar.com for more information and additional articles.
For subscription information, call (860) 875-2199, subscribe@circuitcellar.com or subscribe online. ýCircuit Cellar, the Magazine for Computer Applications. Posted with permission.
Click here to get your listing up.

Copyright © 2003 ChipCenter-QuestLink
About ChipCenter-Questlink  Contact Us  Privacy Statement   Advertising Information  FAQ