bitwise logic/arithmetic problem

moorea21

Senior Member
This isnt strictly a picaxe problem, but more of a logic one I think:-
I'm trying to find a relationship between the following 2 columns of data:

10000000 8
1000000 7
100000 6
10000 5
1000 4
100 3
10 2
1 1

The only one I can come up with is 'counting from the lsb of the 1st number, the position of the '1' is the number in the second column.'

I'm hoping there is some arithmetic/logical relationship, as It would be very handy to use in a calculation. I'm sure there is, but I can't think of it.

Is there one? How would I take the number decimal 8 and arrive at binary 10000000 (decimal 128)?
 

lbenson

Senior Member
... please ignore ...
Glad you worked it out, and sorry to ignore your request to ignore, but two points which may help others who find this thread.

It's clearer if the leading zeros are shown:
10000000 8
01000000 7
00100000 6
00010000 5
00001000 4
00000100 3
00000010 2
00000001 1

And if you're using an X2, check out the NCD and DCD commands.
 

hippy

Technical Support
Staff member
I'm trying to find a relationship between the following 2 columns of data:
The relationship is -

leftColumn = 2RightColumn-1

How would I take the number decimal 8 and arrive at binary 10000000 (decimal 128)?
b1 = 8
b2 = 1 << b1 >> 1

b1 = 8
b2 = DCD b1 >> 1

b1 = 8
LookUp b1, ( 0, 1, 2, 4, 8, 16, 32, 64, 128 ), b2

Data 0, ( 0, 1, 2, 4, 8, 16, 32, 64, 128 )
b1 = 8
Read b1, b2

Table 0, ( 0, 1, 2, 4, 8, 16, 32, 64, 128 )
b1 = 8
ReadTable b1, b2
 
Top