;#****************************************************************************************** ; # NAME:ARM_CODE2.S *; # author:wuhan center,embest *; # Desc:arm InStr uction examples *; # Example for Condition Code *; # HISTORY:SHW. He 2005.02.22 *; #**************************************************************************************** ;/*------------------------------------------------------------------------------------------* *;/* Code *//*------------------------------------------------------------------------------------------*/IS A start,code,readwrite entry code32 num equ 2;/* Number of entries in jump table */export Reset_handler R Eset_handler mov r0, #0;/* Set up the three parameters */mov r1, #3 mov r2, #2 bl arithfunc;/* C All the function */
;/* dead loop */stop B stop; # ************************************************************************ ; # * According R0 Valude to execute the code *; # ************************************** Arithfunc;/* Label the function */CMP r0, #num; * Treat function code as unsigned integer */BHS Doadd;/* If code is >=2 then do operation 0. */ADR R3, jumptable;/* Load Address of Jump table */Ldr PC, [r3,r0,lsl#2];/* Jump to the appropriate Rou Tine */
;/*pc = r3 + r0<<2*/
jumptable
DCD doadd ; it occupies 4 bytes, which stores the doadd corresponding to the address
DCD dosub ; It occupies 4 bytes, which stores the corresponding address of dosub
doadd
add r0, R1, R2;/ * operation 0, >1 */
BX LR ;/* return */
dosub
Sub r0, R1, R2 ;/* Operation 1 */
BX lr;/ * return */
end ;/* Mark the end of this file */
Before you perform BL Arithfunc
After execution:
It stores the value of the PC in R14 (LR).
------------------------------------------------------------Perseverance, The Pursuit of Excellence--------------------------------------------------------------------------------