Thanks Alan,
Just got back from having some non-robotics fun.  
The difficulty with cleaning up this code is It may end up smaller but harder to read. For example if I take the TimerZ1 handler that handles the 4 timer counter match interrupts. It currently looks like:
[code]extern “C” void TIMERZ1() attribute ((interrupt_handler));
extern “C” void TIMERZ1()
{
DSERVOTOGGLE(40);		// BUGBUG:: For debug servo stuff.
if (TZ1.TSR.BIT.IMFA && TZ1.TIER.BIT.IMIEA) {
	DSERVOTOGGLE(41);		// BUGBUG:: For debug servo stuff.
	TZ1.GRA = 0xffff;			// should trigger and do its processing before overflow happens.
	TZ1.TIORA.BIT.IOA = 0x001;	// Will set to zero when timer happens
	TZ1.TIER.BIT.IMIEA = 0;		// don't need interrupt here
	TZ1.TSR.BIT.IMFA = 0;
}	
if (TZ1.TSR.BIT.IMFB && TZ1.TIER.BIT.IMIEB) {
	DSERVOTOGGLE(41);		// BUGBUG:: For debug servo stuff.
	TZ1.GRB = 0xffff;			// should trigger and do its processing before overflow happens.
	TZ1.TIORA.BIT.IOB = 0x001;	// Will set to zero when timer happens
	TZ1.TIER.BIT.IMIEB = 0;		// don't need interrupt here
	TZ1.TSR.BIT.IMFB = 0;
}	
… similar code repeated for IMIEC and IMIED… except also TIORA goes to TIORC (4 bits each…)
[/code]
Disregard the DSERVOTOGGLE.  When compiled for debug it toggles the IO line when compiled for non-debug it does nothing…
I could probably write this something like this:
[code]extern “C” void TIMERZ1() attribute ((interrupt_handler));
extern “C” void TIMERZ1()
{
DSERVOTOGGLE(40);		// BUGBUG:: For debug servo stuff.
int i;
for (i=0; i < 4; i++) {
if ((TZ1.TSR.BYTE & (1<<i)) && (TZ1.TIER.BYTE & (1<<i))) {
(((u16)&(TZ1.GRA))+i) = 0xffff;	// How to treat GRA-GRD like an array
		// How to handle TIORA/TIORC???  
		if (i < 2)
			TZ1.TIORA.BYTE = (TZ1.TIORA.BYTE & (0xf0 >> (i*4))) | (1 << (i*4));
		else
			TZ1.TIORC.BYTE = (TZ1.TIORC.BYTE & (0xf0 >> ((i&1)*4))) | (1 << ((i&1)*4));
		TZ1.TIER.BYTE &= ~(1<<i);
		TZ1.TSR.BYTE &= ~(1<<i);
	}
}
}
[/code]
Note: I just typed in the code above, have not compiled it or the like.  It would probably generate smaller code, but it would be slower and I personally don’t think it is overly readable…  Not sure what I am going to do yet…
Kurt
								
							
  To test the servos for a Bap28, I will probably try this for a Brat.