小Y

小Y

0个粉丝

4

问答

0

专栏

2

资料

小Y  发布于  2008-08-24 12:38:49
采纳率 0%
4个问答
4988

万年历代码 用51单片机实现.

 

[code]sec11 equ 10h sec12 equ 11h min11 equ 12h min12 equ 13h hour11 equ 14h hour12 equ 15h day11 equ 16h day12 equ 17h month11 equ 18h month12 equ 19h year11 equ 1ah year12 equ 1bh year13 equ 1ch year14 equ 1dh TEMP EQU 1EH N_DAY EQU 1FH shu2 equ 20h adress2 equ 21h ADRESS1 EQU 23H SHU1 EQU 24H SHU3 EQU 25H TEMP11 EQU 26H TEMP12 EQU 27H N_DAY11 EQU 28H N_DAY12 EQU 29H N_MONTH11 EQU 2AH N_MONTH12 EQU 2BH N_MONTH EQU 2CH huan equ 2dh SCLK bit 90h io bit 91h RST bit 92h sec data 60h min data 61h hour data 62h date data 63h month data 64h day data 65h

year1 DATA 66H year2 data 67h

int_min equ 68h int_hour equ 69h int_date equ 6ah int_month equ 6bh int_year1 equ 6ch int_day equ 6dh

start_year EQU 01; 定义查询表起始年份,01--199 表示1901-2099 年 ;以下三单元为需转换的公历日期是子程序的入口数据 time_year DATA 66h time_month DATA 64h ;BIT7 表示世纪,为1 表示19 世纪,为0 表示20 世纪 time_date DATA 63h ;以下三单元存转换后农历日期与入口单元重叠,如要保留入口信息,请重定义出口地址 CONvert_yeAr DATA 33h CONvert_mONth DATA 34h ;BIT7 为1 表示闰月 CONvert_dAte DATA 35h temp_Byte1 DATA 37h temp_Byte2 DATA 38h temp_Byte3 DATA 39h temp_Byte4 DATA 3Ah temp_Byte5 DATA 3Bh time_week DATA 65h ;星期天出口 ;以下为公历转农历子程序

org 0000h

mov p0,#0ffh mov 6eh,#00h mov int_min,#59h mov int_hour,#23h mov int_date,#12h mov int_month,#11h mov int_year1,#04h mov int_day,#07h mov temp,#00h mov year2,#20h MOV SP,#74H

;DS1302读写程序 ;**

 lcall  init

start: mov 70h,hour mov 71h,min ;mov day,time_week mov r0,#sec mov r7,#7 setb psw.5 lcall rwrtc lcall kEY

   LCALL  CONvert
   lcall  GetWeek
   LCALL  TRUN
    ;LCALL  DINGSHI
   LCALL  DISP1
   LCALL  DISP3

   ljmp  start

rwrtc: mov b,#10000001b jb psw.5,rwrtc1 mov b,#10000000b rwrtc1:clr sclk nop setb rst mov r6,#8 mov a,b rwrtc2:clr sclk rrc a mov io,c nop setb sclk djnz r6,rwrtc2 mov r6,#8 jnb psw.5,rwrtc4 rwrtc3:clr sclk nop mov c,io rrc a setb sclk djnz r6,rwrtc3 mov @r0,a sjmp rwrtc6 rwrtc4:mov a,@r0 rwrtc5:clr sclk rrc a mov io,c nop setb sclk djnz r6,rwrtc5 rwrtc6:inc r0 mov a,b add a,#02h mov b,a clr rst nop clr sclk djnz r7,rwrtc1 RET

WRRTC: CLR SCLK NOP SETB RST NOP NOP MOV R7,#2 WRRTC1: MOV R6,#8 MOV A,@R0 CLR C wrrtc2: CLR SCLK RRC A MOV IO,C nop SETB SCLK DJNZ R6,WRRTC2 INC R0 djnz r7,wrrtc1 clr rst nop clr sclk ret

init: CLR SCLK CLR RST MOV SEC,#10001110b MOV MIN,#00000000b MOV R0,#SEC LCALL wrrtc MOV SEC,#10010000b MOV MIN,#10100101b MOV R0,#SEC LCALL wrrtc MOV R0,#SEC MOV SEC,#10000000b MOV MIN,#00000000b lcall writer_f lcall writer_sh lcall writer_date lcall writer_yue lcall writer_nian ret

writer_f:LCALL wrrtc mov r0,#sec mov sec,#82h mov min,int_min lcall wrrtc ret

writer_sh:mov sec,#10000100b mov min,int_hour mov r0,#sec lcall wrrtc ret writer_yue:mov sec,#88h mov min,int_month mov r0,#sec lcall wrrtc ret writer_nian:mov sec,#8ch mov min,int_year1 mov r0,#sec lcall wrrtc ret writer_date:mov sec,#86h mov min,int_date mov r0,#sec lcall wrrtc RET

;****0*** ;BCD转换 TRUN: MOV A,SEC MOV B,#10H DIV AB MOV SEC12,A MOV SEC11,B

  MOV  A,MIN
  MOV  B,#10H
  DIV   AB
  MOV  MIN12,A
  MOV  MIN11,B

  MOV  A,HOUR
  MOV  B,#10H
  DIV  AB
  MOV  HOUR12,A
  MOV  HOUR11,B

  MOV  A,date
  MOV  B,#10H
  DIV  AB
  MOV  DAY12,a
  MOV  DAY11,b

  MOV  A,MONTH
  MOV  B,#10H
  DIV  AB
  MOV  MONTH12,A
  MOV  MONTH11,B

  MOV  A,year1
  MOV  B,#10H
  DIV  AB
  MOV  YEAR12,A
  MOV  YEAR11,B

  MOV  A,YEAr2
  MOV  B,#10H
  DIV  AB
  MOV  YEAR14,A
  MOV  YEAR13,b
  MOV  A,35h
  MOV  B,#10H
  DIV  AB
  MOV  N_DAY12,A
  MOV  N_day11,B

  MOV  A,34h
  MOV  B,#10H
  DIV  AB
  MOV  N_MONTH12,A
  MOV  N_MONTH11,B

  MOV  A,TEMP
  MOV  B,#10H
  DIV  AB
  MOV  TEMP12,A
  MOV  TEMP11,B

      RET

;延时程序 ;****

DEALY:MOV R5,#01h DEL1: MOV R2,#07dH DEL2:NOP NOP DJNZ R2,DEL2 DJNZ R5,DEL1 RET ;显示程序 ;*** DENG:MOV P2,#0FFH MOV A,#00H MOV SBUF,A JNB TI,$ CLR TI

 MOV  P2,ADRESS2
 MOV  A,SHU2
 MOV  SBUF,A
 JNB  TI,$
 CLR  TI

 MOV  A,#00H
 MOV  SBUF,A
 JNB   TI,$
 CLR  TI
 LCALL  DEALY
 MOV  P2,#0FFH
 RET

DENG1:MOV P2,#0FFH MOV A,SHU1 MOV SBUF,A JNB TI,$ CLR TI

 MOV  P2,#0FFH
 mov  a,#00h
 MOV  SBUF,a
 JNB  TI,$
 CLR TI

 MOV  P2,ADRESS1
 MOV  A,SHU3
 MOV  SBUF,A
 JNB  TI,$
 CLR  TI
 LCALL  DEALY
 RET

DISP1: MOV R3,#0bFH MOV R4,#06H MOV R0,#10H

DISP2:MOV A,@R0 MOV DPTR,#TAB MOVC A,@A+DPTR MOV SHU2,A inc r0 MOV A,R3 Rr A MOV R3,A MOV ADRESS2,A LCALL DENG DJNZ R4,DISP2 mov a,day mov dptr,#xing movc a,@a+dptr mov shu2,a mov adress2,#0bfh lcall deng RET DISP3:MOV R3,#0FEH MOV R4,#08H

  MOV  R1,#24H

DISP4:MOV A,@R0 MOV DPTR,#TAB MOVC A,@A+DPTR MOV SHU3,A INC r0 MOV A,@R1 MOVC A,@A+DPTR MOV SHU1,A INC R1 MOV A,R3 RR A MOV R3,A MOV ADRESS1,A LCALL DENG1 DJNZ R4,DISP4 RET ;****

;键盘程序

;**** key:jb p1.3,s2

s1: lcall disp1 lcall disp3 jnb p1.3,s1 mov a,6eh inc a mov 6eh,a dianliang1:cjne a,#01h,dianliang2 mov p0,#0feh ret dianliang2:cjne a,#02h,dianliang3 mov p0,#0fch ret dianliang3:cjne a,#03h,dianliang4 mov p0,#0f8h ret dianliang4:cjne a,#04h,dianliang5 mov p0,#0f0h ret dianliang5:cjne a,#05h,mie mov p0,#0e0h ret mie:cjne a,#06h,out mov 06eh,#00h mov p0,#0ffh ret

out: ret s2:jb p3.3,s3 shang:acall disp1 acall disp3 jnb p3.3,shang mov a,temp inc a mov temp,a cjne a,#01h,out mov a,6eh cjne a,#05h,out mov r0,#sec mov sec,#0c0h mov min,70h lcall wrrtc mov r0,#sec mov sec,#0c2h mov min,71h lcall wrrtc ret

s3: jb p3.2,out MOV R7,#05H xian: MOV 6FH,R7 lcall disp1 lcall disp3 MOV R7,6FH DJNZ R7,XIAN jia: mov a,6eh cjne a,#01h,pan2 LJMP jia_SH pan2:cjne a,#02h,pan3 LJMP jia_F pan3:cjne a,#03h,pan4 LJMP jia_nian pan4:cjne a,#04h,pan5 ljmp jia_yue pan5:cjne a,#05h,out ljmp jia_ri

 ret

jia_f:mov a,int_min inc a da a mov int_min,a cjne a,#60h,diao_jf mov int_min,#00h diao_jf: lcall writer_f lcall chxie_ds1302 ret jia_sh: mov a,int_hour inc a da a mov int_hour,a cjne a,#24h,diao_jsh mov int_hour,#00h diao_jsh: lcall writer_sh lcall chxie_ds1302

     ret

jia_ri:mov a,int_date inc a da a mov int_date,a MOV A,MONTH clr c mov R7,#0f8h addc a,R7 jc hou qian: mov a,month mov b,#02h div ab mov a,b rrc a jc dayue xiaoyue:mov a,int_date cjne a,#31h,diao_jri mov int_date,#01h sjmp diao_jri dayue:mov a,int_date cjne a,#32h,diao_jri mov int_date,#01h sjmp diao_jri hou: mov a,month mov b,#02h div ab mov a,b rrc a jc xiaoyue sjmp dayue

diao_jri: lcall writer_date lcall chxie_ds1302 ret jia_yue:mov a,int_month inc a da a mov int_month,a cjne a,#13h,diao_jyue mov int_month,#01h diao_jyue: lcall writer_yue lcall chxie_ds1302 ret jia_nian:mov a,int_year1 inc a da a mov int_year1,a cjne a,#99h,diao_jnian mov int_year1,#00h diao_jnian: lcall writer_nian lcall chxie_ds1302 ret

;** ;公农历算法 ;*****

CONvert: MOV A,time_year ;将年月日转化为HEX 格式 MOV B,#16 DIV AB MOV CONvert_yeAr,B MOV B,#10 MUL AB ADD A,CONvert_yeAr MOV CONvert_yeAr,A MOV A,time_month MOV C,ACC.7 MOV f0,C ;f0暂存世纪标志,仅用于数据表定位 CLR ACC.7 JNB ACC.4,CON_02

CLR ACC.4 ;ACC.4 为1 表示大于10 月 ADD A,#10 CON_02: MOV CONvert_mONth,A MOV A,time_date MOV B,#16 DIV AB MOV CONvert_dAte,B MOV B,#10 MUL AB ADD A,CONvert_dAte MOV CONvert_dAte,A MOV dptr,#mONth_dAtA ;以下定位本年数据在表格中的位置 MOV A,CONvert_yeAr JB f0,CON_06 ;当前为19 世纪年跳转 ADD A,#100 ;从19 世纪起定义表格起始年,20 世纪要加100 年 CON_06: CLR C SUBB A,#stArt_yeAr MOV B,#3 ;表格每年3 字节 MUL AB ADD A,dpl MOV dpl,A MOV A,B ADDC A,dph MOV dph,A MOV A,#2 MOVC A,@A+dptr ;读本年表格最后一字节(春节日期) CLR ACC.7 ;ACC.7 是闰年第13 个月大小,在此不用 MOV B,#32 DIV AB MOV temp_Byte1,A ;春节月份 MOV temp_Byte2,B ;春节日 ; 以下计算当前日期距元旦天数 MOV temp_Byte3,#0 ;设距元旦天数高位为0 MOV A,CONvert_mONth CJNE A,#10,CON_08 CON_08: JC CON_09 ;9月以前日子数小于256 天,高字节为0(9 月份过去的整月为8 个月) MOV temp_Byte3,#1 CON_09: MOV A,CONvert_yeAr ANL A,#03h ;ACC 为除4 的余数 JNZ CON_10 ;转常年处理 ; 年除4 余数为0 是闰年 MOV A,CONvert_mONth

LCALL get_ruN_dAys_lOw ;取得闰年过去月的天数的低字节 SJMP CON_12 CON_10: MOV A,CONvert_mONth LCALL get_dAys_lOw ;取得常年过去月的天数的低字节 CON_12: MOV B,CONvert_dAte DEC B ;因为日期从1 日起,而不是0 日起 ADD A,B ;过去的整月天数加当月天数 MOV temp_Byte4,A JNC CON_14 INC temp_Byte3 ;temp_Byte3,temp_Byte4 分别为公历年过去的天数的高低字节 ; 以下求春节距元旦天数,因肯定小于256 天所以只用一字节表示 CON_14: MOV A,temp_Byte1 LCALL get_dAys_lOw ;春节不会在3 月份,不用考虑闰年 DEC A ;因为日期从1 日起 ADD A,temp_Byte2 MOV temp_Byte5,A ;temp_Byte5,为春节距元旦天数 MOV A,CONvert_mONth CJNE A,temp_Byte1,CON_20 ;转换月与春节月比较 MOV A,CONvert_dAte CJNE A,temp_Byte2,CON_20 ;转换日与春节日比较 CON_20: JC CON_22 LJMP CON_60 ;当前日大于等于春节日期,公历年与农历年同年份 CON_22: MOV A,CONvert_yeAr ;不到春节,农历年比公历年低一年 JNZ CON_24 MOV A,#100 ;年有效数0-99 CON_24: DEC A MOV CONvert_yeAr,A MOV A,dpl CLR C SUBB A,#3 MOV dpl,A JNC CON_26 DEC dph ;表格指针指向上一年 CON_26: MOV A,temp_Byte5 CLR C SUBB A,temp_Byte4 MOV temp_Byte3,A ;temp_Byte3 中为当前日离春节的天数 MOV CONvert_mONth,#12 ;农历月为12 月 CLR f0 ;1901-2099 年没有闰12 月,清闰月标志 CLR A MOVC A,@A+dptr

ANL A,#0f0h SWAP A; MOV temp_Byte4,A ;temp_Byte4 中为闰月 JZ CON_30 ;没有闰月转移 MOV A,#2 ;有闰月,取第13 个月天数 MOVC A,@A+dptr MOV C,ACC.7 MOV A,#1 MOVC A,@A+dptr RLC A ;ACC 中为最后6 个月的大小值 SJMP CON_34 CON_30: MOV A,#1 MOVC A,@A+dptr ;ACC 中为最后6 个月的大小值 CON_34: MOV temp_Byte5,A CON_40: MOV A,temp_Byte5 RRC A MOV temp_Byte5,A

JC CON_42 MOV B,#29 ;小月29 天 SJMP CON_44 CON_42: MOV B,#30 ;大月30 天 CON_44: MOV A,temp_Byte3 CLR C SUBB A,B JZ CON_46 ;正好够减,就是农历日1 日 JNC CON_50 ;不够减一月天数,结束农历月调整 CPL A ;求补取绝对值 INC A CON_46: INC A ;加1 即为农历日 MOV B,#10 ;转换并保存农历日,月,年 DIV AB SWAP A ORL A,B MOV CONvert_dAte,A MOV A,CONvert_mONth MOV B,#10 DIV AB SWAP A ORL A,B MOV C,f0 MOV ACC.7,C MOV CONvert_mONth,A

MOV A,CONvert_yeAr MOV B,#10 DIV AB SWAP A ORL A,B MOV CONvert_yeAr,A RET ;结束转换 CON_50: MOV temp_Byte3,A ;temp_Byte3 存减去一月后的天数 JB f0,CON_52 ;是闰月,前推一月,月份不减 DEC CONvert_mONth; CON_52: MOV A,CONvert_mONth CJNE A,temp_Byte4,CON_54 CPL f0 ;当前月与闰月相同,更改闰月标志 CON_54: SJMP CON_40 CON_60: MOV A,temp_Byte4 ;春节日小于当前日,农历年同公历年 CLR C SUBB A,temp_Byte5 MOV temp_Byte4,A JNC CON_62 DEC temp_Byte3 ;temp_Byte3 temp_Byte4 中为公历日离春节的天数 CON_62: MOV CONvert_mONth,#1 ;农历月为1 月 CLR A MOVC A,@A+dptr MOV temp_Byte5,A ANL A,#0f0h SWAP A; XCH A,temp_Byte5 ;temp_Byte5 中为闰月,ACC 为当年农历表第一字节 CLR f0 ;第一个月肯定不是闰月 ANL A,#0fh MOV temp_Byte1,A MOV A,#1 MOVC A,@A+dptr MOV temp_Byte2,A ANL A,#0f0h ORL A,temp_Byte1 SWAP A MOV temp_Byte1,A MOV A,#2 MOVC A,@A+dptr MOV C,ACC.7 MOV A,temp_Byte2 ANL A,#0fh

SWAP A MOV ACC.3,C; MOV temp_Byte2,A ;以上temp_Byte1,temp_Byte2 各BIT 存农历年大小 CON_70: MOV A,temp_Byte2 RLC A MOV temp_Byte2,A MOV A,temp_Byte1 RLC A MOV temp_Byte1,A JC CON_72 MOV B,#29 ;小月29 天处理 SJMP CON_74 CON_72: MOV B,#30 ;大月30 天 CON_74: MOV A,temp_Byte4 CLR C SUBB A,B JNC CON_78 ;低字节够减跳转 MOV B,A ;低字节不够减, B 暂存减后结果, MOV A,temp_Byte3 JZ CON_76 ;高字节为0,不够减 DEC temp_Byte3 MOV temp_Byte4,B SJMP CON_80 CON_76: MOV A,temp_Byte4 ;不够减结束月调整 LJMP CON_46 ;转日期加1 后,处理并保存转换后农历年月日 CON_78: MOV temp_Byte4,A ;temp_Byte3 temp_Byte4 天数为减去一月后天数 CON_80: MOV A,CONvert_mONth CJNE A,temp_Byte5,CON_82 CPL f0 ;当前月与闰月相同,更改闰月标志 JNB f0,CON_82 ;更改标志后是非闰月,月份加1 SJMP CON_70 CON_82: INC CONvert_mONth; SJMP CON_70 get_dAys_lOw: MOVC A,@A+PC ;取得常年过去月的天数的低字节 RET DB 0,31,59,90,120,151,181,212,243,17,48,78 get_ruN_dAys_lOw: MOVC A,@A+PC ;取得闰年过去月的天数的低字节 RET DB 0,31,60,91,121,152,182,213,244,18,49,79 mONth_dAtA: ;公历年对应的农历数据,每年三字节,

;格式第一字节BIT7-4 位表示闰月月份,值为0 为无闰月,BIT3-0 对应农历第1-4 月的大小 ;第二字节BIT7-0 对应农历第5-12 月大小,第三字节BIT7 表示农历第13 个月大小 ;月份对应的位为1 表示本农历月大(30 天),为0 表示小(29 天). ;第三字节BIT6-5 表示春节的公历月份,BIT4-0 表示春节的公历日期 DB 004h,0Aeh,053h; 1901; DB 00Ah,057h,048h; 1902 DB 055h,026h,0Bdh; 1903 DB 00dh,026h,050h; 1904 DB 00dh,095h,044h; 1905 DB 046h,0AAh,0B9h; 1906 DB 005h,06Ah,04dh; 1907 DB 009h,0Adh,042h; 1908 DB 024h,0Aeh,0B6h; 1909 DB 004h,0Aeh,04Ah; 1910 DB 06Ah,04dh,0Beh; 1911 DB 00Ah,04dh,052h; 1912 DB 00dh,025h,046h; 1913 DB 05dh,052h,0BAh; 1914 DB 00Bh,054h,04eh; 1915 DB 00dh,06Ah,043h; 1916 DB 029h,06dh,037h; 1917 DB 009h,05Bh,04Bh; 1918 DB 074h,09Bh,0C1h; 1919 DB 004h,097h,054h; 1920 DB 00Ah,04Bh,048h; 1921 DB 05Bh,025h,0BCh; 1922 DB 006h,0A5h,050h; 1923 DB 006h,0d4h,045h; 1924 DB 04Ah,0dAh,0B8h; 1925 DB 002h,0B6h,04dh; 1926 DB 009h,057h,042h; 1927 DB 024h,097h,0B7h; 1928 DB 004h,097h,04Ah; 1929 DB 066h,04Bh,03eh; 1930 DB 00dh,04Ah,051h; 1931 DB 00eh,0A5h,046h; 1932 DB 056h,0d4h,0BAh; 1933 DB 005h,0Adh,04eh; 1934 DB 002h,0B6h,044h; 1935 DB 039h,037h,038h; 1936 DB 009h,02eh,04Bh; 1937 DB 07Ch,096h,0Bfh; 1938 DB 00Ch,095h,053h; 1939 DB 00dh,04Ah,048h; 1940

DB 06dh,0A5h,03Bh; 1941 DB 00Bh,055h,04fh; 1942 DB 005h,06Ah,045h; 1943 DB 04Ah,0Adh,0B9h; 1944 DB 002h,05dh,04dh; 1945 DB 009h,02dh,042h; 1946 DB 02Ch,095h,0B6h; 1947 DB 00Ah,095h,04Ah; 1948 DB 07Bh,04Ah,0Bdh; 1949 DB 006h,0CAh,051h; 1950 DB 00Bh,055h,046h; 1951 DB 055h,05Ah,0BBh; 1952 DB 004h,0dAh,04eh; 1953 DB 00Ah,05Bh,043h; 1954 DB 035h,02Bh,0B8h; 1955 DB 005h,02Bh,04Ch; 1956 DB 08Ah,095h,03fh; 1957 DB 00eh,095h,052h; 1958 DB 006h,0AAh,048h; 1959 DB 07Ah,0d5h,03Ch; 1960 DB 00Ah,0B5h,04fh; 1961 DB 004h,0B6h,045h; 1962 DB 04Ah,057h,039h; 1963 DB 00Ah,057h,04dh; 1964 DB 005h,026h,042h; 1965 DB 03eh,093h,035h; 1966 DB 00dh,095h,049h; 1967 DB 075h,0AAh,0Beh; 1968 DB 005h,06Ah,051h; 1969 DB 009h,06dh,046h; 1970 DB 054h,0Aeh,0BBh; 1971 DB 004h,0Adh,04fh; 1972 DB 00Ah,04dh,043h; 1973 DB 04dh,026h,0B7h; 1974 DB 00dh,025h,04Bh; 1975 DB 08dh,052h,0Bfh; 1976 DB 00Bh,054h,052h; 1977 DB 00Bh,06Ah,047h; 1978 DB 069h,06dh,03Ch; 1979 DB 009h,05Bh,050h; 1980 DB 004h,09Bh,045h; 1981 DB 04Ah,04Bh,0B9h; 1982 DB 00Ah,04Bh,04dh; 1983 DB 0ABh,025h,0C2h; 1984 DB 006h,0A5h,054h; 1985 DB 006h,0d4h,049h; 1986 DB 06Ah,0dAh,03dh; 1987 DB 00Ah,0B6h,051h; 1988 DB 009h,037h,046h; 1989 DB 054h,097h,0BBh; 1990 DB 004h,097h,04fh; 1991 DB 006h,04Bh,044h; 1992 DB 036h,0A5h,037h; 1993 DB 00eh,0A5h,04Ah; 1994 DB 086h,0B2h,0Bfh; 1995 DB 005h,0ACh,053h; 1996 DB 00Ah,0B6h,047h; 1997 DB 059h,036h,0BCh; 1998

DB 009h,02eh,050h; 1999 DB 00Ch,096h,045h; 2000 DB 04dh,04Ah,0B8h; 2001 DB 00dh,04Ah,04Ch; 2002 DB 00dh,0A5h,041h; 2003 DB 025h,0AAh,0B6h; 2004 DB 005h,06Ah,049h; 2005 DB 07Ah,0Adh,0Bdh; 2006 DB 002h,05dh,052h; 2007 DB 009h,02dh,047h; 2008 DB 05Ch,095h,0BAh; 2009 DB 00Ah,095h,04eh; 2010 DB 00Bh,04Ah,043h; 2011 DB 04Bh,055h,037h; 2012 DB 00Ah,0d5h,04Ah; 2013 DB 095h,05Ah,0Bfh; 2014 DB 004h,0BAh,053h; 2015 DB 00Ah,05Bh,048h; 2016 DB 065h,02Bh,0BCh; 2017 DB 005h,02Bh,050h; 2018 DB 00Ah,093h,045h; 2019 DB 047h,04Ah,0B9h; 2020 DB 006h,0AAh,04Ch; 2021 DB 00Ah,0d5h,041h; 2022 DB 024h,0dAh,0B6h; 2023 DB 004h,0B6h,04Ah; 2024 DB 069h,057h,03dh; 2025 DB 00Ah,04eh,051h; 2026 DB 00dh,026h,046h; 2027 DB 05eh,093h,03Ah; 2028

DB 00dh,053h,04dh; 2029 DB 005h,0AAh,043h; 2030 DB 036h,0B5h,037h; 2031 DB 009h,06dh,04Bh; 2032 DB 0B4h,0Aeh,0Bfh; 2033 DB 004h,0Adh,053h; 2034 DB 00Ah,04dh,048h; 2035 DB 06dh,025h,0BCh; 2036 DB 00dh,025h,04fh; 2037 DB 00dh,052h,044h; 2038 DB 05dh,0AAh,038h; 2039 DB 00Bh,05Ah,04Ch; 2040 DB 005h,06dh,041h; 2041 DB 024h,0Adh,0B6h; 2042 DB 004h,09Bh,04Ah; 2043 DB 07Ah,04Bh,0Beh; 2044 DB 00Ah,04Bh,051h; 2045 DB 00Ah,0A5h,046h; 2046 DB 05Bh,052h,0BAh; 2047 DB 006h,0d2h,04eh; 2048 DB 00Ah,0dAh,042h; 2049 DB 035h,05Bh,037h; 2050 DB 009h,037h,04Bh; 2051 DB 084h,097h,0C1h; 2052 DB 004h,097h,053h; 2053 DB 006h,04Bh,048h; 2054 DB 066h,0A5h,03Ch; 2055 DB 00eh,0A5h,04fh; 2056 DB 006h,0B2h,044h; 2057 DB 04Ah,0B6h,038h; 2058 DB 00Ah,0Aeh,04Ch; 2059 DB 009h,02eh,042h; 2060 DB 03Ch,097h,035h; 2061 DB 00Ch,096h,049h; 2062 DB 07dh,04Ah,0Bdh; 2063 DB 00dh,04Ah,051h; 2064 DB 00dh,0A5h,045h; 2065 DB 055h,0AAh,0BAh; 2066 DB 005h,06Ah,04eh; 2067 DB 00Ah,06dh,043h; 2068 DB 045h,02eh,0B7h; 2069 DB 005h,02dh,04Bh; 2070 DB 08Ah,095h,0Bfh; 2071 DB 00Ah,095h,053h; 2072

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,temp_Byte1,temp_Byte2,temp_Byte3 GetWeek: MOV A,time_yeAr MOV B,#16 DIV AB MOV temp_Byte1,B MOV B,#10 MUL AB ADD A,temp_Byte1 MOV temp_Byte1,A ;temp_Byte1=年 MOV A,time_month JB ACC.7,getw02

MOV A,#100 ADD A,temp_Byte1 MOV temp_Byte1,A ;20世纪年+100 MOV A,time_month CLR ACC.7 getw02: JNB ACC.4,getw04 ADD A,#10 CLR ACC.4 getw04: MOV temp_Byte2,A ;temp_Byte2=月 MOV A,time_date MOV B,#16 DIV AB MOV temp_Byte3,B MOV B,#10 MUL AB ADD A,temp_Byte3 MOV temp_Byte3,A ;temp_Byte3=日 MOV A,temp_Byte1; ANL A,#03h JNZ getw10 ;非闰年转移 MOV A,temp_Byte2 CJNE A,#3,getw06 getw06: JNC getw10 ;月大于2 转移 DEC temp_Byte3 ;份小于等于2,又是闰年,日减1 getw10: MOV A,temp_Byte2; LCALL get_CorreCt ;取月校正表数据 ADD A,temp_Byte1 MOV B,#7 DIV AB ;B放年加校正日数之和后除7 的余数不先做这一步 ;有可能数据溢出 MOV A,temp_Byte1 ANL A,#0fCh RR A RR A ;以上年除4 即闰年数 ADD A,B ADD A,temp_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 xing:db 0FEH,060H,0DAH,0F2H,066H,0B6H,0BEH, TAB:DB 0FCH,060H,0DAH,0F2H,066H DB 0B6H,0BEH,0E0H,0FEH,0F6H chxie_ds1302: mov r0,#sec mov r7,#7 setb psw.5 lcall rwrtc ret dingshi :MOV r0,#70h mov r7,#02h setb psw.5 lcall rwrtc MOV A,70H CJNE A,HOUR,DINGSHI1 RET DINGSHI1:MOV A,71H CJNE A,#MIN,OUT4 CLR P0.6 OUT4 : ret

   END[/code][附件 : 20063322301448417.rar](/resource/download/240000028999 '20063322301448417.rar')

本帖最后由 小Y 于 2008-8-24 12:40 编辑

易百纳技术社区文件: 20063322301448417.rar
下载
我来回答
回答0个
时间排序
认可量排序
易百纳技术社区暂无数据
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
+ 添加网盘链接/附件

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
举报反馈

举报类型

  • 内容涉黄/赌/毒
  • 内容侵权/抄袭
  • 政治相关
  • 涉嫌广告
  • 侮辱谩骂
  • 其他

详细说明

易百纳技术社区