I have made some changes to my code and am understanding why it was doing what it was doing. I am trying to use the examples from the PICBASIC compiler hand book page 47 to write my code. I am trying to use the first four pins on PortA and PortC to control two motors through an H bridge using port B pins 4,5 for motor 1 and 6,7 for motor 2. The example code says:

Loop: Peek PortA,B0 'get current portA pin states to variable B0
If bit0=1 then zerohigh
If bit1=0 then onelow
goto loop

zerohigh: high 0
gotoloop
onelow: low 1
goto loop
end


So this is why in my code I was using bits. According to the Pg 20 of this manual that came with my basic compilier it says that the first tow bytes , B0 and B1 may also be used as bit variables. Bit0...Bit7 for B0 and bit8...bit15 for B1. So this is why I had the use of bit8 in my orginal code. But may be there is a better way to do this and if so I would like to know. Here is my revised code.

symbol cmcon=$1f
poke cmcon,7
symbol adcon0=$9f
poke adcon0,7
symbol adcon1=$9f
poke adcon1,7

start:
peek 5, B0
if bit0=0 then A
if bit0=1 then D

peek 7, B1
if bit8=0 then B
if bit8=1 then C
goto start


A: low 6: high 7: Return
B: low 4: high 5: Return
C: low 7: Return
D: low 5 Return

Please tell me how I can fix my code It still seems like peek and poke arent working right for me.

Thanks for you Help.