Highnib - lownib problem
Hello Stampers,
It's been a while.......
My problem:
I define variables:
reg var byte(10) 'define a 10 byte array called reg
red var nib 'define a 4 bit variable
green var nib 'define anothet 4 bit variable
I want to fill the first byte of the array so that the four MSB's contains
"red" and the four LSB's contains "green"
reg(0).highnib = red
reg(0).lownib = green
After tokenizing I get an error on the reg(0).highnib line
expected "=" instead of the "."
Sombody knows the problem....?
Thanx
Michel De Meester
Met vriendelijke groetjes,
> ************************************************
> Michel De Meester
> Biotechnisch Onderhoud
> Universitair Ziekenhuis Antwerpen
> Wilrijkstraat 10
> 2650 Edegem - B
> tel: ++32 (0)3 821 36 47
> e-mail: michel.de.meester@u...
>
> *************************************************
>
>
It's been a while.......
My problem:
I define variables:
reg var byte(10) 'define a 10 byte array called reg
red var nib 'define a 4 bit variable
green var nib 'define anothet 4 bit variable
I want to fill the first byte of the array so that the four MSB's contains
"red" and the four LSB's contains "green"
reg(0).highnib = red
reg(0).lownib = green
After tokenizing I get an error on the reg(0).highnib line
expected "=" instead of the "."
Sombody knows the problem....?
Thanx
Michel De Meester
Met vriendelijke groetjes,
> ************************************************
> Michel De Meester
> Biotechnisch Onderhoud
> Universitair Ziekenhuis Antwerpen
> Wilrijkstraat 10
> 2650 Edegem - B
> tel: ++32 (0)3 821 36 47
> e-mail: michel.de.meester@u...
>
> *************************************************
>
>
Comments
>Hello Stampers,
>
>It's been a while.......
>
>My problem:
>
>I define variables:
>
>reg var byte(10) 'define a 10 byte array called reg
>red var nib 'define a 4 bit variable
>green var nib 'define anothet 4 bit variable
>
>I want to fill the first byte of the array so that the four MSB's contains
>"red" and the four LSB's contains "green"
>
>reg(0).highnib = red
>reg(0).lownib = green
>
>After tokenizing I get an error on the reg(0).highnib line
>
>expected "=" instead of the "."
>
>
>Sombody knows the problem....?
Try this:
reg.HIGHNIB(0) = red
reg.LOWNIB(0) = green
>Thanx
>
>Michel De Meester
>
>
>
>
>
>Met vriendelijke groetjes,
>
>> ************************************************
>> Michel De Meester
>> Biotechnisch Onderhoud
>> Universitair Ziekenhuis Antwerpen
>> Wilrijkstraat 10
>> 2650 Edegem - B
>> tel: ++32 (0)3 821 36 47
>> e-mail: michel.de.meester@u...
>>
>> *************************************************
>>
>>
>
>
>To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
>from the same email address that you subscribed. Text in the Subject and Body
of the message will be ignored.
>
>Yahoo! Groups Links
>
>
>
>
reg(0).highnib = red
reg(0).lownib = green
> Try this:
>
> reg.HIGHNIB(0) = red
> reg.LOWNIB(0) = green
Indead, I overlooked this in the manual.
After reading page 54 and 55 I think it should be:
reg.HIGHNIB(0) = red
reg.LOWNIB(1) = green
because the variable is addressed as nibble.
So, if I want to fill the 10 byte array with nibbles I need to use
indexes from 0 to 19 (assuming all the "color" variables are nibbles)
'byte0
reg.HIGHNIB(0) = red
reg.LOWNIB(1) = green
'byte1
reg.HIGHNIB(2) = purple
reg.LOWNIB(3) = orange
....
'byte9
reg.HIGHNIB(18) = any color
reg.LOWNIB(19) = any color
Am I right?
Thanks
Michel De Meester
your case you could do this:
reg(0) = (red << 4) + green
-- Jon Williams
-- Applications Engineer, Parallax
-- Dallas Office
Original Message
From: De Meester, Michel [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=tB5Huzyq3kSDl9HzTkTt6jBJYiNvx09pZ22YpWAmGVfRWBrDAiYRImWYH4eF8j2QE-i9TjY1Nk4FSaFaZEqjt99q0HAdob0A]Michel.De.Meester@u...[/url
Sent: Wednesday, April 14, 2004 5:47 AM
To: 'basicstamps@yahoogroups.com'
Subject: [noparse][[/noparse]basicstamps] Highnib - lownib problem
Hello Stampers,
It's been a while.......
My problem:
I define variables:
reg var byte(10) 'define a 10 byte array called reg
red var nib 'define a 4 bit variable
green var nib 'define anothet 4 bit variable
I want to fill the first byte of the array so that the four MSB's
contains "red" and the four LSB's contains "green"
reg(0).highnib = red
reg(0).lownib = green
After tokenizing I get an error on the reg(0).highnib line
expected "=" instead of the "."
Sombody knows the problem....?
Thanx
Michel De Meester
>reg.HIGHNIB(0) = red
>reg.LOWNIB(1) = green
both of those address the same nib. The first one is an offset zero
from HIGHNIB, which is the same as HIGHNIB. The second one is an
offset one above LOWNIB, which too is HIGHNIB.
If you want to address this as an array of nibbles, use either the
one Bruce suggested:
reg.LOWNIB(0) = green ' offset zero from LOWNIB
reg.HIGHNIB(0) = red ' offset zero from HIGHNIB
or this alternative:
reg.LOWNIB(0) = red ' offset zero from LOWNIB
reg.LOWNIB(1) = green ' offset one from LOWNIB
for all of them:
FOR idx=0 to 18 STEP 2
reg.LOWNIB(idx) = red ' offset idx from LOWNIB
reg.HIGHNIB(idx) = green ' offset idx from HIGHNIB
NEXT
-- Tracy
>Hello Bruce,
>
>reg(0).highnib = red
>reg(0).lownib = green
>
>> Try this:
>>
>> reg.HIGHNIB(0) = red
>> reg.LOWNIB(0) = green
>
>Indead, I overlooked this in the manual.
>
>After reading page 54 and 55 I think it should be:
>
>reg.HIGHNIB(0) = red
>reg.LOWNIB(1) = green
>
>because the variable is addressed as nibble.
>
>So, if I want to fill the 10 byte array with nibbles I need to use
>indexes from 0 to 19 (assuming all the "color" variables are nibbles)
>
>'byte0
>reg.HIGHNIB(0) = red
>reg.LOWNIB(1) = green
>
>'byte1
>reg.HIGHNIB(2) = purple
>reg.LOWNIB(3) = orange
>
>....
>
>'byte9
>reg.HIGHNIB(18) = any color
>reg.LOWNIB(19) = any color
>
>Am I right?
>
>Thanks
>
>Michel De Meester