打印

再来麻烦斑竹,万年历

[复制链接]
1674|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
zjw5000|  楼主 | 2009-5-21 14:52 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
再来麻烦斑竹,不知道有没有4位机万年历的相关资料或者代码?
沙发
warm_ice| | 2009-5-22 10:07 | 只看该作者

这样

4bit MCU 萬年歷程序實現
一>                ROM資源規劃
;OSC: 32768
        list        P = 6613
        romsize = 4096
        include                OS_cfg.inc        
        include                Ram_SH6613D.inc
        include                Ram_User.inc
        org                000h
;interrupt entrance        
        jmp                POWERON
        jmp                ISR_EXT
        jmp                ISR_TIMER0
        jmp                ISR_BT
        jmp                ISR_PORT
;bank0 rom document list
        org                005h
         include                 Table.asm        //程序表格
        include                isr.asm        //中斷函數
           include                 main.asm        //主函數
        jmp                Error        //鼠標右鍵這里可以察看ROM Bank0區所使用的代碼量
;bank1 rom document list        
        org                0800h        
        jmp                Error        //鼠標右鍵這里可以察看ROM Bank1所使用的代碼量
        end
;-----------------------------------------End-----------------------------------------------
二>    RAM資源規劃
USERRAMBEGIN                        EQU        020h
USERRAMEND                        EQU        1ffh
//注意:四位機開發需要定義一些局部變量,好比C語言里面通常定義的i,j,k
//          中斷和主循環不允許沖突,所以為主函數定義了一些局部變量,為中斷函數也定義了一些局部變量
//          可以根據需要定義局部臨時變量的個數
;==========================================================================================
;                                主函數局部臨時變量寄存器        Part1
WorkingRegStartAddress        EQU        USERRAMBEGIN
WorkingRegLength                EQU        6
zWk0                        EQU        WorkingRegStartAddress+0 ;main process work register
zWk1                        EQU        WorkingRegStartAddress+1 ;main process work register
zWk2                        EQU        WorkingRegStartAddress+2 ;main process work register
zWk3                        EQU        WorkingRegStartAddress+3 ;main process work register
zWk4                        EQU        WorkingRegStartAddress+4 ;main process work register
zWk5                        EQU        WorkingRegStartAddress+5 ;main process work register
;==========================================================================================
;                                interrupt registers
IntRegStartAddress                EQU        WorkingRegStartAddress+WorkingRegLength
IntRegLength                EQU        9
zIEBackup                        EQU        IntRegStartAddress+0                        //IE現場保護
zIntFlag                        EQU        IntRegStartAddress+1                        //中斷標記
//bit3:
//bit2: 1秒標記,更新RTC請求
//bit1:
//bit0:
zIntWk0                        EQU        IntRegStartAddress+2                //中斷里面的局部臨時變量寄存器
zIntWk1                        EQU        IntRegStartAddress+3
zIntWk2                        EQU        IntRegStartAddress+4
zIntWk3                        EQU        IntRegStartAddress+5
zIntWk4                        EQU        IntRegStartAddress+6
zIntWk5                        EQU        IntRegStartAddress+7
zAcc                        EQU        IntRegStartAddress+8                //ACC現場保護
;==========================================================================================
;                                RTC 寄存器
ClkRegStartAddress                EQU        IntRegStartAddress + IntRegLength
ClkRegLength                EQU        12                                        //12個RAM
zClk_second                        EQU        ClkRegStartAddress+0                //hex
zClk_minute                        EQU        ClkRegStartAddress+2                //hex
zClk_hour                                EQU        ClkRegStartAddress+4                //hex
zClk_day                                EQU        ClkRegStartAddress+6                //hex
zClk_month                        EQU        ClkRegStartAddress+8                //hex
zClk_year                                EQU        ClkRegStartAddress+9                //hex
zClk_dow                                EQU        ClkRegStartAddress+11                 //hex
;==========================================================================================
;                                主函數局部臨時變量寄存器        Part2
nTemper_Temp                        EQU        0x80
三>                RTC處理程序,其余程序略
;=====================================================================================
//                                月份的天數表格
MonthOfYearTab:                
        TJMP                 
        rtnw        29+1                ;閏月
        rtnw        31+1                ;1月
        rtnw        28+1                ;2月
        rtnw        31+1                ;3月
        rtnw        30+1                ;4月
        rtnw        31+1                ;5月
        rtnw        30+1                ;6月
        rtnw        31+1                ;7月
        rtnw        31+1                ;8月
        rtnw        30+1                ;9月
        rtnw        31+1                ;10月
        rtnw        30+1                ;11月
        rtnw        31+1                ;12月
MonthOfYearTab_ACC                EQU                (MonthOfYearTab+1)&0fh
MonthOfYearTab_TBR                EQU                ((MonthOfYearTab+1)>>4)&0fh
;=====================================================================================
//                                 月份的禮拜表格
MonthOfWeekTab:                
        TJMP                        
        rtnw        0                ;1
        rtnw        3                ;2
        rtnw        3                ;3
        rtnw        6                ;4
        rtnw        1                ;5
        rtnw        4                ;6
        rtnw        6                ;7
        rtnw        2                ;8
        rtnw        5                ;9
        rtnw        0                ;10
        rtnw        3                ;11
        rtnw        5                ;12
MonthOfWeekTab_ACC                        EQU                (MonthOfWeekTab+1)&0fh
MonthOfWeekTab_TBR                        EQU                ((MonthOfWeekTab+1)>>4)&0fh
;=====================================================================================
;                        

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

19

主题

145

帖子

0

粉丝