[Coco] gcc-coco revisited

KnudsenMJ at aol.com KnudsenMJ at aol.com
Fri Oct 31 21:52:24 EST 2003


In a message dated 10/31/03 11:28:20 AM Eastern Standard Time, 
james at skwirl.ca writes:

> I'm somewhat clueless on this "direct" parameter.  Is it a directive to
>  the compiler to tell it to use the DP register as much as possible?

Actually all the "direct" storage class tag (applied to a global variable 
declaration) does to the output code, is to use absolute DP register addressing, 
meaning only the low 8 bits of address are included.

It also flags such vars to the linker, so it will (try to) put them all into 
the first 256 bytes of data memory.  If you were greedy and they don't all 
fit, you got big trouble, but no warning.  But the speed and code size advantages 
are tremendous.

Microware C assumes that the DP register is always zero.  I'm sure that some 
programmers have set DP to other offsets for short bursts of intensive 
crunching, but in the famous series of BYTE articles on the 6809's design, the 
architects expounded a philosophy that DP should not be used as a free-for-all 
segment register, "deprecated" changing its value, and bragged about how slow it 
was to reload DP with the TFR instruction (which takes about 4 clocks longer 
than it should).

Incidentally, in assembler you can force full absolute addressing on a direct 
var with 
">address", and force DP with "<xxx".  There's no way in C to force absolute 
on a direct var, except on a per-file basis, you can leave off the "direct" 
modifier in that global var's declaration.  --Mike K.



More information about the Coco mailing list