[Ktechlab-devel] Confusing bitwise behaviour (novice)

P Zoltan zoltan.padrah at gmail.com
Sun Sep 20 17:31:54 UTC 2009


On Wed, 16 Sep 2009 16:56:55 +0200, Matthew Ayres
<solar.granulation at gmail.com> wrote:

> Hello again
>
> Using flowcode I'm performing a right-rotation on variable x on a P16F84.
> Port A TRIS is 00011111 and port B TRIS is 00000000.  x is set to 1  
> before
> the initial rotation.
>
> I have the chip's out pins hooked up to LEDs in a circuit in ktechlab.   
> I'm
> writing x to port B, the value of which is thus displayed on the LEDs.
>
> Slipping into binary for a moment, one step after displaying 4, pins go  
> high
> for a value of 130 or, back in binary, 1000 0010.  That is to say that  
> pins
> RB1 and RB7 are high while the others are low.
>

  How looks the code exactly? And in what is it written (C, ASM, flowcode)?

  I can think to some intruction "shift right with carry", which takes the  
value from the carry bit and places it in the  most significant bit of the  
register.


> To me, this seems to indicate that the variable is being stored in more  
> than
> 8 bits and that one of these unexpected bits is initially 1.  In short,  
> I'm
> confused as all get out!
>
> -Matthew




More information about the Ktechlab-devel mailing list