汇编指令的执行过程

来源:互联网 发布:安卓电路设计软件 编辑:程序博客网 时间:2024/05/20 11:36
;#*********************************************************************************************;# NAME:ARM_code2.s *;# Author: WUHAN R&D Center,Embest *;# Desc:ARM instruction examples *;#          Example for Condition Code *;# History:shw.He 2005.02.22 *;#*********************************************************************************************;/*------------------------------------------------------------------------------------------*/;/* code     */;/*------------------------------------------------------------------------------------------*/area start,code,readwriteentrycode32num equ2;/*  Number of entries in jump table */export Reset_HandlerReset_Handlermovr0, #0;/*  set up the three parameters */movr1, #3movr2, #2blarithfunc;/*  call the function */
;/*死循环*/stopbstop;# ********************************************************************************************;# * According R0 valude to execute the code *;# ********************************************************************************************arithfunc;/*  label the function */cmpr0, #num;/*  Treat function code as unsigned integer */bhsDoAdd;/*  If code is >=2 then do operation 0. */adrr3, JumpTable;/*  Load address of jump table */ldrpc, [r3,r0,LSL#2];/*  Jump to the appropriate routine */
                                                                         ;/*pc = r3 + r0<<2*/JumpTabledcdDoAdd                                ;其占领4个字节,其中存储的是DoAdd对应的地址dcdDoSub                                ;其占领4个字节,其中存储的是DoSub对应的地址DoAddaddr0, r1, r2;/*  Operation 0, >1 */bxlr ;/*  Return */DoSubsubr0, r1, r2;/*  Operation 1 */bxlr;/*  Return */end;/*  mark the end of this file */


执行bl  arithfunc之前

执行之后:

 

其将pc的值保存在r14(LR)之中。

 

 

 ------------------------------------------------------------坚持不懈,追求卓越--------------------------------------------------------------------------------

原创粉丝点击