NDC has a range of 1-16 but gives a result of 0 if no bit is set. So you can say it has 17 possible results (0-16)
NDC %00000000 equals 0
NDC %00000001 equals 1
NDC %00000010 equals 2
NDC %00000100 equals 3
to
NDC %1000000000000000 equals 16
NDC %1111111111111111 also equals 16 because NDC is only checking the highest bit set.
DCD is a bit different it has (0-15) as range
DCD 0 would give %00000001
DCD 1 would give %00000010
DCD 2 would give %00000100
So you see in DCD you use a BIT reference number and PBP mostly counts bits from 0-7 if it is a byte and 0-15 if it is a word.
So the easy answer to your question is that NDC and DCD are not symetrical because they are not the reverse function of each other.
BUT....
IF you want you can do like this and get a better result.
Just remember you will "loose" the highest bit but if you use this to set a port it is no problem as long as you do the shifting in a Word size variable.
Temp Var Word
A var Byte
Temp= DCD 0 'Temp=%0000000000000001
Temp=Temp>>1 'Temp=%0000000000000000
A=NDC Temp 'A equals 0
Temp=DCD 15 'Temp=%1000000000000000
Temp=Temp>>1 ''Temp=%0100000000000000
A=NDC Temp 'A equals 15
Bookmarks