中文字幕 另类精品,亚洲欧美一区二区蜜桃,日本在线精品视频免费,孩交精品乱子片免费

<sup id="3hn2b"></sup>

    1. <sub id="3hn2b"><ol id="3hn2b"></ol></sub><legend id="3hn2b"></legend>

      1. <xmp id="3hn2b"></xmp>

      2. 新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > Thumb指令集之: ARM和Thumb的混合編程

        Thumb指令集之: ARM和Thumb的混合編程

        作者: 時間:2013-09-30 來源:網(wǎng)絡(luò) 收藏

        本文引用地址:http://www.antipu.com.cn/article/257035.htm

        (2)C語言的互交實例

        下面的例子顯示了一個Thumb狀態(tài)下的代碼通過互交調(diào)用子程序;而后又在子程序中調(diào)用的庫函數(shù)printf()。

        /*********************

        *thumbmain.c*

        **********************/

        #includestdio.h>

        externvoidarm_function(void);

        intmain(void)

        {

        printf(HellofromThumbWorldn);

        arm_function();

        printf(AndgoodbyefromThumbWorldn);

        return(0);

        }

        /*********************

        *armsub.c*

        **********************/

        #includestdio.h>

        voidarm_function(void)

        {

        printf(HelloandGoodbyefromworldn);

        }

        使用下面的命令對程序進行編譯連接。

        ①編譯生成帶互交的Thumb代碼。

        armcc--thumb-c-g--apcs/interwork-othumbmain.othumbmain.c

        ②編譯生成帶互交的ARM代碼。

        armcc-c-g--apcs/interwork-oarmsub.oarmsub.c

        ③連接目標文件。

        armlinkthumbmain.oarmsub.o-othumbtoarm.axf

        另外,可以使用--info選項使連接器輸出由于互交所增加的代碼大小。

        armlinkarmsub.othumbmain.o-othumbtoarm.axf--infoveneers

        輸出信息如下所示。

        Addingstotheimage

        AddingTAveneer(4bytes,Inline)forcallto'arm_function'fromthumbmain.o(.text).

        AddingATveneer(8bytes,Inline)forcallto'__0printf'fromarmsub.o(.text).

        AddingATveneer(8bytes,Inline)forcallto'__rt_lib_init'fromkernel.o(.text).

        AddingATveneer(12bytes,Long)forcallto'__rt_lib_shutdown'fromkernel.o(.text).

        AddingTAveneer(4bytes,Inline)forcallto'__rt_memclr_w'fromstdio.o(.text).

        AddingTAveneer(4bytes,Inline)forcallto'__rt_raise'fromstdio.o(.text).

        AddingTAveneer(8bytes,Short)forcallto'__rt_exit'fromexit.o(.text).

        AddingTAveneer(4bytes,Inline)forcallto'__user_libspace'fromfree.o(.text).

        AddingTAveneer(4bytes,Inline)forcallto'_fp_init'fromlib_init.o(.text).

        AddingTAveneer(4bytes,Inline)forcallto'__heap_extend'frommalloc.o(.text).

        AddingATveneer(8bytes,Inline)forcallto'__raise'fromrt_raise.o(.text).

        AddingTAveneer(4bytes,Inline)forcallto'__rt_errno_addr'fromftell.o(.text).

        12(s)(total72bytes)addedtotheimage.

        (3)Thumb狀態(tài)下的功能指針

        任何指向Thumb函數(shù)(由Thumb指令完成的功能函數(shù)并且其返回狀態(tài)也為Thumb狀態(tài))的指針,其最低有效位(LSB)必為1。

        當重定位Thumb代碼中的地址標號時,連接器將自動設(shè)置地址的最低有效位。如果在程序中使用絕對地址,連接器將無法完成該設(shè)置。因此,如果在Thumb代碼中使用絕對地址時,必須手工設(shè)置為其地址加1。

        下面的例子顯示了Thumb代碼的功能指針的使用。

        typedefint(*FN)();

        myfunc(){

        FNfnptrs[]={

        (FN)(0x8084+1), //有效的Thumb地址

        (FN)(0x8074) //無效的Thumb地址

        };

        FN*myfunctions=fnptrs;

        myfunctions[0](); //調(diào)用成功

        myfunctions[1](); //調(diào)用失敗

        }

        c++相關(guān)文章:c++教程



        上一頁 1 2 3 4 5 6 下一頁

        評論


        相關(guān)推薦

        技術(shù)專區(qū)

        關(guān)閉