51单片机,用键盘输入数码管显示的程序!!!用汇编语言,大家帮忙看看哪里错了!谢谢了!!!
ORG0000HLJMPMAINORG0100HMAIN:MOVSP,#78HMOV78H,#00HMOV79H,#00HMOV7AH,#00HMOV7BH,#00HMO...
ORG 0000H
LJMP MAIN
ORG 0100H
MAIN:MOV SP,#78H
MOV 78H,#00H
MOV 79H,#00H
MOV 7AH,#00H
MOV 7BH,#00H
MOV 7CH,#00H
MOV 7DH,#00H
MOV 7EH,#00H
KEYI:ACALL KS1
CJNE A,#0F0H,LK1
ACALL DIR
AJMP KEYI
LK1:ACALL DIR
ACALL DIR
ACALL KS1
CJNE A, #0F0H,LK2
ACALL DIR
AJMP KEYI
LK2: ACALL KS1
MOV R2,A
ORL A,#0FH
MOV P3,A
MOV A,P3
ANL A,#0FH
ADD A,R2 ;键特征值
CJNE A,#0EEH,JZHI1
MOV A,#00H
PUSH 0E0H
JZHI1: CJNE A,#0DEH,JZHI2
MOV A,#01H
PUSH 0E0H
JZHI2: CJNE A,#0BEH, JZHI3
MOV A,#02H
PUSH 0E0H
JZHI3: CJNE A,#7EH,JZHI4
MOV A,#03H
PUSH 0E0H
JZHI4: CJNE A, #0EDH, JZHI5
MOV A,#04H
PUSH 0E0H
JZHI5: CJNE A,#0DDH, JZHI6
MOV A, #05H
PUSH 0E0H
JZHI6: CJNE A,#0BDH, JZHI7
MOV A, #06H
PUSH 0E0H
JZHI7: CJNE A,#07DH, JZHI8
MOV A, #07H
PUSH 0E0H
JZHI8: CJNE A,#0EBH, JZHI9
MOV A, #08H
PUSH 0E0H
JZHI9:CJNE A,#0DBH, KEYI
MOV A, #09H
PUSH 0E0H
LJMP KEYI
DIR:MOV DPTR,#DEG
MOV R0,#79H;数码管第一位
MOV R3,#0FEH;线选
LD1:CLR P2.7
CLR P2.6
MOV A,@R0
MOVC A,@A+DPTR
MOV P0,A
SETB P2.6
CLR P2.6
MOV P0,R3
SETB P2.7
LCALL DELY
INC R0
MOV A,R3
JNB ACC.5,LD2
RL A
MOV R3,A
SJMP LD1
LD2:RET
DEG:DB 3FH,06H,5BH,4FH,66H
DB 6DH,7DH,07H,7FH,6FH
DELY:MOV R7,#02H
DL:MOV R6,#0FFH
DL6:DJNZ R6,DL6
DJNZ R7,DL
RET
KS1:MOV P3,#0F0H
MOV A,P3
ANL A, #0F0H
RET ;键是否按下
END
为什么复位后显示“暗1暗100”是六位数码管,输入后六位数码管显示同一个数字。不能逐个显示数字,我用的是郭天祥的开发板。 展开
LJMP MAIN
ORG 0100H
MAIN:MOV SP,#78H
MOV 78H,#00H
MOV 79H,#00H
MOV 7AH,#00H
MOV 7BH,#00H
MOV 7CH,#00H
MOV 7DH,#00H
MOV 7EH,#00H
KEYI:ACALL KS1
CJNE A,#0F0H,LK1
ACALL DIR
AJMP KEYI
LK1:ACALL DIR
ACALL DIR
ACALL KS1
CJNE A, #0F0H,LK2
ACALL DIR
AJMP KEYI
LK2: ACALL KS1
MOV R2,A
ORL A,#0FH
MOV P3,A
MOV A,P3
ANL A,#0FH
ADD A,R2 ;键特征值
CJNE A,#0EEH,JZHI1
MOV A,#00H
PUSH 0E0H
JZHI1: CJNE A,#0DEH,JZHI2
MOV A,#01H
PUSH 0E0H
JZHI2: CJNE A,#0BEH, JZHI3
MOV A,#02H
PUSH 0E0H
JZHI3: CJNE A,#7EH,JZHI4
MOV A,#03H
PUSH 0E0H
JZHI4: CJNE A, #0EDH, JZHI5
MOV A,#04H
PUSH 0E0H
JZHI5: CJNE A,#0DDH, JZHI6
MOV A, #05H
PUSH 0E0H
JZHI6: CJNE A,#0BDH, JZHI7
MOV A, #06H
PUSH 0E0H
JZHI7: CJNE A,#07DH, JZHI8
MOV A, #07H
PUSH 0E0H
JZHI8: CJNE A,#0EBH, JZHI9
MOV A, #08H
PUSH 0E0H
JZHI9:CJNE A,#0DBH, KEYI
MOV A, #09H
PUSH 0E0H
LJMP KEYI
DIR:MOV DPTR,#DEG
MOV R0,#79H;数码管第一位
MOV R3,#0FEH;线选
LD1:CLR P2.7
CLR P2.6
MOV A,@R0
MOVC A,@A+DPTR
MOV P0,A
SETB P2.6
CLR P2.6
MOV P0,R3
SETB P2.7
LCALL DELY
INC R0
MOV A,R3
JNB ACC.5,LD2
RL A
MOV R3,A
SJMP LD1
LD2:RET
DEG:DB 3FH,06H,5BH,4FH,66H
DB 6DH,7DH,07H,7FH,6FH
DELY:MOV R7,#02H
DL:MOV R6,#0FFH
DL6:DJNZ R6,DL6
DJNZ R7,DL
RET
KS1:MOV P3,#0F0H
MOV A,P3
ANL A, #0F0H
RET ;键是否按下
END
为什么复位后显示“暗1暗100”是六位数码管,输入后六位数码管显示同一个数字。不能逐个显示数字,我用的是郭天祥的开发板。 展开
展开全部
ORG 0000H
LJMP MAIN
ORG 0100H
MAIN:
MOV SP,#78H
MOV 78H,#00H
MOV 79H,#00H
MOV 7AH,#00H
MOV 7BH,#00H
MOV 7CH,#00H
MOV 7DH,#00H
MOV 7EH,#00H
MOV R0,#79H
MOV R1,#0
KEYI:
ACALL KS1
CJNE A,#0F0H,LK1
ACALL DIR
AJMP KEYI
LK1:
ACALL DIR
ACALL KS1
CJNE A, #0F0H,LK2
ACALL DIR
AJMP KEYI
LK2:
ACALL KS1
MOV R2,A
ORL A,#0FH
MOV P3,A
MOV A,P3
ANL A,#0FH
ADD A,R2 ;键特征值
CJNE A,#0EEH,JZHI1
MOV A,#00H
PUSH ACC
SJMP JZH20
JZHI1:
CJNE A,#0DEH,JZHI2
MOV A,#01H
PUSH ACC
SJMP JZH20
JZHI2:
CJNE A,#0BEH, JZHI3
MOV A,#02H
PUSH ACC
SJMP JZH20
JZHI3:
CJNE A,#7EH,JZHI4
MOV A,#03H
PUSH ACC
SJMP JZH20
JZHI4:
CJNE A, #0EDH, JZHI5
MOV A,#04H
PUSH ACC
SJMP JZH20
JZHI5:
CJNE A,#0DDH, JZHI6
MOV A, #05H
PUSH ACC
SJMP JZH20
JZHI6:
CJNE A,#0BDH, JZHI7
MOV A, #06H
PUSH ACC
SJMP JZH20
JZHI7:
CJNE A,#07DH, JZHI8
MOV A, #07H
PUSH ACC
SJMP JZH20
JZHI8:
CJNE A,#0EBH, JZHI9
MOV A, #08H
PUSH ACC
SJMP JZH20
JZHI9:
CJNE A,#0DBH, KEYI
MOV A, #09H
PUSH ACC
JZH20:
POP ACC
MOV @R0,A
INC R0
INC R1
MOV A,R1
CJNE A,#6,JZH21
MOV R0,#79H
MOV R1,#0
JZH21:
LJMP KEYI
DIR:
MOV DPTR,#DEG
MOV R0,#79H;数码管第一位
MOV R3,#0FEH;线选
LD1:
CLR P2.7
CLR P2.6
MOV A,@R0
MOVC A,@A+DPTR
MOV P0,A
SETB P2.6
CLR P2.6
MOV P0,R3
SETB P2.6
SETB P2.7
LCALL DELY
INC R0
MOV A,R3
JNB ACC.5,LD2
RL A
MOV R3,A
SJMP LD1
LD2:
RET
DEG:
DB 3FH,06H,5BH,4FH,66H
DB 6DH,7DH,07H,7FH,6FH
DELY:
MOV R7,#06H
DL:
MOV R6,#0FFH
DL6:
DJNZ R6,DL6
DJNZ R7,DL
RET
KS1:
MOV P3,#0F0H
MOV A,P3
ANL A, #0F0H
RET ;键是否按下
END
LJMP MAIN
ORG 0100H
MAIN:
MOV SP,#78H
MOV 78H,#00H
MOV 79H,#00H
MOV 7AH,#00H
MOV 7BH,#00H
MOV 7CH,#00H
MOV 7DH,#00H
MOV 7EH,#00H
MOV R0,#79H
MOV R1,#0
KEYI:
ACALL KS1
CJNE A,#0F0H,LK1
ACALL DIR
AJMP KEYI
LK1:
ACALL DIR
ACALL KS1
CJNE A, #0F0H,LK2
ACALL DIR
AJMP KEYI
LK2:
ACALL KS1
MOV R2,A
ORL A,#0FH
MOV P3,A
MOV A,P3
ANL A,#0FH
ADD A,R2 ;键特征值
CJNE A,#0EEH,JZHI1
MOV A,#00H
PUSH ACC
SJMP JZH20
JZHI1:
CJNE A,#0DEH,JZHI2
MOV A,#01H
PUSH ACC
SJMP JZH20
JZHI2:
CJNE A,#0BEH, JZHI3
MOV A,#02H
PUSH ACC
SJMP JZH20
JZHI3:
CJNE A,#7EH,JZHI4
MOV A,#03H
PUSH ACC
SJMP JZH20
JZHI4:
CJNE A, #0EDH, JZHI5
MOV A,#04H
PUSH ACC
SJMP JZH20
JZHI5:
CJNE A,#0DDH, JZHI6
MOV A, #05H
PUSH ACC
SJMP JZH20
JZHI6:
CJNE A,#0BDH, JZHI7
MOV A, #06H
PUSH ACC
SJMP JZH20
JZHI7:
CJNE A,#07DH, JZHI8
MOV A, #07H
PUSH ACC
SJMP JZH20
JZHI8:
CJNE A,#0EBH, JZHI9
MOV A, #08H
PUSH ACC
SJMP JZH20
JZHI9:
CJNE A,#0DBH, KEYI
MOV A, #09H
PUSH ACC
JZH20:
POP ACC
MOV @R0,A
INC R0
INC R1
MOV A,R1
CJNE A,#6,JZH21
MOV R0,#79H
MOV R1,#0
JZH21:
LJMP KEYI
DIR:
MOV DPTR,#DEG
MOV R0,#79H;数码管第一位
MOV R3,#0FEH;线选
LD1:
CLR P2.7
CLR P2.6
MOV A,@R0
MOVC A,@A+DPTR
MOV P0,A
SETB P2.6
CLR P2.6
MOV P0,R3
SETB P2.6
SETB P2.7
LCALL DELY
INC R0
MOV A,R3
JNB ACC.5,LD2
RL A
MOV R3,A
SJMP LD1
LD2:
RET
DEG:
DB 3FH,06H,5BH,4FH,66H
DB 6DH,7DH,07H,7FH,6FH
DELY:
MOV R7,#06H
DL:
MOV R6,#0FFH
DL6:
DJNZ R6,DL6
DJNZ R7,DL
RET
KS1:
MOV P3,#0F0H
MOV A,P3
ANL A, #0F0H
RET ;键是否按下
END
追问
你帮我改的程序还是不对,但是给了我一些启发。谢谢你,现在我已经调出来了。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询