ARM assembly learning (VI) jump to thumb state

Publisher:XinmeiLatest update time:2016-07-12 Source: eefocusKeywords:arm Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Usually, a function returns using pop {r7,pc} or bx lr (bx, b is similar to jmp for jump instructions, but bx can specify whether the jump area is thumb or arm instructions.

When the thumb instruction is executed, directly filling in the address always generates a SIGSYS signal (illegal instruction execution).
The reason is that the function is a thumb instruction, so the lowest bit of the instruction address must be set to 1 when jumping (bx uses this bit to distinguish the instruction set), so the function address is increased by one.


Switching between thumb instruction set and arm instruction set

rice
R0,#5     ;Argument to function is in R0
add
R1,PC,#1     ;Load address of SUB_BRANCH, Set for THUMB by adding 1
BX     R1     ;R1 contains address of SUB_BRANCH+1
;Assembler-specific instruction to switch to Thumb
SUB_BRANCH:
BL
thumb_sub     ;Must be in a space of +/- 4 MB
add
R1,#7     ;Point to SUB_RETURN with bit 0 clear
BX
R1
;Assembler-specific instruction to switch to ARM 
SUB_RETURN:


The last two digits of the address of the instruction in arm state are 0,
while the last two digits of the address of the instruction in thumb state are 0.
Thumb1+1 indicates that you are about to jump into thumb state, and the system will automatically adjust the address.

Keywords:arm Reference address:ARM assembly learning (VI) jump to thumb state

Previous article:ARM assembly learning
Next article:Android ARM Assembly Learning (I)

Recommended ReadingLatest update time:2024-11-16 20:37

About the installation of arm-linux-gcc4.4.3 under ubuntu11.10
After reading countless documents, I finally found this useful article. I spent several hours last night installing version 4.3.2 but failed. Today, I accidentally saw this article on the forum and tried it. It still took two or three hours. It was really tiring, but it succeeded. Listen to comfort. The following in
[Microcontroller]
【ARM】s3c2440 bare metal implementation of image display
Function LCD display Chinese characters, characters and pictures illustrate Chinese characters, characters and pictures need to use the corresponding module software to get the corresponding c file, and then include it in the project Main code 1) Draw the background void Brush_ U32  c) {     int x,y ;  
[Microcontroller]
【ARM】s3c2440 bare metal implementation of image display
ARM9 2440 clock
In fact, ARM9 is nothing special, it is basically the same as ARM7 and 6, and there is no difference when running naked. I personally feel that it is wrong! But the omnipotent C language is real!  U32 val; U8 m, p, s; val = rMPLLCON; m = (val 12)&0xff; p = (val 4)&0x3f; s = val&3; //(m+8)*FIN*2 Do not exceed 32 di
[Microcontroller]
ARM floating point knowledge
ARM floating point operations   1: Types of floating-point operations implemented by ARM    There are three ways to implement floating point operations on ARM, and these three methods are usually different in the development time of ARM and its compiler. The above is serial.    (1): Floating point emulation of
[Microcontroller]
ARM Linux kernel layout in memory
Kernel Memory Layout on ARM Linux Russell King rmk@arm.linux.org.uk      November 17, 2005 (2.6.15) This document describes the virtual memory layout which the Linux kernel uses for ARM processors.  It indicates which regions are free for platforms to use, and which are used by generic code. The ARM CPU is c
[Microcontroller]
(VI) ARM Status Register - PSR
ARM Program State Register In ARM mode, there are 16 data registers and 1 or 2 status registers that are accessible at any time. In privileged mode  , the corresponding special group of registers can be used. CPSR Current Program State Register SPSR There are 6 saved program state registers, which are mainly used wh
[Microcontroller]
(VI) ARM Status Register - PSR
Arm provides secure computer vision for smart cameras
Arm provides secure computer vision for smart cameras Mohamed Awad, Vice President of IoT and Embedded Business Unit, Arm Ma Jian, Vice President of Business Development, IoT and Embedded Business Unit, Arm There is an old Chinese saying that we should keep our eyes open and our
[sensor]
Realization of traction therapy system based on ARM
Introduction In medicine, physical traction is usually used as a conservative treatment method for lumbar spine diseases such as lumbar disc herniation. This traction bed system uses a two-section bed as a treatment platform, adopts embedded processors such as ARM and combines computers to achieve distributed
[Microcontroller]
Realization of traction therapy system based on ARM
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号