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

📄 cstart.asm

📁 ucos在xc167下的移植源程序
💻 ASM
📖 第 1 页 / 共 3 页
字号:
                CONST.A a15, EBU_BUSCON0
                st.w    [a15], d2
        .endif
        .if @DEF('_BUSCON1_VALUE')
                CONST.D d2, _BUSCON1_VALUE
                CONST.A a15, EBU_BUSCON1
                st.w    [a15], d2
        .endif
        .if @DEF('_BUSCON2_VALUE')
                CONST.D d2, _BUSCON2_VALUE
                CONST.A a15, EBU_BUSCON2
                st.w    [a15], d2
        .endif
        .if @DEF('_BUSCON3_VALUE')
                CONST.D d2, _BUSCON3_VALUE
                CONST.A a15, EBU_BUSCON3
                st.w    [a15], d2
        .endif
        .if @DEF('_BUSCON4_VALUE')
                CONST.D d2, _BUSCON4_VALUE
                CONST.A a15, EBU_BUSCON4
                st.w    [a15], d2
        .endif
        .if @DEF('_BUSCON5_VALUE')
                CONST.D d2, _BUSCON5_VALUE
                CONST.A a15, EBU_BUSCON5
                st.w    [a15], d2
        .endif
        .if @DEF('_BUSCON6_VALUE')
                CONST.D d2, _BUSCON6_VALUE
                CONST.A a15, EBU_BUSCON6
                st.w    [a15], d2
        .endif
        .if @DEF('_EMUAS_VALUE')
                CONST.D d2, _EMUAS_VALUE
                CONST.A a15, EBU_EMUAS
                st.w    [a15], d2
        .endif
        .if @DEF('_EMUBC_VALUE')
                CONST.D d2, _EMUBC_VALUE
                CONST.A a15, EBU_EMUBC
                st.w    [a15], d2
        .endif
        .if @DEF('_EMUCON_VALUE')
                CONST.D d2, _EMUCON_VALUE
                CONST.A a15, EBU_EMUCON
                st.w    [a15], d2
        .endif
        .if @DEF('_EMUBAP_VALUE')
                CONST.D d2, _EMUBAP_VALUE
                CONST.A a15, EBU_EMUBAP
                st.w    [a15], d2
        .endif
        .if @DEF('_EMUOVL_VALUE')
                CONST.D d2, _EMUOVL_VALUE
                CONST.A a15, EBU_EMUOVL
                st.w    [a15], d2
        .endif
        .if @DEF('_SDRMCON0_VALUE')
                CONST.D d2, _SDRMCON0_VALUE
                CONST.A a15, EBU_SDRMCON0
                st.w    [a15], d2
        .endif
        .if @DEF('_SDRMCON1_VALUE')
                CONST.D d2, _SDRMCON1_VALUE
                CONST.A a15, EBU_SDRMCON1
                st.w    [a15], d2
        .endif
        .if @DEF('_SDRMOD0_VALUE')
                CONST.D d2, _SDRMOD0_VALUE
                CONST.A a15, EBU_SDRMOD0
                st.w    [a15], d2
        .endif
        .if @DEF('_SDRMOD1_VALUE')
                CONST.D d2, _SDRMOD1_VALUE
                CONST.A a15, EBU_SDRMOD1
                st.w    [a15], d2
        .endif
        .if @DEF('_SDRMREF0_VALUE')
                CONST.D d2, _SDRMREF0_VALUE
                CONST.A a15, EBU_SDRMREF0
                st.w    [a15], d2
        .endif
        .if @DEF('_SDRMREF1_VALUE')
                CONST.D d2, _SDRMREF1_VALUE
                CONST.A a15, EBU_SDRMREF1
                st.w    [a15], d2
        .endif
        .if @DEF('_BFCON_VALUE')
                CONST.D d2, _BFCON_VALUE
                CONST.A a15, EBU_BFCON
                st.w    [a15], d2
        .endif
        .if @DEF('_BCUCON_VALUE')
                CONST.D d2, _BCUCON_VALUE
                CONST.A a15, BCU_CON
                st.w    [a15], d2
        .endif
        .if @DEF('_F_BCUCON_VALUE')
                CONST.D d2, _F_BCUCON_VALUE
                CONST.A a15, F_BCU_CON
                st.w    [a15], d2
        .endif
        .if @DEF('_S_BCUCON_VALUE')
                CONST.D d2, _S_BCUCON_VALUE
                CONST.A a15, S_BCU_CON
                st.w    [a15], d2
        .endif
        .if @DEF('_EBUCON_VALUE')
                CONST.D d2, _EBUCON_VALUE
                CONST.A a15, EBU_CON
                st.w    [a15], d2
        .endif
        .if @DEF('_MCDBBS_VALUE')
                CONST.D d2, _MCDBBS_VALUE
                CONST.A a15, MCDBBS 
                st.w    [a15], d2
        .endif
.endif

;
;
;       Initialize and clear C variables
;
.if !@DEF('_NO_C_INIT')
        CALL.I  a2,_c_init              ; initialize data
.endif  

;
;       Call a function (assembly label) before main()
;
.if @DEF('_CALL_INIT')
        .extern _CALL_INIT
        CALL.I  a2,_CALL_INIT
.endif  


;
;       Clear argc and argv[] of main()
;
.if !@DEF('_NO_ARG_INIT')
        mov16   d4,#0                   ; argc    == 0
        CONST.A a4,argv_space           ; argv[0] == 0
.endif

;
;       Main default return value is 0
;
.if !@DEF('_NO_EXIT')
        mov16   d2,#0                   ; set default exit value
.endif

;
;       Call C program
;
        CALL.I  a2,main                 ; call main()

;
;       Call C library exit function
;
;       The exit() function causes normal program termination to occur. First, all 
;       functions registered by the atexit() function are called in the reverse 
;       order. Next, all open streams with unwritten buffered data are flushed, all 
;       open streams are closed and all files created by the tmpfile() function are 
;       removed.
;
.if !@DEF('_NO_EXIT')
        mov16   d4,d2                   ; pass return value to exit()
        CALL.I  a2,exit                 ; call exit()
.endif

;
;       The exit() function jumps _exit and a breakpoint is set
;       at _exit by the CrossView debugger to halt execution.
;       
_Exit:
_exit:  debug16                         ; halt the execution if debug mode is enabled  
.include 'sibug_loop_before.inc' 
        loopu   _exit                   ; otherwise loop
;
;       Default trap vectors are resolved from the C-library
;
.if !@DEF('_NO_BTV_INIT')
.if !@DEF('_USERDEFINED_TRAP_0')
        .extern (CODE) _trapmmu
.endif
.if !@DEF('_USERDEFINED_TRAP_1')
        .extern (CODE) _trapprotection
.endif
.if !@DEF('_USERDEFINED_TRAP_2')
        .extern (CODE) _trapinstruction
.endif
.if !@DEF('_USERDEFINED_TRAP_3')
        .extern (CODE) _trapcontext
.endif
.if !@DEF('_USERDEFINED_TRAP_4')
        .extern (CODE) _trapbus
.endif
.if !@DEF('_USERDEFINED_TRAP_5')
        .extern (CODE) _trapassertion
.endif
.if !@DEF('_USERDEFINED_TRAP_6')
        .extern (CODE) _trapsystem
.endif
.if !@DEF('_USERDEFINED_TRAP_7')
        .extern (CODE) _trapnmi
.endif
.endif
;
; 
; 
;--------------------------------------------------------------------------
; Utility subroutines
;--------------------------------------------------------------------------
; function:     _endinit_clear
; input:        None
; output:       Bit ENDINIT in WDTCON0 is cleared
; other registers used:
;               D0, D1, D2, D4, A3, A4 - work register
; description:  Clears the ENDINIT bit in the 
;               WDT_CON0 register in order to disable the 
; write-protection for registers protected 
; via the EndInit feature (ie. WDT_CON1, BTV, 
; BIV, ISP, mod_CLC).
;--------------------------------------------------------------------------
;
        .global _endinit_clear
;
_endinit_clear:
;
; 1st step: Password access (create password and send to WDT_CON0)
;
        CONST.A a3,WDT_CON0             ; get address WDT_CON0
        ld16.w  d0,[a3]                 ; get WDT_CON0 in d0
;
        CONST.A a4,WDT_CON1             ; get address WDT_CON1
        ld16.w  d1,[a4]                 ; get WDT_CON1_WDTDR WDT_CON1_WDTIR
;
        CONST.D d2,0xFFFFFF01   ; mask hardware password 0,1
        and     d0,d2,d0                ; in copy of WDT_CON0 (d0),
        or      d0,d0,#0xF0             ; set WDTHPW1 to 0xF and load
        and     d4,d1,#0x0C             ; copy of WDT_CON1_WDTDR and
        or      d0,d4,d0                ; WDT_CON1_WDTIR (d1)
        st16.w  [a3],d0                 ; set WDT_CON0
;
; 2nd step: Modify access, set the bit ENDINIT to 0 to allow access to
;                       registers: WDT_CON1, BTV, BIV, ISP and mod_CLC
;
        CONST.D d4,0xFFFFFFF0           ; mask WDTHPW0,WDTLCK,ENDINIT
        and     d0,d4,d0                ; in copy of WDT_CON0 (d0)
        or      d0,d0,#0X02             ; WDTHPW0=0,WDTLCK=1,ENDINIT=0
        isync
        st16.w  [a3],d0                 ; set WDT_CON0
        ld16.w  d0,[a3]                 ; necessary dummy read
;
        ret                             ;
;
;--------------------------------------------------------------------------
; function:     _endinit_set
; input:
;       None
; output:
;   Bit ENDINIT in WDTCON0 is set
; other registers used:
;       D0, D1, D2, D4, A3, A4 - work register
; description: Clears the ENDINIT bit in the 
; WDT_CON0 register in order to disable the 
; write-protection for registers protected 
; via the EndInit feature (ie. WDT_CON1, BTV, 
; BIV, ISP, mod_CLC).
;--------------------------------------------------------------------------
;
        .global _endinit_set
;
_endinit_set:
;
; 1st step: Password access (create password and send to WDT_CON0)
;
        CONST.A a3,WDT_CON0             ; get address WDT_CON0
        ld16.w  d0,[a3]                 ; get WDT_CON0 in d0
;
        CONST.A a4,WDT_CON1             ; get address WDT_CON1
        ld16.w  d1,[a4]                 ; get WDT_CON1_WDTDR WDT_CON1_WDTIR
;
        CONST.D d2,0xFFFFFF01           ; mask hardware password 0,1
        and     d0,d2,d0                ; in copy of WDT_CON0 (d0),
        or      d0,d0,#0xF0             ; set WDTHPW1 to 0xF and load
        and     d4,d1,#0x0C             ; copy of WDT_CON1_WDTDR and
        or      d0,d4,d0                ; WDT_CON1_WDTIR (d1)
        st16.w  [a3],d0                 ; set WDT_CON0
;
; 2nd step: Modify access, set the bit ENDINIT to 1  
;
        CONST.D d4,0xFFFFFFF0           ; mask WDTHPW0,WDTLCK,ENDINIT
        and     d0,d4,d0                ; in copy of WDT_CON0 (d0)
        or      d0,d0,#0X03             ; WDTHPW0=0,WDTLCK=1,ENDINIT=1
        isync
        st16.w  [a3],d0                 ; set WDT_CON0
;
        ret                             ;
;--------------------------------------------------------------------------

⌨️ 快捷键说明

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