PDA

View Full Version : Window variable modifier



philipad23
01-29-2006, 12:21 PM
HI all!,

I am trying to get as a variable the first 3 nibbles of a word but i dont know how to write the variable modifier.

I get the last nibbles like this:

a VAR word
b VAR a.LOWNIB

but how I get the other three?

I thought it was

a VAR word
b VAR a.LOWNIB
c VAR c.NIB1...3ииииии but this dont seem to work

anyone can help me?.....

и

Jon Williams
01-29-2006, 12:31 PM
You betcha... give these a try: myWord.NIB3 (highest nib), myWord.NIB2, myWord.NIB1, myWord.NIB0 (lowest nib).и If you need to use another variable to select one of the nibbles you can use the LOWNIB modifier like this: myWord.LOWNIB(idx) -- where idx is 0 (lowest nib) through 3 (highest).


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

philipad23
01-29-2006, 12:38 PM
so is not possible to read together the first 12 bits of a 16-bit variable?

Jon Williams
01-29-2006, 12:52 PM
If you want to isolate the lower 12 bits of a word you must do this:

и bVar = aVar & $0FFF

There is no 12-bit variable type, so bVar must be a Word as well.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

philipad23
01-29-2006, 01:01 PM
it will not work because masking will change the number when isolating to get the higher 12-bits. Maybe I will try to get the 3 nibbles separately and try to reconsctruct the 12-bit number

Thanks anyway!

Jon Williams
01-29-2006, 01:06 PM
In the example I gave you, bVar will end up being the lower 12 bits of aVar -- and aVar is not modified.и Now, if you want bVar to be set to the value of the upper 12 bits of aVar, do it like this:

и bVar = aVar >> 4

Again, aVar is not modified by this process.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

philipad23
01-29-2006, 01:13 PM
that works great!
thanks