问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

Tr9x5(P2.5)-7E

发布网友 发布时间:2022-04-26 21:50

我来回答

1个回答

热心网友 时间:2023-11-07 07:27

汇编可以么

LED_1 EQU 30H
LED_2 EQU 31H
LED_3 EQU 32H
LED_4 EQU 33H
LED_5 EQU 34H
LED_6 EQU 35H
LED_7 EQU 36H
LED_8 EQU 37H
TIMER EQU 38H
MODE EQU 39H;模式判断
FLASH EQU 40H;闪烁判断 1亮 0不亮
BUTTON1 EQU 41H;按钮开关
BUTTON2 EQU 42H;按钮开关
BUTTON3 EQU 43H;按钮开关
BUTTON4 EQU 44H;按钮灵敏
CS1 EQU P2.0
CS2 EQU P2.1
WR_ON EQU P2.2
;-------------------------------
; 按钮
;-------------------------------
IN_SET EQU P2.3
IN_GAL EQU P2.4
IN_SUB EQU P2.5
;-------------------------------
; 主程序
;接口:D0-D7 接 P1.0-P1.7
; CS1 P2.0 CS2 P2.1 WR P2.2
;-------------------------------
ORG 0000H
JMP MAIN
ORG 000BH
JMP T0INT
ORG 0030H
MAIN:
CALL SYSINIT
;-------------------------------
START:
JMP START
;-------------------------------
; 计时器子程序
;-------------------------------
T0INT:
MOV TH0,#03CH
MOV TL0,#0AFH
CALL SHOW
DJNZ BUTTON4,T0INT1
MOV BUTTON4,#10
CALL AJ1
CALL AJ3
CALL AJ5
T0INT1:
DJNZ TIMER,T0INTEND
CALL MODE_PD1
T0INTEND:
RETI
;-------------------------------
; 模式判断
;-------------------------------
MODE_PD1:
MOV A,MODE
CJNE A,#0,MODE_PD2
MOV TIMER,#200
CALL CADD
JMP MODE_PDEND
MODE_PD2:
MOV A,MODE
CJNE A,#1,MODE_PD3
MOV TIMER,#50
CALL FLASH1
JMP MODE_PDEND
MODE_PD3:
MOV A,MODE
CJNE A,#2,MODE_PD4
MOV TIMER,#50
CALL FLASH3
JMP MODE_PDEND
MODE_PD4:
MOV A,MODE
CJNE A,#3,MODE_PDEND
MOV TIMER,#50
CALL FLASH5
MODE_PDEND:
RET
;-------------------------------
; 按钮
;-------------------------------
AJ1:
MOV A,BUTTON1
CJNE A,#1,AJ2
JB IN_SET,AJEND
MOV BUTTON1,#0
CALL SAVE2
MOV TIMER,#1
INC MODE
MOV A,MODE
CJNE A,#4,AJEND
MOV MODE,#0
MOV TIMER,#100
JMP AJEND
AJ2:
MOV A,BUTTON1
CJNE A,#0,AJ1
JNB IN_SET,AJEND
MOV BUTTON1,#1
JMP AJEND
AJ3:
MOV A,BUTTON2
CJNE A,#1,AJ4
JB IN_GAL,AJEND
MOV BUTTON2,#0
CALL GAL1
JMP AJEND
AJ4:
MOV A,BUTTON2
CJNE A,#0,AJ3
JNB IN_GAL,AJEND
MOV BUTTON2,#1
JMP AJEND
AJ5:
MOV A,BUTTON3
CJNE A,#1,AJ6
JB IN_SUB,AJEND
MOV BUTTON3,#0
CALL SUB1
JMP AJEND
AJ6:
MOV A,BUTTON3
CJNE A,#0,AJ5
JNB IN_SUB,AJEND
MOV BUTTON3,#1
JMP AJEND
AJEND:
RET
;-------------------------------
; 加法
;-------------------------------
GAL1:
MOV A,MODE
CJNE A,#3,GAL2
INC 58H
MOV A,58H
CJNE A,#10,GALEND
MOV 58H,#0
INC 57H
MOV A,57H
CJNE A,#6,GALEND
MOV 57H,#0
GAL2:
MOV A,MODE
CJNE A,#2,GAL3
INC 55H
MOV A,55H
CJNE A,#10,GALEND
MOV 55H,#0
INC 54H
MOV A,54H
CJNE A,#6,GALEND
MOV 54H,#0
GAL3:
MOV A,MODE
CJNE A,#1,GALEND
INC 52H
MOV A,52H
CJNE A,#10,GAL32
MOV 52H,#0
INC 51H
GAL32:
CJNE A,#4,GALEND
MOV A,51H
CJNE A,#2,GALEND
MOV 52H,#0
MOV 51H,#0
GALEND:
CALL SAVE2
RET
;-------------------------------
; 减法
;-------------------------------
SUB1:
MOV A,MODE
CJNE A,#3,SUB2
DEC 58H
MOV A,58H
CJNE A,#-1,SUBEND
MOV 58H,#9
DEC 57H
MOV A,57H
CJNE A,#-1,SUBEND
MOV 57H,#5
SUB2:
MOV A,MODE
CJNE A,#2,SUB3
DEC 55H
MOV A,55H
CJNE A,#-1,SUBEND
MOV 55H,#9
DEC 54H
MOV A,54H
CJNE A,#-1,SUBEND
MOV 54H,#5
SUB3:
MOV A,MODE
CJNE A,#1,SUBEND
DEC 52H
MOV A,52H
CJNE A,#-1,SUBEND
MOV 52H,#9
DEC 51H
MOV A,51H
CJNE A,#-1,GALEND
MOV 52H,#3
MOV 51H,#2
SUBEND:
CALL SAVE2
RET
;-------------------------------
; 闪烁
;-------------------------------
FLASH1:
MOV A,FLASH
CJNE A,#0,FLASH2
MOV 51H,LED_1
MOV 52H,LED_2
MOV LED_1,#11
MOV LED_2,#11
MOV FLASH,#1
JMP FLASHEND
FLASH2:
MOV A,FLASH
CJNE A,#1,FLASHEND
MOV LED_1,51H
MOV LED_2,52H
MOV FLASH,#0
JMP FLASHEND;小时闪烁
FLASH3:
MOV A,FLASH
CJNE A,#0,FLASH4
MOV 54H,LED_4
MOV 55H,LED_5
MOV LED_4,#11
MOV LED_5,#11
MOV FLASH,#1
JMP FLASHEND
FLASH4:
MOV A,FLASH
CJNE A,#1,FLASHEND
MOV LED_4,54H
MOV LED_5,55H
MOV FLASH,#0
JMP FLASHEND;分钟闪烁
FLASH5:
MOV A,FLASH
CJNE A,#0,FLASH6
MOV 57H,LED_7
MOV 58H,LED_8
MOV LED_7,#11
MOV LED_8,#11
MOV FLASH,#1
JMP FLASHEND
FLASH6:
MOV A,FLASH
CJNE A,#1,FLASHEND
MOV LED_7,57H
MOV LED_8,58H
MOV FLASH,#0;秒钟闪烁
FLASHEND:
RET
;-------------------------------
; 数据加减
;-------------------------------
CADD:
INC LED_8
MOV A,LED_8
CJNE A,#10,CADDEND
MOV LED_8,#0
INC LED_7
MOV A,LED_7
CJNE A,#6,CADDEND
MOV LED_7,#0
INC LED_5
MOV A,LED_5
CJNE A,#10,CADDEND
MOV LED_5,#0
INC LED_4
MOV A,LED_4
CJNE A,#6,CADDEND
MOV LED_4,#0
INC LED_2
MOV A,LED_2
CJNE A,#10,CADD2
MOV LED_2,#0
INC LED_1
CADD2:
CJNE A,#4,CADDEND
MOV A,LED_1
CJNE A,#2,CADDEND
CALL SYSINIT
CADDEND:
CALL SAVE1
RET
;-------------------------------
; 数据显示
;-------------------------------
SHOW:
MOV R0,#30H
MOV R1,#8
MOV R2,#B
SHOW1:
MOV A,R2
MOV P0,A
CALL CS2_ON
RR A
MOV R2,A
MOV A,@R0
MOVC A,@A+DPTR
MOV P0,A
CALL CS1_ON
CALL DELAY
MOV P0,#0FFH
CALL CS1_ON
CALL CS2_ON
INC R0
DJNZ R1,SHOW1
RET
CS1_ON:
CLR WR_ON
CLR CS1
SETB WR_ON
SETB CS1
RET
CS2_ON:
CLR WR_ON
CLR CS2
SETB WR_ON
SETB CS2
RET
;-------------------------------
; 数据储存
;-------------------------------
SAVE1:
MOV 51H,LED_1
MOV 52H,LED_2
MOV 54H,LED_4
MOV 55H,LED_5
MOV 57H,LED_7
MOV 58H,LED_8
RET
SAVE2:
MOV LED_1,51H
MOV LED_2,52H
MOV LED_4,54H
MOV LED_5,55H
MOV LED_7,57H
MOV LED_8,58H
RET
;-------------------------------
; 数据初始化
;-------------------------------
SYSINIT:
MOV LED_1,#0
MOV LED_2,#0
MOV LED_3,#10
MOV LED_4,#0
MOV LED_5,#0
MOV LED_6,#10
MOV LED_7,#0
MOV LED_8,#0
CALL SAVE1
MOV TIMER,#200
MOV MODE,#0
MOV FLASH,#0
MOV BUTTON1,#1
MOV BUTTON2,#1
MOV BUTTON3,#1
MOV BUTTON4,#3
MOV TH0,#03CH
MOV TL0,#0AFH
SETB TR0
SETB ET0
SETB EA
MOV DPTR,#TAB
RET
;-------------------------------
; 延迟
;-------------------------------
DELAY:
MOV R6,#255
DJNZ R6,$
RET
;-------------------------------
; 段码
;-------------------------------
TAB:
DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H,0BFH,0FFH
;0- "0"
;1- "1"
;2- "2"
;
;9- "9"
;10-"-"
;11-" "
END

热心网友 时间:2023-11-07 07:27

汇编可以么

LED_1 EQU 30H
LED_2 EQU 31H
LED_3 EQU 32H
LED_4 EQU 33H
LED_5 EQU 34H
LED_6 EQU 35H
LED_7 EQU 36H
LED_8 EQU 37H
TIMER EQU 38H
MODE EQU 39H;模式判断
FLASH EQU 40H;闪烁判断 1亮 0不亮
BUTTON1 EQU 41H;按钮开关
BUTTON2 EQU 42H;按钮开关
BUTTON3 EQU 43H;按钮开关
BUTTON4 EQU 44H;按钮灵敏
CS1 EQU P2.0
CS2 EQU P2.1
WR_ON EQU P2.2
;-------------------------------
; 按钮
;-------------------------------
IN_SET EQU P2.3
IN_GAL EQU P2.4
IN_SUB EQU P2.5
;-------------------------------
; 主程序
;接口:D0-D7 接 P1.0-P1.7
; CS1 P2.0 CS2 P2.1 WR P2.2
;-------------------------------
ORG 0000H
JMP MAIN
ORG 000BH
JMP T0INT
ORG 0030H
MAIN:
CALL SYSINIT
;-------------------------------
START:
JMP START
;-------------------------------
; 计时器子程序
;-------------------------------
T0INT:
MOV TH0,#03CH
MOV TL0,#0AFH
CALL SHOW
DJNZ BUTTON4,T0INT1
MOV BUTTON4,#10
CALL AJ1
CALL AJ3
CALL AJ5
T0INT1:
DJNZ TIMER,T0INTEND
CALL MODE_PD1
T0INTEND:
RETI
;-------------------------------
; 模式判断
;-------------------------------
MODE_PD1:
MOV A,MODE
CJNE A,#0,MODE_PD2
MOV TIMER,#200
CALL CADD
JMP MODE_PDEND
MODE_PD2:
MOV A,MODE
CJNE A,#1,MODE_PD3
MOV TIMER,#50
CALL FLASH1
JMP MODE_PDEND
MODE_PD3:
MOV A,MODE
CJNE A,#2,MODE_PD4
MOV TIMER,#50
CALL FLASH3
JMP MODE_PDEND
MODE_PD4:
MOV A,MODE
CJNE A,#3,MODE_PDEND
MOV TIMER,#50
CALL FLASH5
MODE_PDEND:
RET
;-------------------------------
; 按钮
;-------------------------------
AJ1:
MOV A,BUTTON1
CJNE A,#1,AJ2
JB IN_SET,AJEND
MOV BUTTON1,#0
CALL SAVE2
MOV TIMER,#1
INC MODE
MOV A,MODE
CJNE A,#4,AJEND
MOV MODE,#0
MOV TIMER,#100
JMP AJEND
AJ2:
MOV A,BUTTON1
CJNE A,#0,AJ1
JNB IN_SET,AJEND
MOV BUTTON1,#1
JMP AJEND
AJ3:
MOV A,BUTTON2
CJNE A,#1,AJ4
JB IN_GAL,AJEND
MOV BUTTON2,#0
CALL GAL1
JMP AJEND
AJ4:
MOV A,BUTTON2
CJNE A,#0,AJ3
JNB IN_GAL,AJEND
MOV BUTTON2,#1
JMP AJEND
AJ5:
MOV A,BUTTON3
CJNE A,#1,AJ6
JB IN_SUB,AJEND
MOV BUTTON3,#0
CALL SUB1
JMP AJEND
AJ6:
MOV A,BUTTON3
CJNE A,#0,AJ5
JNB IN_SUB,AJEND
MOV BUTTON3,#1
JMP AJEND
AJEND:
RET
;-------------------------------
; 加法
;-------------------------------
GAL1:
MOV A,MODE
CJNE A,#3,GAL2
INC 58H
MOV A,58H
CJNE A,#10,GALEND
MOV 58H,#0
INC 57H
MOV A,57H
CJNE A,#6,GALEND
MOV 57H,#0
GAL2:
MOV A,MODE
CJNE A,#2,GAL3
INC 55H
MOV A,55H
CJNE A,#10,GALEND
MOV 55H,#0
INC 54H
MOV A,54H
CJNE A,#6,GALEND
MOV 54H,#0
GAL3:
MOV A,MODE
CJNE A,#1,GALEND
INC 52H
MOV A,52H
CJNE A,#10,GAL32
MOV 52H,#0
INC 51H
GAL32:
CJNE A,#4,GALEND
MOV A,51H
CJNE A,#2,GALEND
MOV 52H,#0
MOV 51H,#0
GALEND:
CALL SAVE2
RET
;-------------------------------
; 减法
;-------------------------------
SUB1:
MOV A,MODE
CJNE A,#3,SUB2
DEC 58H
MOV A,58H
CJNE A,#-1,SUBEND
MOV 58H,#9
DEC 57H
MOV A,57H
CJNE A,#-1,SUBEND
MOV 57H,#5
SUB2:
MOV A,MODE
CJNE A,#2,SUB3
DEC 55H
MOV A,55H
CJNE A,#-1,SUBEND
MOV 55H,#9
DEC 54H
MOV A,54H
CJNE A,#-1,SUBEND
MOV 54H,#5
SUB3:
MOV A,MODE
CJNE A,#1,SUBEND
DEC 52H
MOV A,52H
CJNE A,#-1,SUBEND
MOV 52H,#9
DEC 51H
MOV A,51H
CJNE A,#-1,GALEND
MOV 52H,#3
MOV 51H,#2
SUBEND:
CALL SAVE2
RET
;-------------------------------
; 闪烁
;-------------------------------
FLASH1:
MOV A,FLASH
CJNE A,#0,FLASH2
MOV 51H,LED_1
MOV 52H,LED_2
MOV LED_1,#11
MOV LED_2,#11
MOV FLASH,#1
JMP FLASHEND
FLASH2:
MOV A,FLASH
CJNE A,#1,FLASHEND
MOV LED_1,51H
MOV LED_2,52H
MOV FLASH,#0
JMP FLASHEND;小时闪烁
FLASH3:
MOV A,FLASH
CJNE A,#0,FLASH4
MOV 54H,LED_4
MOV 55H,LED_5
MOV LED_4,#11
MOV LED_5,#11
MOV FLASH,#1
JMP FLASHEND
FLASH4:
MOV A,FLASH
CJNE A,#1,FLASHEND
MOV LED_4,54H
MOV LED_5,55H
MOV FLASH,#0
JMP FLASHEND;分钟闪烁
FLASH5:
MOV A,FLASH
CJNE A,#0,FLASH6
MOV 57H,LED_7
MOV 58H,LED_8
MOV LED_7,#11
MOV LED_8,#11
MOV FLASH,#1
JMP FLASHEND
FLASH6:
MOV A,FLASH
CJNE A,#1,FLASHEND
MOV LED_7,57H
MOV LED_8,58H
MOV FLASH,#0;秒钟闪烁
FLASHEND:
RET
;-------------------------------
; 数据加减
;-------------------------------
CADD:
INC LED_8
MOV A,LED_8
CJNE A,#10,CADDEND
MOV LED_8,#0
INC LED_7
MOV A,LED_7
CJNE A,#6,CADDEND
MOV LED_7,#0
INC LED_5
MOV A,LED_5
CJNE A,#10,CADDEND
MOV LED_5,#0
INC LED_4
MOV A,LED_4
CJNE A,#6,CADDEND
MOV LED_4,#0
INC LED_2
MOV A,LED_2
CJNE A,#10,CADD2
MOV LED_2,#0
INC LED_1
CADD2:
CJNE A,#4,CADDEND
MOV A,LED_1
CJNE A,#2,CADDEND
CALL SYSINIT
CADDEND:
CALL SAVE1
RET
;-------------------------------
; 数据显示
;-------------------------------
SHOW:
MOV R0,#30H
MOV R1,#8
MOV R2,#B
SHOW1:
MOV A,R2
MOV P0,A
CALL CS2_ON
RR A
MOV R2,A
MOV A,@R0
MOVC A,@A+DPTR
MOV P0,A
CALL CS1_ON
CALL DELAY
MOV P0,#0FFH
CALL CS1_ON
CALL CS2_ON
INC R0
DJNZ R1,SHOW1
RET
CS1_ON:
CLR WR_ON
CLR CS1
SETB WR_ON
SETB CS1
RET
CS2_ON:
CLR WR_ON
CLR CS2
SETB WR_ON
SETB CS2
RET
;-------------------------------
; 数据储存
;-------------------------------
SAVE1:
MOV 51H,LED_1
MOV 52H,LED_2
MOV 54H,LED_4
MOV 55H,LED_5
MOV 57H,LED_7
MOV 58H,LED_8
RET
SAVE2:
MOV LED_1,51H
MOV LED_2,52H
MOV LED_4,54H
MOV LED_5,55H
MOV LED_7,57H
MOV LED_8,58H
RET
;-------------------------------
; 数据初始化
;-------------------------------
SYSINIT:
MOV LED_1,#0
MOV LED_2,#0
MOV LED_3,#10
MOV LED_4,#0
MOV LED_5,#0
MOV LED_6,#10
MOV LED_7,#0
MOV LED_8,#0
CALL SAVE1
MOV TIMER,#200
MOV MODE,#0
MOV FLASH,#0
MOV BUTTON1,#1
MOV BUTTON2,#1
MOV BUTTON3,#1
MOV BUTTON4,#3
MOV TH0,#03CH
MOV TL0,#0AFH
SETB TR0
SETB ET0
SETB EA
MOV DPTR,#TAB
RET
;-------------------------------
; 延迟
;-------------------------------
DELAY:
MOV R6,#255
DJNZ R6,$
RET
;-------------------------------
; 段码
;-------------------------------
TAB:
DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H,0BFH,0FFH
;0- "0"
;1- "1"
;2- "2"
;
;9- "9"
;10-"-"
;11-" "
END
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
苹果电脑电池充不进电苹果电脑充不进去电是怎么回事 苹果电脑不充电没反应苹果电脑充电指示灯不亮充不了电怎么办 狗狗更加忠诚护家、善解人意,养一只宠物陪伴自己,泰迪能长多大... 描写泰迪狗的外形和特点的句子 国外留学有用吗 花钱出国留学有用吗 !这叫什么号 百万医疗赔付后是否可以续保 前一年理赔过医疗险还能续保吗? 医疗住院险理赔后还能购买吗? 整式的定义 c#如何调用PCHunter(xuetr)的驱动呢? 整式包括有哪些? lvtr9.5大概是aj多少 什么是整式概念是什么 天天德州发牌系统是不是有问题啊?我特么kk输69,AJ输38,而且对面都特么在river做成了tr 什么叫整式? ajtr还是预警期刊吗 整式的定义是什么 什么是整式?概念是什么? 什么叫整式 整式的概念 整式的概念是什么? “整式”的定义是什么? 整式是什么?有哪些例子? 什么是整式 什么是整式? 想在中信证券开户,有没有低佣金的在万2以下的渠道? 现在证券开户佣金最低可以多少? 证券股票开户一般多少,市场普遍万1.2了吗? 手机qq照片存在哪里? 什么叫做整式 整式包括什么和什么? 整式是什么(关于代数的) 穿越制作细盐的电视剧有哪些? 法律硕士(法学)用书? 考法学学硕需要跟着法硕的戴老师一起背吗 cortana它是个什么 法硕联考用书?? 花呗分期还没到时间能关闭花呗重开吗 法硕联考 法硕只背背诵手册够吗 谁有法律硕士(非法学)的资料?求 法硕(法学)专业课都需要买什么书和资料啊 花呗分期付款能不能取消? 法律硕士(非法学)考研的所有教材 考研的法硕(非法学)专业课的录音和资料哪可以下载或者发给我,急求 华为应用商店的 APP产品下载链接在哪里? 法硕非法学除了讲义还需要买什么资料和辅导书 华为手机怎么设置默认在华为应用商店打开安装链接?