您当前的位置:五五电子网电子知识单片机-工控设备51单片机用51 单片机实现公历与农历星期的转换 正文
用51 单片机实现公历与农历星期的转换

用51 单片机实现公历与农历星期的转换

点击数:7629 次   录入时间:03-04 12:01:58   整理:http://www.55dianzi.com   51单片机
DB 045h,02eh,0B7h; 2069
DB 005h,02dh,04Bh; 2070
DB 08Ah,095h,0Bfh; 2071
DB 00Ah,095h,053h; 2072
- 13 -
DB 00Bh,04Ah,047h; 2073
DB 06Bh,055h,03Bh; 2074
DB 00Ah,0d5h,04fh; 2075
DB 005h,05Ah,045h; 2076
DB 04Ah,05dh,038h; 2077
DB 00Ah,05Bh,04Ch; 2078
DB 005h,02Bh,042h; 2079
DB 03Ah,093h,0B6h; 2080
DB 006h,093h,049h; 2081
DB 077h,029h,0Bdh; 2082
DB 006h,0AAh,051h; 2083
DB 00Ah,0d5h,046h; 2084
DB 054h,0dAh,0BAh; 2085
DB 004h,0B6h,04eh; 2086
DB 00Ah,057h,043h; 2087
DB 045h,027h,038h; 2088
DB 00dh,026h,04Ah; 2089
DB 08eh,093h,03eh; 2090
DB 00dh,052h,052h; 2091
DB 00dh,0AAh,047h; 2092
DB 066h,0B5h,03Bh; 2093
DB 005h,06dh,04fh; 2094
DB 004h,0Aeh,045h; 2095
DB 04Ah,04eh,0B9h; 2096
DB 00Ah,04dh,04Ch; 2097
DB 00dh,015h,041h; 2098
DB 02dh,092h,0B5h; 2099
DB 00dh,053h,049h; 2100
;以下子程序用于从当前公历日期,推算星期,
;入口:time_yeAr,time_month ,time_date ,定义公历年月日,BCD 码,其中月的
;BIT7 表示世纪,0 表示20 世纪,1 表示19 世纪,与PCF8563 一致
;出口 time_week, 0-6 表示星期日-星期六,与PCF8563 一致,程序不改变入口数据
;使用资源:ACC,B,psw,Byte1,Byte2,Byte3
GetWeek: MOV A,time_yeAr
MOV B,#16
DIV AB
MOV Byte1,B
MOV B,#10
MUL AB
ADD A,Byte1
MOV Byte1,A ;Byte1=年
MOV A,time_month
JB ACC.7,getw02
- 14 -
MOV A,#100
ADD A,Byte1
MOV Byte1,A ;20世纪年+100
MOV A,time_month
CLR ACC.7
getw02: JNB ACC.4,getw04
ADD A,#10
CLR ACC.4
getw04: MOV Byte2,A ;Byte2=月
MOV A,time_date
MOV B,#16
DIV AB
MOV Byte3,B
MOV B,#10
MUL AB
ADD A,Byte3
MOV Byte3,A ;Byte3=日
MOV A,Byte1;
ANL A,#03h
JNZ getw10 ;非闰年转移
MOV A,Byte2
CJNE A,#3,getw06
getw06: JNC getw10 ;月大于2 转移
DEC Byte3 ;份小于等于2,又是闰年,日减1
getw10: MOV A,Byte2;
LCALL get_CorreCt ;取月校正表数据
ADD A,Byte1
MOV B,#7
DIV AB ;B放年加校正日数之和后除7 的余数不先做这一步
;有可能数据溢出
MOV A,Byte1
ANL A,#0fCh
RR A
RR A ;以上年除4 即闰年数
ADD A,B
ADD A,Byte3
MOV B,#7
DIV AB
MOV time_week,B
RET
get_COrreCt:
MOVC A,@A+PC
RET
DB 0,3,3,6,1,4,6,2,5,0,3,5

上一页  [1] [2] [3] 


本文关键字:单片机  51单片机单片机-工控设备 - 51单片机