I am facing problem when programming 89c51 using assembly language.According to following code controller counts only 4.please help me to correct the code when both the pins (P1.0 and P1.1)are high then pin (P1.7)should be high to count.
ORG 0 IA EQU P2.0 IB EQU P2.1 IC EQU P2.2 ID EQU P2.3 IN_1 EQU P1.0 IN_2 EQU P1.1 OUT EQU P1.7 MOV R0,#0 MOV P0,R0 MOV P1,R0 MOV P2,R0 MOV P3,R0 CLR A AGAIN:JNB IN_1,AGAIN JNB IN_2,AGAIN SETB OUT INC A CJNE A,#1,N1 MOV P2,#00000001B ;1 CLR OUT SJMP AGAIN N1:CJNE A,#2,N2 MOV P2,#00000010B ;2 CLR OUT SJMP AGAIN N2:CJNE A,#3,N3 MOV P2,#00000010B ;3 CLR OUT SJMP AGAIN N3:CJNE A,#4,AGAIN MOV P2,#00000100B ;4 CLR OUT SJMP AGAIN N4:CJNE A,#4,N5 MOV P2,#00000101B ;5 CLR OUT SJMP AGAIN N5:CJNE A,#5,N6 MOV P2,#00000110B ;6 CLR OUT SJMP AGAIN N6:CJNE A,#6,N7 MOV P2,#00000111B ;7 CLR OUT SJMP AGAIN N7:CJNE A,#7,N8 MOV P2,#00001000B ;8 CLR OUT SJMP AGAIN N8:CJNE A,#8,N9 MOV P2,#00001001B ;9 CLR OUT SJMP AGAIN N9:CJNE A,#9,AGAIN MOV P2,#00000000B ;0 CLR OUT SJMP AGAIN END
you are supposed to read through your own code and try to understand it. which would be easier with labels less cryptic and a few comments would not hurt