Process of assembly instruction execution

Source: Internet
Author: User
;#****************************************************************************************** ; # 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--------------------------------------------------------------------------------

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.