3988|4

316

帖子

1

TA的资源

纯净的硅(中级)

楼主
 

大家来一块把这个汇编翻译成C? [复制链接]

;-------------------------------------------------------------------------------
; int SetRTCYEAR(int year)
; year will be set in the RTCYEAR register
; return value is read back from the RTCYEAR register
; Works only in calendar mode (RTCMODE = 1)
; argument year is in R12
; return value is in R12
            ORG     0x5C00
            nop
            ALIGN 5

SetRTCYEAR  nop
            nop
            nop
            nop
            dint           
            nop
            nop
            nop           
            mov.w   R12,&RTCYEAR            ; Set RTCYEAR to year        
            nop
            nop
            mov.w   &RTCYEAR,R12            ; Return value
            eint
            reta
;-------------------------------------------------------------------------------
; int SetRTCMON(int month)
; month will be set in the RTCMON register
; Workaround requires to write 16 bits into RTCDATE
; return value is read back from the RTCMON register
; argument month is in R12
; return value is in R12
SetRTCMON   push.w  R5                      ; push R5
            mov.b   &RTCDAY, R5             ; read RTCDAY into R5
            swpb    R12                     ; R12 holds month - swap lower and upper byte
            bis.w   R12, R5                 ; combine read RTCDAY and new RTCMON
            dint
            nop
            mov.w   R5,&RTCDATE             ; write to RTCDATE       
            nop
            nop
            nop
            nop
            eint
            mov.b   &RTCMON,R12             ; Read RTCMON register
            pop.w   R5                      ; pop R5
            reta
;-------------------------------------------------------------------------------       
; int SetRTCDAY(int day)
; day will be set in the RTCDAY register
; Workaround requires to write 16 bits into RTCDATE
; return value is read back from the RTCDAY register
; argument day is in R12
; return value is in R12
            nop
            nop
            nop
            nop
            nop
            nop
            nop
            nop
            nop
            nop
            nop
            nop
SetRTCDAY                                   ; R12 holds day in lower byte
            push.w  R5                      ; push R5
            mov.b   &RTCMON, R5             ; read RTCMON into lower byte of R5
            swpb    R5                      ; month is now in higher byte of R5
            bic.w   #00FFh, R5              ; clear lower byte of R5
            bis.w   R12, R5                 ; combine read RTCDAY and new RTCMON
            dint
            nop
            mov.w   R5,    &RTCDATE            ; write to RTCDATE       
            nop
            eint
            mov.b   &RTCDAY, R12            ; Read RTCDAY register
            pop.w   R5                      ; pop R5
            reta
;-------------------------------------------------------------------------------   
; int SetRTCDOW(int dow)
; dow will be set in the RTCDOW register
; Workaround requires to write 16 bits into RTCTIM1
; return value is read back from the RTCDOW register
; argument dow is in R12
; return value is in R12
SetRTCDOW   push.w  R5                      ; push R5
            mov.b   &RTCHOUR, R5            ; read RTCHOUR into R5
            swpb    R12                     ; R12 holds dow - swap lower and upper byte
            bis.w   R12, R5                 ; combine read RTCHOUR and new RTCDOW
            dint
            nop
            mov.w   R5,&RTCTIM1             ; write to RTCTIM1       
            nop
            eint
            mov.b   &RTCDOW, R12            ; Read RTCDOW register
            pop.w   R5                      ; pop R5
            reta
;-------------------------------------------------------------------------------   
; int SetRTCHOUR(int hour)
; hour will be set in the RTCHOUR register
; Workaround requires to write 16 bits into RTCTIM1
; return value is read back from the RTCHOUR register
; argument hour is in R12
; return value is in R12
SetRTCHOUR                                  ; R12 holds day in lower byte
            push.w  R5                      ; push R5
            mov.b   &RTCDOW,R5              ; read RTCDOW into lower byte of R5
            swpb    R5                      ; dow is now in higher byte of R5
            bis.w   R12, R5                 ; combine read RTCDOW and new RTCHOUR
            dint
            nop
            nop
            mov.w   R5,&RTCTIM1             ; write to RTCTIM1       
            nop
            eint
            mov.b   &RTCHOUR, R12           ; Read RTCHOUR register
            pop.w   R5                      ; pop R5
            reta
;-------------------------------------------------------------------------------   
; int SetRTCMIN(int min)
; min will be set in the RTCMIN register
; Workaround requires to write 16 bits into RTCTIM0
; return value is read back from the RTCDOW register
; argument min is in R12
; return value is in R12
SetRTCMIN   push.w  R5                      ; push R5
            mov.b   &RTCSEC, R5             ; read RTCSEC into R5
            swpb    R12                     ; R12 holds min - swap lower and upper byte
            bis.w   R12, R5                 ; combine read RTCMIN and new RTCSEC
            dint
            nop
            mov.w   R5,&RTCTIM0             ; write to RTCTIM0
            nop
            eint
            mov.b   &RTCMIN, R12            ; Read RTCDOW register
            pop.w   R5                      ; pop R5
            reta
;-------------------------------------------------------------------------------   
; int SetRTCSEC(int sec)
; sec will be set in the RTCSEC register
; Workaround requires to write 16 bits into RTCTIM0
; return value is read back from the RTCSEC register
; argument sec is in R12
; return value is in R12
SetRTCSEC                                   ; R12 holds day in lower byte
            push.w  R5                      ; push R5
            mov.b   &RTCMIN, R5             ; read RTCMIN into lower byte of R5
            swpb    R5                      ; min is now in higher byte of R5
            bis.w   R12, R5                 ; combine read RTCMIN and new RTCSEC
            dint
            nop
            nop                             ; WG:
            mov.w   R5,&RTCTIM0             ; write to RTCTIM0       
            nop
            eint
            mov.b   &RTCSEC, R12            ; Read RTCSEC register
            pop.w   R5                      ; pop R5
            reta

最新回复

就指令看,感觉不是430的汇编,reta什么的430的汇编里面没有  详情 回复 发表于 2012-1-5 12:10
 
点赞 关注

回复
举报

316

帖子

1

TA的资源

纯净的硅(中级)

沙发
 
;-------------------------------------------------------------------------------   


; Read the RTC registers RTCTIM0
; return the values
GetRTCTIM0
            mov.w   &RTCTIM0,R12
            reta

; Read the RTC register RTCTIM1
; return the values
GetRTCTIM1
            mov.w   &RTCTIM1,R12
            reta


; Read the RTC register RTCDATE
; return the values
GetRTCDATE
            mov.w   &RTCDATE,R12
            reta


; Read the RTC registers RTCYEAR
; return the values
GetRTCYEAR
            mov.w   &RTCYEAR,R12
            reta

; Read the RTC register RTCMON
; return the values
GetRTCMON
            mov.b   &RTCMON,R12
            reta

; Read the RTC register RTCDOW
; return the values
GetRTCDOW
            mov.b   &RTCDOW,R12
            reta


; Read the RTC register RTCDOW
; return the values
GetRTCDAY
            mov.b   &RTCDAY,R12
            reta

; Read the RTC register RTCDOW
; return the values
GetRTCHOUR
            mov.b   &RTCHOUR,R12
            reta

; Read the RTC register RTCDOW
; return the values
GetRTCMIN
            mov.b   &RTCMIN,R12
            reta

; Read the RTC register RTCDOW
; return the values
GetRTCSEC
            mov.b   &RTCSEC,R12
            reta

            end
 
 

回复

2002

帖子

24

TA的资源

五彩晶圆(高级)

板凳
 
汇编是和MCU相关的,不同的MCU汇编指令不太一样,所以楼主应该把MCU型号和汇编指令表贴出来才会有高人帮你吧
 
 
 

回复

1634

帖子

0

TA的资源

裸片初长成(高级)

4
 
原帖由 shower.xu 于 2012-1-5 09:23 发表 汇编是和MCU相关的,不同的MCU汇编指令不太一样,所以楼主应该把MCU型号和汇编指令表贴出来才会有高人帮你吧
这是PIC
 
 
 

回复

5015

帖子

13

TA的资源

裸片初长成(初级)

5
 
就指令看,感觉不是430的汇编,reta什么的430的汇编里面没有
 
 
 

回复
您需要登录后才可以回帖 登录 | 注册

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/8 下一条

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表