org 00h
rs equ p1.0
rw equ p1.1
en equ p1.2
lcd equ p0
acall initialize
mov r0,#00d
mov r1,#00d
mov r2,#00d
mov r3,#00d
mov r4,#00d
mov r5,#00d
setb p2.0                               ; switch has been connected
setb p2.1
setb p2.2
check: jnb p2.0,s1                              ;condition checking
jnb p2.1,s2
jnb p2.2,s3                            ;condition
sjmp check

s1: mov dptr,#300h
clr a
inc r0
mov a,r0
mov b,#10
div ab
mov a,b
cjne a,#00,go
inc r3
mov a,r3
movc a,@a+dptr
mov lcd,#82h
acall cmd
mov lcd,'0'
acall disp
acall delay
mov lcd,#81h
acall cmd
mov lcd,a
acall disp
sjmp check
go: movc a,@a+dptr
mov lcd,#82h
acall cmd
mov lcd,a
acall disp
sjmp check


s2: mov dptr,#300h
clr a
inc r1
mov a,r1
mov b,#10
div ab
mov a,b
cjne a,#00,go1
inc r4
mov a,r4
movc a,@a+dptr
mov lcd,#85h
acall cmd
mov lcd,'0'
acall disp
acall delay
mov lcd,#84h
acall cmd
mov lcd,a
acall disp
sjmp check
go1: movc a,@a+dptr
mov lcd,#85h
acall cmd
mov lcd,a
acall disp
sjmp check

s3: mov dptr,#300h
clr a
inc r2
mov a,r2
mov b,#10
div ab
mov a,b
cjne a,#00,go2
inc r5
mov a,r5
movc a,@a+dptr
mov lcd,#88h
acall cmd
mov lcd,'0'
acall disp
acall delay
mov lcd,#87h
acall cmd
mov lcd,a
acall disp
ljmp check
go2: movc a,@a+dptr
mov lcd,#88h
acall cmd
mov lcd,a
acall disp
ljmp check









initialize: mov lcd,#38h
                                                acall cmd
                                                acall delay
                                                mov lcd,#06h
                                                acall cmd
                                                acall delay
                                                mov lcd,#01h
                                                acall cmd
                                                acall delay
                                                mov lcd,#0ch
                                                acall cmd
                                                acall delay
                                                mov lcd,#81h
                                                acall cmd
                                                acall delay
                                                mov lcd,#'0'
                                                acall disp
                                                acall delay
                                                mov lcd,#82h
                                                acall cmd
                                                acall delay
                                                mov lcd,#'0'
                                                acall disp
                                                acall delay
                                                mov lcd,#84h
                                                acall cmd
                                                acall delay
                                                mov lcd,#'0'
                                                acall disp
                                                acall delay
                                                mov lcd,#85h
                                                acall cmd
                                                acall delay
                                                mov lcd,#'0'
                                                acall disp
                                                acall delay
                                                mov lcd,#87h
                                                acall cmd
                                                acall delay
                                                mov lcd,#'0'
                                                acall disp
                                                acall delay
                                                mov lcd,#88h
                                                acall cmd
                                                acall delay
                                                mov lcd,#'0'
                                                acall disp
                                                acall delay
                                                ret

delay: mov r6,#0f1h
abn2: mov r7,#0ffh
abn: djnz r7,abn
djnz r6,abn2
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

org 300h
db '0123456789'

Leave a Reply

Subscribe to Posts | Subscribe to Comments

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