How does ARM implement absolute address jump?

Publisher:创新思绪Latest update time:2019-02-13 Source: eefocusKeywords:ARM Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Analysis based on b jump instruction, ldr pseudo instruction, ldr load instruction


The following scenarios require


1. After executing some instructions from Stepingstone, you need to jump to SDRAM for execution. The prerequisite is that you must first copy the code in NAND FLASH to SDRAM before you can jump to SDRAM for execution. To jump to SDRAM, you need to use the LDR pseudo instruction LDR PC,=SDRAM to implement


analyze:


The b instruction is a relative jump instruction. You can see that the disassembled code is exactly the same. It depends on the value of the current PC register. Regardless of the link address of this code, the b instruction can jump to the correct position. This type of instruction is called a position-independent instruction.


ldr pc,=labr pseudo-instruction. As can be seen from the disassembled code, it reads data from a certain location in the memory and assigns it to the pc register. The value stored in it depends on the link address of the link script file. It is an absolute jump instruction.


2. To debug interrupts in SDRAM, the interrupt vector must also be placed at 0x00000000 to jump to the corresponding position in SDRAM


Vectors         

ldr PC, Reset_Addr ;@0x00 reset    

ldr PC, Undef_Addr ;@ 0x04: vector address of undefined instruction abort mode

ldr PC, SWI_Addr ;@ 0x08: vector address of management mode, enter this mode through SWI instruction

ldr PC, PAbt_Addr ;@ 0x0c: vector address of exception caused by instruction prefetch termination

ldr PC, DAbt_Addr ;@ 0x10: vector address of the exception caused by data access termination

nop ;@ 0x14: reserved

ldr PC, IRQ_Addr ;@ 0x18: interrupt mode vector address

ldr PC, FIQ_Addr ;@ 0x1c: vector address of fast interrupt mode

Reset_Addr      DCD     Reset_Handler

Undef_Addr      DCD     Undef_Handler

SWI_Addr        DCD     SWI_Handler

PAbt_Addr       DCD     PAbt_Handler

DAbt_Addr DCD DAbt_Handler

                nop

IRQ_Addr        DCD     IRQ_Handler

FIQ_Addr DCD FIQ_Handler

Reset_Handler                

   

Undef_Handler b Undef_Handler ; not used, can be reserved with this instruction

SWI_Handler b SWI_Handler ; not used, can be reserved with this instruction

PAbt_Handler b PAbt_Handler ; not used, can be reserved with this instruction

DAbt_Handler b DAbt_Handler ;Not used, can be reserved with this instruction

FIQ_Handler b FIQ_Handler ; not used, can be reserved with this instruction

IRQ_Handler

    sub lr, lr, #4 ;@ Calculate the return address

    stmdb sp!, { r0-r12,lr } ;@ Save the used registers

                                    ;@ Note that the sp at this time is the sp in interrupt mode

                                     ;@ The initial value is 3072 set above

ldr lr , =int_return

    ldr pc, =EINT_Handle ;@ Call interrupt service function in interrupt.c

int_return; Because the ldr jump cannot save the address of the next instruction to lr, it is necessary to save the instruction before the jump.

    ldmia sp!, { r0-r12,pc }^ ;@ interrupt return, ^ means copy the value of spsr to cpsr

    END

Use the ldr load instruction (not the ldr pseudo-instruction) to implement absolute address jump


The hander label depends on the setting of the link script address. The hander address is placed in the memory labeled step3, so as to achieve the purpose of absolute address jump.


+++++++++++link2.s+++++++++


.text


.global _start


_start:         b   step1


step1:          ldr pc,=step2


 


step2:          ldr pc,step3


step3:          .long   hander


hander:         b step4


step4:          b step4


 

+++++++++++Makefile++++++++++++++



link2:  link2.s


arm-linux-gcc -c -o link2.o link2.s


arm-linux-ld -Ttext 0x00000000 link2.o -o link2_elf_0x00000000


arm-linux-ld -Ttext 0x30000000 link2.o -o link2_elf_0x30000000


arm-linux-objdump -D link2_elf_0x00000000 > link2_0x00000000_dis


arm-linux-objdump -D link2_elf_0x30000000 > link2_0x30000000_dis


clean :


rm -f  *.o


  

link2_elf_0x30000000:    file format elf32-littlearm


Disassembly of section .text:


30000000


30000000:  eaffffff      b       30000004


30000004


30000004:  e59ff00c   ldr     pc, [pc, #12]; 30000018


30000008


30000008:  e51ff004   ldr     pc, [pc, #-4]         ; 3000000c


3000000c


3000000c:  30000010 .word         0x30000010


30000010


30000010:  eaffffff      b       30000014


30000014


30000014:  eafffffe     b       30000014


30000018:  30000008 .word         0x30000008


 

link2_elf_0x00000000:    file format elf32-littlearm


Disassembly of section .text:


00000000


   0:          eaffffff      b       4


00000004


   4:          e59ff00c   ldr     pc, [pc, #12]        ; 18


00000008


   8:          e51ff004   ldr     pc, [pc, #-4]         ; c


0000000c


   c: 00000010 .word         0x00000010


00000010


  10:          eaffffff      b       14


00000014


  14:          eafffffe     b       14


  18:          00000008 .word         0x00000008


Keywords:ARM Reference address:How does ARM implement absolute address jump?

Previous article:Introduction to ARM platform printf function positioning to uart output
Next article:MDK routine porting based on S3C2410

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

Introduction to ARM Cortex-M7 processor architecture
This article uses ST's STM32F7 as an example to introduce the M7 architecture, mainly involving the M7 memory model and buffer mechanism, programming model, exception model, two major working modes of the processor, and privilege levels. For core registers, core peripherals SysTick, MPU, The FPU and system control blo
[Microcontroller]
Design and implementation of home intelligent control terminal based on ARM and GPRS technology
The home intelligent control system uses home bus technology to connect various household appliances, home security devices and various metering devices in the home to form an internal home network, which is managed uniformly by the home intelligent controller. Remote control is to connect the intelligent home controll
[Microcontroller]
Design and implementation of home intelligent control terminal based on ARM and GPRS technology
Embedded real-time image processing system based on ARM+FPGA+multi-DSP
Real-time image processing and high-speed data computing require that the system has fast data processing speed, high data throughput and multi-task processing capabilities. At present, most solutions use HPI data transmission to combine ARM and DSP to complete some image processing. The DSP processor only completes
[Microcontroller]
Embedded real-time image processing system based on ARM+FPGA+multi-DSP
Intel XScale Embedded System Based on ARM Core
1 Introduction Intel XScale microarchitecture provides a new, cost-effective, low-power solution based on ARMv5TE architecture , supporting 16-bit Thumb instructions and DSP expansion. Microprocessors developed based on XScale technology can be used in mobile phones, portable terminals (PDAs), net
[Microcontroller]
Intel XScale Embedded System Based on ARM Core
What did Nvidia and Arm CEOs say at the 2020 Developer Conference?
Comprehensive compilation from HPC and Techcrunch I don’t know if it was a coincidence, but during the National Day holiday, both Nvidia and Arm held developer conferences. Nvidia CEO Jensen Huang had just finished his GTC keynote speech, and then he had a lively conversation with Arm CEO Simon Segars at the Arm Dev
[Semiconductor design/manufacturing]
Design of remote control system for campus LED bulletin board based on ARM
In recent years, LED electronic display screens have attracted increasing attention as a high-tech product. They can display text, graphics and image information in real time or in a loop. They have many advantages, such as rich display modes, strong viewing, convenient display content modification, high brightness, s
[Power Management]
Design of remote control system for campus LED bulletin board based on ARM
Design of circuit module of fingerprint attendance system based on ARM7
  The attendance system has now become a must-have equipment for many companies, but the traditional attendance system is prone to replacing punching and swiping cards. The new fingerprint attendance machine completely avoids this situation. This article introduces a solution for designing a fingerprint attendance mac
[Microcontroller]
Design of circuit module of fingerprint attendance system based on ARM7
Research and Simulation of ARM Parallel Bus Based on FPGA
    0 Introduction In the design of digital systems, the FPGA+ARM system architecture has been used more and more widely. FPGA mainly realizes high-speed data processing; ARM mainly realizes system process control, human-computer interaction, external communication and FPGA control functions. Serial bus interfaces
[Embedded]
Research and Simulation of ARM Parallel Bus Based on FPGA
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号