arm匯編學(xué)習(六)跳轉到thumb狀態(tài)
thumb指令指令的時(shí)候,直接填寫(xiě)該地址卻總是產(chǎn)生SIGSYS信號(非法指令執行)。
原因就是該函數為thumb指令,因此跳轉時(shí)必須要把指令地址的最低位設置為1(bx 通過(guò)這一位來(lái)區分指令集),所以函數地址就加了一。
thumb指令集與arm指令集切換
movR0,#5 ;Argument to function is in R0addR1,PC,#1 ;Load address of SUB_BRANCH, Set for THUMB by adding 1BX R1 ;R1 contains address of SUB_BRANCH+1;Assembler-specific instruction to switch to ThumbSUB_BRANCH:BLthumb_sub ;Must be in a space of +/- 4 MBaddR1,#7 ;Point to SUB_RETURN with bit 0 clearBXR1;Assembler-specific instruction to switch to ARM SUB_RETURN:
arm狀態(tài)下指令的地址末兩位都是0
而thumb狀態(tài)下指令地址的末尾是0
thum1+1表明你即將跳入thumb狀態(tài),系統會(huì )自動(dòng)調整地址的
評論