bit value accessed by variable indexing.

Post your requests and ideas on the future development of mikroPascal.
Post Reply
Author
Message
Sparky1039
Posts: 1179
Joined: 24 Nov 2005 20:07
Location: Colorado, USA

bit value accessed by variable indexing.

#1 Post by Sparky1039 » 27 Nov 2005 00:33

What I would like to see implemented is the ability to access each bit of a variable sequentially by using another variable.
Currently MikroC allows the user to access each bit singularly by the construct

“variable_X = data_variable_Y.F0…F8” with “F0,F1…F7” being the bit location identifiers.

This is useful if the objective is to only look at a single bit, but it would be nice to be able to index through the whole byte or word sequentially in a loop by applying a variable in the numerical location of the ‘F0…F8’ bit identifier. Construct example:

“data_variable_X = data_variable_Y.F[n]” where “n” is a incrementing or decrementing index value.

So to apply this idea to some sample code: Build a routine that outputs a serial bit stream on PORTB.F0 (RB0) by indexing through the ‘data_variable’ contents from LSB to MSB, The indexing is done by the ‘n’ counter value. Bit time is 100 uS.

#define TX_Pin PORTB.F0

for (n=0; n<0x08; N++);
{
TX_Pin = data_variable.F[n]
Delay_uS(100);
}

This would allow the user to build very simple and compact routines for performing serial shift out functions. Conversely, the same approach could be applied to shifting in a bit sequentially by the same process.

Possible ?

Sparky1039
Posts: 1179
Joined: 24 Nov 2005 20:07
Location: Colorado, USA

#2 Post by Sparky1039 » 27 Nov 2005 00:34

Sorry this was meant for the MikroC users forum.
Probably would be useful for the Pascal users too...

Post Reply

Return to “mikroPascal Wish List”