• 專注電子技術學習與研究
    當前位置:單片機教程網 >> MCU設計實例 >> 瀏覽文章

    對stm32啟動代碼DCD sfe(CSTACK)的理解

    作者:公平   來源:本站原創   點擊數:  更新時間:2014年03月14日   【字體:

    復位序列:
    在離開復位狀態后,CM3做的第一件事就是讀取下列兩個32位整數的值:
    1、從地址0x0000 0000 處取出MSP的初始值。(也就是 stm32啟動代碼DCD     sfe(CSTACK)設置的棧頂指針值)
        PS:至于MSP的真實地址是多少我還不清楚,如果哪位大俠知道請告訴我?梢源_定的是它是在0x2000 0000--0x2002 0000之間的一個值,貌似是在0x20020000。


     

    2、從地址0x0000 0004 處取出PC的初始值 也就是復位向量的值。
    相關知識:
    IAR匯編指令SFB和SFE
    SFB Segment begin 段開始
    語法格式
    SFB(segment [{+|-} offset])

    參數
    segment: 可重定位段的段名, 必須在SFB使用前已定義
    offset : 從開始地址的偏移, 是一個可選參數, 當偏移量省略時, 可以不添加小括號

    描述
    SFB 右邊可以接受一個操作數, 而且這個操作數必須是一個可重位段的段名.
    這個操作符計算段的首字節地址. 這個操作發生在連接時.
    The operator evaluates to the absolute address of the first byte of that segment. This evaluation takes place at linking time.


    NAME demo
    RSEG CODE
    start: DC16 SFB(CODE)
    即使上面的代碼和多個其他的模塊進行連接, start標號處仍被置為段的首字節地址. Even if the above code is linked with many other modules, start will still be set to the address of the first byte of the segment.

     


    SFE Segment end

    語法格式
    SFE (segment [{+|-} offset])

    參數
    segment: 可重定位段的段名, 必須在SFB使用前已定義
    offset : 從開始地址的偏移, 是一個可選參數, 當偏移量省略時, 可以不添加小括號

    描述
    SFE在其右邊接收一個操作數. 操作數必須是一個可重定位段的段名. SFE操作符將段起始地址和段大小相加. 這個操作在連接時發生.
    SFE accepts a single operand to its right. The operand must be the name of a relocatable segment. The operator evaluates to the segment start address plus the segment size. This evaluation takes place at linking time.


    NAME demo
    RSEG CODE
    end: DC16 SFE(CODE)
    即使當上面的代碼被和多個模塊連接時, end標號仍然會被置為段最后一個字節的地址. Even if the above code is linked with many other modules, end will still be set to the address of the last byte of the segment.

    段MY_SEGMENT的大小可以通過以下方式計算而得:
    SFE(MY_SEGMENT)-SFB(MY_SEGMENT)

    關閉窗口

    相關文章

    亚洲一区二区制服在线|在绩专区欧美自拍日韩|青春娱乐网97超碰人人射|在线观看国产网址你懂的