This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS6.0 全局变量如何不清零



1 由于将工程编译后,启动时间较长。时间长的原因是因为程序在启动时将局变量清零,所以造成启动的较慢。

2 在CCS中如何设置,可以将全局变量在编译后的可执行代码中,不清零,来让app启动时间短一点,谢谢。刚入手CCS,不是太熟悉。

  • 全局变量初始化是从.cinit copy到bss段,这个函数在autoinit里。跟CCS的设置没有关系。跟全局变量是否有初始化值有关系。

    ;----------------------------------------------------------------------
    ; Copy data from .cinit section to .bss section
    ; AR2 = data length of current record (0 => finished)
    ; AC0 = 23-bit variable address in .bss section
    ; AC1 = Address space indicator (0 => DATA, 1 => IO)
    ;----------------------------------------------------------------------
    LOOP:
    AR2 = *AR0+
    if (AR2 == #0) goto PINIT

    AC0 = uns(*AR0+) << #8
    || AR2 = AR2 - #1
    AC1 = uns(*AR0+)
    || CSR = AR2
    AC0 = AC0 | (AC1 <<< #-8)
    AC1 = AC1 & #0xff

    ;----------------------------------------------------------------------
    ; Load extended address register with 23-bit address of variable
    ;----------------------------------------------------------------------
    .if .PHASE3 | __TMS320C55X_PLUS__
    XAR6 = AC0
    .else
    MDP67 = @AC0_H || mmap()
    AR6 = AC0
    .endif

    ;----------------------------------------------------------------------
    ; Do the appropriate copy operation
    ;----------------------------------------------------------------------
    if (AC1 != #0) goto PORTMEMCOPY

    DATAMEMCOPY:
    .if __TMS320C55X_PLUS_BYTE__
    repeat(CSR)
    byte(*AR6+) = byte(*AR0+)
    mar(XAR0 + #1) || bit(AR0, @0) = #0
    .else
    repeat(CSR)
    *AR6+ = *AR0+
    .endif
    goto LOOP

    PORTMEMCOPY:
    .if __TMS320C55X_PLUS_BYTE__
    AR2 = AR2 >> #1
    CSR = AR2
    .endif
    repeat(CSR)
    *AR6+ = *AR0+ || writeport()
    goto LOOP