Shifting and Testing Variables

<< Click to Display Table of Contents >>

Navigation:  ETEC 'C' Compiler Information >

Shifting and Testing Variables

Previous pageReturn to chapter overviewNext page

Sometimes a single bit flag or value is stored in the LSB of a variable. This can be quickly and easily testing by using the C flag in the condition code register (CC).

(i >>=1,CC.C == 1)? SetFlag0():ClrFlag0();

You can also do things like

if (CC.C == 1) { . . . };

Generated code should look something like:

022C 9FEFFB04 ram p23_0 = 0011.

0230 97F87A04 alu p = p >>1 ,ccs;

              ram 0011 = p23_0.

0234 F080121F if c==0 jump 0240,flush.

0238 FFF9FCF9 Set flag0.

023C F7C0123F jump 0244,flush.

0240 FFF8FCF9 Clear flag0.

If using this capability, take care that the previous code includes the arithmetic operation of interest that sets the C flag as desired.  Note also that all the other condition code flags can be tested via the CC "structure".