arm汇编学习(六)跳转到thumb状态
thumb指令指令的时候,直接填写该地址却总是产生SIGSYS信号(非法指令执行)。
原因就是该函数为thumb指令,因此跳转时必须要把指令地址的最低位设置为1(bx 通过这一位来区分指令集),所以函数地址就加了一。
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状态下指令的地址末两位都是0
而thumb状态下指令地址的末尾是0
thum1+1表明你即将跳入thumb状态,系统会自动调整地址的
评论