51单片机6位计数器汇编程序
扫描二维码
随时随地手机看文章
1602液晶6位计数器
RSEQUP2.0
RWEQUP2.1
EEQUP2.2
org00h
a_bitequ30h;个位数存放处
b_bitequ31h;十位数存放处
c_bitequ32h;百位数存放处
d_bitequ33h;千位数存放处
e_bitequ34h;万位数存放处
f_bitequ35h;十万位数存放处
MOVa,#30h;30H的ASCIC码为0
MOVa_bit,a
MOVb_bit,a
MOVc_bit,a
MOVd_bit,a
MOVe_bit,a
MOVf_bit,a
org0030h
MOVP0,#00000001B;清屏
ACALLENABLE
MOVP0,#00111000B;显示功能
ACALLENABLE
MOVP0,#00001100B;显示开关控制
ACALLENABLE
MOVP0,#06H;输入模式
ACALLENABLE
MOVp0,#80H;第一行的开始位置
cALLENABLE
MOVP0,#00000001B;清屏
ACALLENABLE
MOVDPTR,#TABLE1;显示PASSWORD
CALLWRITE1;到TABLE1取码?
stlop:acalldisplay;显示
inca_bit;加1
MOVa,a_bit
cjnea,#3AH,stlop;如果A的值到3AH那么继续否则重新
MOVa_bit,#30h;显示数送30H(就是显示0)
incb_bit
MOVa,b_bit
cjnea,#3AH,stlop
MOVb_bit,#30h
incc_bit
MOVa,c_bit
cjnea,#3AH,stlop
MOVc_bit,#30h
incd_bit
MOVa,d_bit
cjnea,#3AH,stlop
MOVd_bit,#30h
ince_bit
MOVa,e_bit
cjnea,#3AH,stlop
MOVe_bit,#30h
incf_bit
MOVa,f_bit
cjnea,#3AH,stlop
MOVf_bit,#30h
ajmpstlop
display:;显示子程序
MOVP0,#0C9H
ACALLENABLE
MOVA,A_BIT
ACALLWRILTE2
MOVP0,#0C8H;显示的位置
ACALLENABLE
MOVA,B_BIT;显示10位数
ACALLWRILTE2;显示
MOVP0,#0C7H;数据存贮器地址
ACALLENABLE
MOVA,C_BIT
ACALLWRILTE2
MOVP0,#0C6H;数据存贮器地址
ACALLENABLE
MOVA,D_BIT
ACALLWRILTE2
MOVP0,#0C5H;数据存贮器地址
ACALLENABLE
MOVA,E_BIT
ACALLWRILTE2
MOVP0,#0C4H;数据存贮器地址
ACALLENABLE
MOVA,F_BIT
ACALLWRILTE2
;1MS延时(按12MHz算)
;====================================================
D1MS:MOVR7,#2
DJNZR7,$
RET
WRILTE2:MOVp0,A;显示
SETBRS
CLRRW
CLRE
CALLDELAY
CALLDELAY3
SETBE
RET
WRITE1:MOVR1,#00H;显示table中的值
A1:MOVA,R1;到table取码
MOVCA,@A+DPTR
callWRILTE2;显示到LCD
INCR1
CJNEA,#00H,A1;是否到00h
RET
ENABLE:CLRRS;送命令
CLRRW
CLRE
ACALLDELAY
SETBE
RET
DELAY:MOVP0,#0FFH
CLRRS
SETBRW
CLRE
NOP
SETBE
JBP0.7,DELAY;判断忙标志
RET
DELAY3:;延时程序
MOVR7,#255
D1:MOVR6,#25
D2:DJNZR6,D2
DJNZR7,D1
RET
table1:db"1602JISHUQI",00H
end