请高手帮我用8051单片机用汇编一个数字的显示 开关按一下 数字增加一 从0到9 汇编程序
答案:3 悬赏:50 手机版
解决时间 2021-04-12 21:26
- 提问者网友:焚苦与心
- 2021-04-12 04:11
请高手帮我用8051单片机用汇编一个数字的显示 开关按一下 数字增加一 从0到9 汇编程序
最佳答案
- 五星知识达人网友:鸠书
- 2021-04-12 05:39
SP1 EQU P3.2
ORG 0000H
MOV 30H, #3FH ;0
MOV 31H, #06H ;1
MOV 32H, #5BH ;2
MOV 33H, #4FH ;3
MOV 34H, #66H ;4
MOV 35H, #6DH ;5
MOV 36H, #7DH ;6
MOV 37H, #07H ;7
MOV 38H, #7FH ;8
MOV 39H, #6FH ;9
M_0: MOV R0, #30H
DISP: MOV P2, @R0
WT: JB SP1, $
MOV R6, #40
DJNZ R7, $
DJNZ R6, $ - 2
JB SP1, WT
JNB SP1, $
INC R0
CJNE R0, #3AH, DISP
SJMP M_0
END
ORG 0000H
MOV 30H, #3FH ;0
MOV 31H, #06H ;1
MOV 32H, #5BH ;2
MOV 33H, #4FH ;3
MOV 34H, #66H ;4
MOV 35H, #6DH ;5
MOV 36H, #7DH ;6
MOV 37H, #07H ;7
MOV 38H, #7FH ;8
MOV 39H, #6FH ;9
M_0: MOV R0, #30H
DISP: MOV P2, @R0
WT: JB SP1, $
MOV R6, #40
DJNZ R7, $
DJNZ R6, $ - 2
JB SP1, WT
JNB SP1, $
INC R0
CJNE R0, #3AH, DISP
SJMP M_0
END
全部回答
- 1楼网友:过活
- 2021-04-12 08:30
TIM EQU 30H
CNTA EQU 31H
CNTB EQU 32H
ORG 00H
LJMP START
ORG 0BH
LJMP T0X
ORG 30H
START: MOV TIM,#00H
MOV CNTA,#00H
MOV CNTB,#00H
MOV TMOD,#01H
MOV TH0,#(65536-4000)/256
MOV TL0,#(65536-4000) MOD 256
SETB TR0
SETB ET0
SETB EA
SJMP $
T0X:
MOV TH0,#(65536-4000)/256
MOV TL0,#(65536-4000) MOD 256
MOV DPTR,#TAB
MOV A,CNTA
MOVC A,@A+DPTR
MOV P3,A
MOV DPTR,#DIGIT
MOV A,CNTB
MOV B,#8
MUL AB
ADD A,CNTA
MOVC A,@A+DPTR
MOV P1,A
INC CNTA
MOV A,CNTA
CJNE A,#8,NEXT
MOV CNTA,#00H
NEXT: INC TIM
MOV A,TIM
CJNE A,#250,NEX
MOV TIM,#00H
INC CNTB
MOV A,CNTB
CJNE A,#10,NEX
MOV CNTB,#00H
NEX: RETI
TAB: DB 0FEH,0FDH,0FBH,0F7H,0EFH,0DFH,0BFH,07FH
DIGIT: DB 00H,00H,3EH,41H,41H,41H,3EH,00H
DB 00H,00H,00H,00H,21H,7FH,01H,00H
DB 00H,00H,27H,45H,45H,45H,39H,00H
DB 00H,00H,22H,49H,49H,49H,36H,00H
DB 00H,00H,0CH,14H,24H,7FH,04H,00H
DB 00H,00H,72H,51H,51H,51H,4EH,00H
DB 00H,00H,3EH,49H,49H,49H,26H,00H
DB 00H,00H,40H,40H,40H,4FH,70H,00H
DB 00H,00H,36H,49H,49H,49H,36H,00H
DB 00H,00H,32H,49H,49H,49H,3EH,00H
END
CNTA EQU 31H
CNTB EQU 32H
ORG 00H
LJMP START
ORG 0BH
LJMP T0X
ORG 30H
START: MOV TIM,#00H
MOV CNTA,#00H
MOV CNTB,#00H
MOV TMOD,#01H
MOV TH0,#(65536-4000)/256
MOV TL0,#(65536-4000) MOD 256
SETB TR0
SETB ET0
SETB EA
SJMP $
T0X:
MOV TH0,#(65536-4000)/256
MOV TL0,#(65536-4000) MOD 256
MOV DPTR,#TAB
MOV A,CNTA
MOVC A,@A+DPTR
MOV P3,A
MOV DPTR,#DIGIT
MOV A,CNTB
MOV B,#8
MUL AB
ADD A,CNTA
MOVC A,@A+DPTR
MOV P1,A
INC CNTA
MOV A,CNTA
CJNE A,#8,NEXT
MOV CNTA,#00H
NEXT: INC TIM
MOV A,TIM
CJNE A,#250,NEX
MOV TIM,#00H
INC CNTB
MOV A,CNTB
CJNE A,#10,NEX
MOV CNTB,#00H
NEX: RETI
TAB: DB 0FEH,0FDH,0FBH,0F7H,0EFH,0DFH,0BFH,07FH
DIGIT: DB 00H,00H,3EH,41H,41H,41H,3EH,00H
DB 00H,00H,00H,00H,21H,7FH,01H,00H
DB 00H,00H,27H,45H,45H,45H,39H,00H
DB 00H,00H,22H,49H,49H,49H,36H,00H
DB 00H,00H,0CH,14H,24H,7FH,04H,00H
DB 00H,00H,72H,51H,51H,51H,4EH,00H
DB 00H,00H,3EH,49H,49H,49H,26H,00H
DB 00H,00H,40H,40H,40H,4FH,70H,00H
DB 00H,00H,36H,49H,49H,49H,36H,00H
DB 00H,00H,32H,49H,49H,49H,3EH,00H
END
- 2楼网友:想偏头吻你
- 2021-04-12 06:58
硬件设置:
1、P0口接共阳极数码管,P0口与数码管串接300~470欧电阻;
2、P1.0接按键,低电平有效;
3、晶振为12M
软件部分如下:
ORG 00H
LJMP MAIN
ORG 100H
MAIN:
MOV 30H,#00H
MOV DPTR,#TAB
START:
LCALL SHOW_DATA
JB P1.0,START
LCALL DELAY_50MS
JNB P1.0,$
MOV A,30H
MOV B,#09H
DIV AB
JZ ADD_1:
MOV 30H,#00H
SJMP START
ADD_1:
INC 30H
SJMP START
DELAY_50MS:
MOV R7,#200D
LP:
MOV R6,#250D
DJNZ R6,$
DJNZ R7,LP
RET
SHOW_DATA:
MOV A,30H
MOVC A,@A+DPTR
MOV P0,A
RET
TAB: ;表:共阳数码管 0-9 A-F
DB 0C0H,0F9H,0A4H,0b0H,99H,92H,82H,0F8H,80H,90H,88H,83H,0C6H,0A1H,86H,8EH
END
1、P0口接共阳极数码管,P0口与数码管串接300~470欧电阻;
2、P1.0接按键,低电平有效;
3、晶振为12M
软件部分如下:
ORG 00H
LJMP MAIN
ORG 100H
MAIN:
MOV 30H,#00H
MOV DPTR,#TAB
START:
LCALL SHOW_DATA
JB P1.0,START
LCALL DELAY_50MS
JNB P1.0,$
MOV A,30H
MOV B,#09H
DIV AB
JZ ADD_1:
MOV 30H,#00H
SJMP START
ADD_1:
INC 30H
SJMP START
DELAY_50MS:
MOV R7,#200D
LP:
MOV R6,#250D
DJNZ R6,$
DJNZ R7,LP
RET
SHOW_DATA:
MOV A,30H
MOVC A,@A+DPTR
MOV P0,A
RET
TAB: ;表:共阳数码管 0-9 A-F
DB 0C0H,0F9H,0A4H,0b0H,99H,92H,82H,0F8H,80H,90H,88H,83H,0C6H,0A1H,86H,8EH
END
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯