⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clock.txt

📁 公农历转换 用51 单片机实现公历与农历星期的转换
💻 TXT
📖 第 1 页 / 共 2 页
字号:
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: 
;公历年对应的农历数据,每年三字节, 

- 9 - 
;格式第一字节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 

- 10 - 
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 

- 11 - 
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 

- 12 - 
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 

- 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,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 

- 14 - 
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 


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -