switch A is connected to P0.1
switch B is connected to P0.2
LED is connected to P1.0
IF both switches high then the LED is turn on otherwise turn off
switch A high then turn off LED
switch B high then turn of LED
both A B high then turn on LED
both A B low then turn off led
I want to write assembly program using AND logic statement
How to write statement for AND logic for switches
ANL Is used by the Acc only... Sorry about that... A quick look at the datasheet says it can... But it can't.
This works... with bit test..
Code:
org 0000h ; Reset vector.
sjmp start ; Jump over vector space.
org 030h
start: ; This will be assembled at 0x30.
clr p2.0 ; Turn LED off
mov P0,#6 ; Inputs...
while:
jb p0.1, turnon ; Test switch 1.
jb p0.2, turnon ; Test switch 1.
clr p2.0 ; Turn LED on.
sjmp while ; Or go back to LABEL (while)
turnon:
setb p2.0 ; turn LED OFF.
sjmp while ; end while
end
This is with a ANL command
Code:
org 0000h ; Reset vector.
sjmp start ; Jump over vector space.
org 030h
start: ; This will be assembled at 0x30.
clr p2.0 ; Turn LED off
mov P0,#6 ; Inputs...
while:
mov A,P0 ; Copy switches to Acc
ANL A,#0x6 ; Test which are on / off
jnz turnoff ; both on.. if not zero
clr P2.0 ; one or more are off
sjmp while
turnoff:
setb p2.0 ; turn LED ON.
sjmp while ; end while
end