<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>

新聞中心

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

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

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

本文引用地址:http://dyxdggzs.com/article/257035.htm

(2)C語(yǔ)言的互交實(shí)例

下面的例子顯示了一個(gè)Thumb狀態(tài)下的代碼通過(guò)互交調用子程序;而后又在子程序中調用的庫函數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);

}

使用下面的命令對程序進(jìn)行編譯連接。

①編譯生成帶互交的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函數(由Thumb指令完成的功能函數并且其返回狀態(tài)也為T(mén)humb狀態(tài))的指針,其最低有效位(LSB)必為1。

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

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

typedefint(*FN)();

myfunc(){

FNfnptrs[]={

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

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

};

FN*myfunctions=fnptrs;

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

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

}

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



上一頁(yè) 1 2 3 4 5 6 下一頁(yè)

評論


相關(guān)推薦

技術(shù)專(zhuān)區

關(guān)閉
国产精品自在自线亚洲|国产精品无圣光一区二区|国产日产欧洲无码视频|久久久一本精品99久久K精品66|欧美人与动牲交片免费播放
<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>