Program structure in ARM assembly language

Publisher:不加糖的302Latest update time:2016-08-14 Source: eefocusKeywords:ARM Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
In ARM (Thumb) assembly language programs, code is organized in program segments. A segment is a relatively independent sequence of instructions or data with a specific name. Segments can be divided into code segments and data segments. The content of the code segment is the execution code, and the data segment stores the data needed when the code is running. An assembly program should have at least one code segment. When the program is long, it can be divided into multiple code segments and data segments. Multiple segments will eventually form an executable image file when the program is compiled and linked.

An executable image file usually consists of the following parts:

— One or more code segments, the properties of the code segments are read-only.

— Zero or more data segments containing initialized data. The data segments are readable and writable.

— Zero or more data segments that do not contain initialized data, and the attributes of the data segments are readable and writable.

The linker arranges each segment in the corresponding position in the memory according to the system default or user-defined rules. Therefore, the relative positions of the segments in the source program and the relative positions of the segments in the executable image file are generally different.

The following is the basic structure of an assembly language source program:

AREA Init , CODE , READONLY

ENTRY

Start

LDR R0 , =0x3FF5000

LDR R1 , 0xFF

STR R1 , [R0]

LDR R0 , =0x3FF5008

LDR R1 , 0x01

STR R1 , [R0]

┉┉

END

In assembly language programs, the AREA directive is used to define a segment and describe the relevant attributes of the defined segment. This example defines a code segment named Init with read-only attributes. The ENTRY directive identifies the entry point of the program, followed by a sequence of instructions. The end of the program is the END directive, which tells the compiler the end of the source file. Each assembly program segment must have an END directive to indicate the end of the code segment. Subroutine calls in ARM assembly language

 
 
  
 

In ARM assembly language programs, subroutine calls are generally implemented through BL instructions. In the program, use the instruction:

BL Subroutine name

The subroutine call is completed.

This instruction completes the following operations when executed: the return address of the subroutine is stored in the link register LR, and the program counter PC points to the entry point of the subroutine. When the subroutine is executed and needs to return to the calling place, it only needs to copy the return address stored in LR to the program counter PC. When calling a subroutine, it can also complete the transfer of parameters and the return of calculation results from the subroutine, which can usually be completed using registers R0 to R3.

The following is the basic structure of an assembly language source program that uses the BL instruction to call a subroutine:

AREA Init , CODE , READONLY

ENTRY

Start

LDR R0 , =0x3FF5000

LDR R1 , 0xFF

STR R1 , [R0]

LDR R0 , =0x3FF5008

LDR R1 , 0x01

STR R1 , [R0]

BL PRINT_TEXT

┉┉

PRINT_TEXT

┉┉

MOV PC,BL

┉┉

END

Keywords:ARM Reference address:Program structure in ARM assembly language

Previous article:LCD driver (FrameBuffer) example development explanation on S3C2440 (Part 2)
Next article:External RAM usage of LPC22xx under KEIL FOR ARM

Recommended ReadingLatest update time:2024-11-23 10:59

Introduction to ARM Platform Processors
When I first came into contact with ARM, I was confused by the numerous processor versions and series. It took me a lot of research to sort it out. Now I will summarize it here, hoping it can help others.   1. General situation First, copy a table from ARM's wiki: Architecture Family ARMv1 ARM1
[Microcontroller]
Introduction to ARM Platform Processors
Comparison of the performance of Cortex-M3 and ARM7TDMI-S cores
Since STM32 was launched, I have been very interested in it. Since it uses ARM's Cortex-M3 core, I want to know how its performance compares with ARM7. By chance, I got to know EDNCHINA and participated in EDN's group buying event. I got an STM32 development board, which gave me the opportunity to test the performance
[Microcontroller]
Comparison of the performance of Cortex-M3 and ARM7TDMI-S cores
Realization of field monitoring instrument for single-phase power metering device based on ARM
The on-site monitoring instrument for power metering devices is an intelligent instrument designed for online detection of line loss reduction and electricity theft prevention for power management departments in accordance with relevant national regulations and standards. The instrument can measure the comprehensive
[Microcontroller]
ARM -- core
ARM (advanced RISC machine) represents three meanings: Always represent ARM Always represents ARM technology Always represents ARM chips For the Three Represents. 1. ARM 8 working modes  user  fiq  irq  svc  abort  undef  system  (mon )  Unprivileged mode  Fast interrupt request
[Microcontroller]
Intel vs ARM: The battle for the future of mobile
Qualcomm, Samsung, MediaTek, and NVIDIA are the largest mobile chip manufacturers, accounting for the vast majority of all smartphone and tablet chips. At the same time, they have one thing in common: their CPU hardware is based on ARM's Cortex-A series. Intel may still dominate the PC and Windows markets, but the com
[Analog Electronics]
Intel vs ARM: The battle for the future of mobile
Design and implementation of CSMA/CA MAC protocol based on ARM and FPGA
    introduction     The advantages of the MAC protocol based on CSMA/CA are its simplicity and robustness. It is suitable for distributed networks. Each node does not need to maintain and dynamically update the status information of the surrounding adjacent nodes. It can independently decide when to access the chan
[Microcontroller]
Design and implementation of CSMA/CA MAC protocol based on ARM and FPGA
Design of embedded wireless video surveillance system based on ARM S3C2410X
    introduction     The emergence of high-performance, low-power embedded CPUs and high-reliability network operating systems has made it possible to implement applications with large amounts of computing data, such as videophones, video conferencing, and remote video monitoring, in embedded devices. Traditional vide
[Microcontroller]
Design of embedded wireless video surveillance system based on ARM S3C2410X
Research on SMC interface and PC/104 bus simulation based on ARM920T design
introduction PC/104 is an industrial control bus specification specifically defined for embedded applications. Personal computers and their peripherals based on the IBM PC/AT bus specification have made great achievements in application. IEEE-996 calls it the ISA (Industry Standard Architecture) bus. PC/104 is
[Microcontroller]
Research on SMC interface and PC/104 bus simulation based on ARM920T design
Latest Microcontroller Articles
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号