org 00h
rs equ p1.0
rw equ p1.1
en equ p1.2
lcd equ p0
MOV LCD,#38H
ACALL CMD
ACALL DELAY
MOV LCD,#06H
ACALL CMD
ACALL DELAY
MOV LCD,#01H
ACALL CMD
ACALL DELAY
MOV LCD,#0EH
ACALL CMD
ACALL DELAY
MOV LCD,#80H
ACALL CMD
ACALL DELAY
CLR A
MOV P2,#0FFH

MOV R0,#04
H2: ACALL KEYBOARD
DJNZ R0,H2
MOV A,R3
MOV B,#08
MUL AB
MOV R3,A

MOV A,R4
MOV B,#04
MUL AB
MOV R4,A

MOV A,R5
MOV B,#02
MUL AB
MOV R5,A

MOV A,R6
MOV B,#01
MUL AB
MOV R6,A

CLR A

ADD A,R3
ADD A,R4
ADD A,R5
ADD A,R6
MOV LCD,#'='
ACALL DISP
ACALL DELAY

MOV B,#10
DIV AB
MOV DPTR,#MSG
MOVC A,@A+DPTR
MOV LCD,A
ACALL DISP
ACALL DELAY
CLR A
MOV A,B
MOV DPTR,#MSG
MOVC A,@A+DPTR
MOV LCD,A
ACALL DISP
ACALL DELAY
ALT: SJMP ALT






KEYBOARD: MOV A,P2
CJNE A,#0FEH,S1
MOV A,#00
CJNE R0,#04,L1
MOV R3,A
L1: CJNE R0,#03,L2
MOV R4,A
L2: CJNE R0,#02,L3
MOV R5,A
L3: CJNE R0,#01,L4
MOV R6,A
L4: SJMP RAM

S1: CJNE A,#0FDH,KEYBOARD
MOV A,#01
CJNE R0,#04,M1
MOV R3,A
M1: CJNE R0,#03,M2
MOV R4,A
M2: CJNE R0,#02,M3
MOV R5,A
M3: CJNE R0,#01,RAM
MOV R6,A

RAM: MOV DPTR,#MSG
MOVC A,@A+DPTR
MOV LCD,A
ACALL DISP
ACALL DELAY
RET

CMD: CLR RS
     CLR RW
                 SETB EN
                 ACALL DELAY
                 CLR EN
                 RET

DISP: SETB RS
      CLR RW
                  SETB EN
                  ACALL DELAY
                  CLR EN
                  RET

DELAY: MOV R1,#0F0H
HERE2: MOV R2,#0FFH
HERE:  DJNZ R2,HERE
       DJNZ R1,HERE2
                   RET

MSG: DB '0','1','2','3','4','5','6','7','8','9'
END


If you have any problem then comment!!!!!!!!!!!!!!!!!!!!!!!!!

Leave a Reply

Subscribe to Posts | Subscribe to Comments

- Copyright © Microcontroller Projects -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -