急求51单片机汇编程序,请高手进来帮忙

急求51单片机汇编程序,请高手进来帮忙,第1张

我有一个程序你的电路设计不是太一样,大体上的功能差不多,就是我上大学时做的,标注太少程序比较亩氏乱。为了提高时间的准确性是用T0中断输入外部的秒时钟信号做的。显示有取余晖功能,按键为单脉冲触发,有自动累加功能,可以自动判定月份日期,数据表为辩棚(格式携耐则减1)

DB 32H,29H,32H,31H,32H,31H,32H,32H,31H

DB 00H,00H,00H,00H,00H,00H,32H,31H,32H

没有秒表功能。你得看端口定义,或者是看程序,程序不难,如果想实现你得功能改一改就可以。仅供产考

=====================================================================

WEI EQU P2 位码

WEICON EQU 08H 位码缓存

DUANEQU P0 段码

GESHU EQU 09H 显示个数

Y0 EQU 01H 延时

Y1 EQU 11H

M0 EQU 12H 计数

M1 EQU 13H

M2 EQU 14H

M3 EQU 15H

MOSHI0 EQU 17H 模式0

MOSHI1 EQU 18H 模式1

JS EQU 19H 记时

JS2 EQU 1AH

JS4 EQU 16H

TINGJI EQU 1CH 停机5分钟

TIAOL EQU 1DH 调时差值

TIAOCA EQU 1EH

TIAOCB EQU 1FH

TIAOS EQU 28H

MUOSHI0 EQU 29H

ST0 EQU 2AH

ST1 EQU 2BH

ST2 EQU 2CH

DIS EQU 20H 显示缓存头地址

SECQEQU 40H 秒

MINQEQU 41H 分

HOURQ EQU 42H 小时

DAYQEQU 43H 日

MONQEQU 44H 月

YEARQ EQU 45H 年

JIANBIT 2EH.0 键盘标志

JIANY BIT 2EH.1 键盘延时标志

JIANCA BIT 2EH.2

JIANCB BIT 2EH.3

TIAOD BIT 2EH.4

MO2 BIT 2EH.5

TS2 BIT 2EH.6

TIAOMAI BIT 2EH.7 调点的脉冲

TINGBIT 2FH.0 停机

=====================================================================

ORG 0000H

SJMPSTART

ORG 0003H

AJMPBRT0

ORG 000BH

AJMPBRT0

ORG 0030H

START: MOV R0,#02H

MOV R1,#100D

STARTM: MOV @R0,#00H

INC R0

DJNZR1,STARTM

MOV R0,#00H

MOV SP,#60H

MOV DAYQ,#01H

MOV MONQ,#01H

MOV YEARQ,#01H

MOV WEICON,#11111110B

MOV GESHU,#08H

MOV IE,#82H

SETBEX0

SETBIT0

MOV M0,#2D

MOV M1,#25D

MOV M2,#2D

MOV M3,#4D

MOV ST0,#100D

MOV ST1,#20D

MOV ST2,#02D

MOV JS4,#02H

MOV TINGJI,#05H

MOV 3EH,#25H

---------------------------------------------------------------------

MAIN: ACALL LED0好

ACALL ZHUAN

ACALL MUOSHI

ACALL JIANP

ACALL STARTJ

DJNZGESHU,MAIN

MOV GESHU,#08H

SJMPMAIN

---------------------------------------------------------------------

STARTJ: JNB TING,VVV

DJNZST0,VVV

MOV ST0,#100D

DJNZST1,VVV

MOV ST1,#40D

DJNZST2,VVV

MOV ST2,#02D

CLR TING

MOV MUOSHI0,#00H

MOV TIAOS,#00000000B

VVV:RET

---------------------------------------------------------------------

MUOSHI: MOV A,MUOSHI0

CJNEA,#00H,Q0

MOV 20H,35H 时

MOV 21H,34H

MOV 22H,#0BH

MOV 23H,33H 分

MOV 24H,32H

MOV 25H,#0BH

MOV 26H,31H 秒

MOV 27H,30H

Q0: CJNEA,#01H,Q1

MOV 20H,3BH 时

MOV 21H,3AH

MOV 22H,#0CH

MOV 23H,39H 分

MOV 24H,38H

MOV 25H,#0CH

MOV 26H,37H 秒

MOV 27H,36H

Q1: RET

---------------------------------------------------------------------

=====================================================================

数码管的显示程序,

=====================================================================

LED0: MOV WEI,#11111111B 关端口

MOV A,#1FH 传送段码数据

ADD A,GESHU

MOV R0,A

MOV A,@R0

ACALL LED1

MOV A,WEICON传送位码数据

RR A

MOV WEICON,A

JNB TIAOD,PLL

ORL A,TIAOS

PLL: MOV WEI,A

ACALL DELAY 延时

RET

---------------------------------------------------------------------

LED1: ADD A,#03H

MOVCA,@A+PC

MOV DUAN,A

RET

DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH,00H,40H,20H

---------------------------------------------------------------------

DELAY: MOV Y0,#050D

DEL0: MOV Y1,#020D

DEL1: DJNZY1,DEL1

DJNZY0,DEL0

RET

---------------------------------------------------------------------

JIANP: JB JIAN,JIAN4

JB JIANY,JIAN2

SETBP1.0

JB P1.0,JIAN0

SETBJIAN

SETBJIANY

SJMPJIAN4

JIAN0: CLR JIANCA

SETBP1.1

JB P1.1,JIAN1

SETBJIAN

SETBJIANY

SJMPJIAN4

JIAN1: CLR JIANCB

JIAN2: CLR JIANY

SETBP1.0

JB P1.0,JIAN3

JB JIANCA,JIAN3

SETBJIANCA

ACALL TIAOA

CLR JIANY

JIAN3: SETBP1.1

JB P1.1,JIAN4

JB JIANCB,JIAN4

SETBJIANCB

ACALL TIAOB

SETBTIAOMAI

CLR JIANY

JIAN4: RET

--------------------------------------------------------------------

TIAOA: JB MO2,RP5

INC TIAOCA

MOV JS,#00H

MOV JS2,#00H

MOV ST0,#100D

MOV ST1,#40D

MOV ST2,#02D

MOV A,TIAOCA

CJNEA,#01H,RP0

MOV TIAOS,#00000011B

SETBTS2

RP0: CJNEA,#02H,RP1

MOV TIAOS,#00011000B

SETBTS2

RP1: CJNEA,#03H,RP2

MOV TIAOS,#00000011B

SETBTS2

MOV MUOSHI0,#01H

RP2: CJNEA,#04H,RP3

MOV TIAOS,#00011000B

SETBTS2

RP3: CJNEA,#05H,RP4

MOV TIAOS,#11000000B

SETBTS2

RP4: CJNEA,#06H,RP5

MOV TIAOCA,#00H

MOV TIAOS,#00000000B

MOV MUOSHI0,#00H

RP5:RET

---------------------------------------------------------------------

TIAOB: MOV A,TIAOCA

CJNEA,#01H,RG0

ACALL HOUR

MOV JS2,#00H 从新规定5S

SJMPQW2

RG0: CJNEA,#02H,RG1

ACALL MINUTE

SETBTING

MOV SECQ,#00H

MOV JS2,#00H

SJMPQW2

RG1: CJNEA,#03H,RG2

ACALL YEAR

MOV JS2,#00H

MOV MUOSHI0,#01H

SJMPQW2

RG2: CJNEA,#04H,RG3

ACALL MONTH

MOV JS2,#00H

SJMPQW2

RG3: CJNEA,#05H,RG4

ACALL DAY

MOV JS2,#00H

SJMPQW2

RG4:CLR TING

INC MUOSHI0

MOV A,MUOSHI0

CJNEA,#01H,QW0

SETBMO2延时5S

SJMPQW2

QW0:CJNEA,#02H,QW2

MOV MUOSHI0,#00H

QW2:MOV ST0,#100D

MOV ST1,#40D

MOV ST2,#02D

RET

---------------------------------------------------------------------

BRT0: PUSHPSW

PUSHACC

JNB JIAN,BRT1

DJNZ3EH,BRT2

CLR JIAN

BRT1: MOV 3EH,#2D

BRT2: DJNZM0,RE

MOV M0,#4D

JNB TIAOMAI,FSF

DJNZJS4,FAF

MOV JS4,#02H

CLR TIAOMAI

MOV TIAOL,#00H

CLR JIAN

CLR JIANY

CLR JIANCB

FAF:CLR TIAOD

DJNZM3,RE

MOV M3,#04D

SJMPFDF

FSF:DJNZM3,RE

MOV M3,#04D

CPL TIAOD

FDF:DJNZM2,RE

MOV M2,#2D

JB TING,RE

ACALL SECOND

MOV A,SECQ

CJNEA,#00H,RE

ACALL MINUTE

MOV A,MINQ

CJNEA,#00H,RE

ACALL HOUR

MOV A,HOURQ

CJNEA,#00H,RE

ACALL DAY

CJNEA,#00H,RE

MOV DAYQ,#00H

ACALL MONTH

ACALL YEAR

RE: POP ACC

POP PSW

RETI

---------------------------------------------------------------------

ZHUAN: MOV R1,#30H秒30H,31H

MOV A,SECQ

ACALL ZHUAN0 分32H,33H

MOV A,MINQ

ACALL ZHUAN0 时34H,35H

MOV A,HOURQ

ACALL ZHUAN0 日36H,37H

MOV A,DAYQ

ACALL ZHUAN0 月38H,39H

MOV A,MONQ

ACALL ZHUAN0 年3AH,3BH

MOV A,YEARQ

ACALL ZHUAN0

RET

---------------------------------------------------------------------

ZHUAN0: XCHDA,@R1

SWAPA

ANL A,#0FH

INC R1

MOV @R1,A

INC R1

RET

---------------------------------------------------------------------

SECOND: JNB MO2,FFF

INC JS

MOV A,JS

CJNEA,#05D,FFF

MOV JS,#00H

MOV MUOSHI0,#00H

CLR MO2

FFF:JNB TS2,GGG

INC JS2

MOV A,JS2

CJNEA,#30D,GGG

MOV JS2,#00H

MOV MUOSHI0,#00H

MOV TIAOS,#00000000B

MOV TIAOCA,#00H

CLR TS2

GGG:INC SECQ

CLR AC

CLR C

MOV A,SECQ

DA A

MOV SECQ,A

CJNEA,#60H,RE0

MOV SECQ,#00H

RE0:RET

---------------------------------------------------------------------

MINUTE: INC TINGJI

MOV A,TINGJI

CJNEA,#05H,TTT

MOV TINGJI,#00H

CLR TING

TTT:INC MINQ

CLR AC

CLR C

MOV A,MINQ

DA A

MOV MINQ,A

CJNEA,#60H,RE1

MOV MINQ,#00H

RE1:RET

---------------------------------------------------------------------

HOUR: INC HOURQ

CLR AC

CLR C

MOV A,HOURQ

DA A

MOV HOURQ,A

CJNEA,#24H,RE2

MOV HOURQ,#00H

RE2:RET

---------------------------------------------------------------------

DAY:MOV A,MONQ

ADD A,#17D

MOVCA,@A+PC

MOV R2,A

INC DAYQ

CLR AC

CLR C

MOV A,DAYQ

DA A

MOV DAYQ,A

CJNEA,02H,RE3

MOV DAYQ,#01H

RE3:RET

DB 32H,29H,32H,31H,32H,31H,32H,32H,31H

DB 00H,00H,00H,00H,00H,00H,32H,31H,32H

---------------------------------------------------------------------

MONTH: INC MONQ

CLR AC

CLR C

MOV A,MONQ

DA A

MOV MONQ,A

CJNEA,#13H,RE4

MOV MONQ,#01H

RE4:RET

---------------------------------------------------------------------

YEAR: INC YEARQ

CLR AC

CLR C

MOV A,YEARQ

DA A

MOV YEARQ,A

RE5:RET

---------------------------------------------------------------------

END

你看到的程序应该是用在STC单片机上的,因为STC单片机的P0,P1,P2,P3口可以设置成四种工作模式,即开机处于的准双向口,推挽输出,高阻输入,开漏输出这四种。如果需要设置成其余的3种,就要通顷悉伍过对各自配陆碧置寄存器来设置的,你的P0M0,雀或P0M1就对P0进行设置的,同样有P1M0,P1M1是对P1口进行设置的,以此类推。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12354025.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存