当前位置:网站首页>Summary of common instructions for arm assembly
Summary of common instructions for arm assembly
2022-06-26 08:33:00 【Yu Getou】
List of articles
ARM A summary of common assembly instructions
1.EQU
assignment
; take 0x40013800 Assign a value to a variable USART1_BASE( Register address )
USART1_BASE EQU 0x40013800
2.AREA
usage :AREA sectionname{,attr}{,attr}…
sectionname: The segment name to be specified
attr: Segment properties
Attribute enumeration
ALIGN=expression
By default ,ELF Segments are aligned on four byte boundaries .expression You can have 0 To 31 Any integer of . Paragraph in 2expression Align on byte boundaries . for example , If expression yes 10, Then the paragraph is in 1KB Align on boundary . This is related to ALIGN The command is not specified in the same way .
ASSOC=section
section Specify an associated ELF paragraph .sectionname Must be included in the section In any link to .
CODE
Contains machine instructions .READONLY Is the default value .
COMDEF
Is a common segment definition . This is what contains code or data ELF paragraph . It must be the same as any other segment with the same name in other source files . The same... With the same name ELF Segments are overwritten by linked programs in the same segment of memory . If any paragraph is different , The linker generates a warning , And do not cover these segments . see also RealView Compiler tools 2.0 Version of the linker and utility guide Linker in chapter .
COMMON
Is a public data segment . No code or data can be defined in it . The reason is
Linker initialized to zero . All public segments with the same name exist
The same segment of the memory is overwritten by the linked program . They don't all need to have
The same size . Linker according to the needs of the largest common segment of each name
Allocate space .
DATA
Contains data but no instructions .READWRITE Is the default value .
NOALLOC
Indicates that this... Is not available on the target system AREA Allocate memory .
NOINIT
Indicates that the data segment is uninitialized or initialized to zero . It contains only zero initialized space reservation commands SPACE or DCB、DCD、DCDU、DCQ、DCQU、DCW or DCWU. You can decide when linking AREA Is it uninitialized or zero initialized ( see also RealView Compiler tools 2.0 Version of the linker and utility guide Linker in chapter ).
READONLY
Indicates that it cannot be written to this segment . This is the default for code regions .
READWRITE
It means you can read and write this paragraph . This is the default for data areas
3.DCD
Allocate storage units for specific data , At the same time, it can complete the initialization of the allocated storage unit .
AREA RESET, DATA, READONLY
DCD MSP_TOP ; Initialize main stack
DCD Start ; Reset vector
DCD NMI_Handler ;NMI Handler
DCD HardFault_Handler ;Hard Fault Handler
DCD 0
DCD 0
DCD 0
DCD 0
DCD 0
DCD 0
DCD 0
DCD 0
DCD 0
DCD 0
DCD 0
DCD SysTick_Handler ;SysTick Handler
SPACE 20 ; Reserve space 20 byte
4. ENTRY
Develop entry points for assemblers , There must be at least one in a complete assembler ENTRY( There can be more than one , When there is more than one ENTRY when , The real entry point of the program is specified by the linker ), But there can be at most one in a source file ENTRY( There can be no ).
AREA |.text|, CODE, READONLY
; The main program starts
ENTRY
; Instructs the program to execute from here
5. START
A label , Mark the entry of the program , After the program is loaded into memory CS,IP Will point to this label , from START The instruction pointed to starts running .
Finally, we should cooperate END Use
6. LDR
Format :LDR{ Conditions } Destination register < Memory address >
1、 ldr pc, =label
Namely the label Of data or instructions after Running address The assignment is pc. Running address = Link address + The offset of these data or instructions from the program start address .
2、 ldr pc, label
hold label Data or instructions after Content Assign a value to pc.
ldr r0, =RCC_CR
ldr r1, [r0]
7. STR
General follow LDR In combination with . usage :STR r1,[r2] ; take r1 Save the value in to r2 In the specified address
ldr r0, =RCC_CR
ldr r1, [r0]
orr r1, #Bit16
str r1, [r0]
8.BEQ
CPSR Of Z The identification bit is 1 when , The program jumps to beq At the label after
; Wait for the external crystal oscillator to be ready
ClkOk
ldr r1, [r0]
ands r1, #Bit17
beq ClkOk
9.MSR/MRS
MRS, The status register is transferred to the general register class instruction , Transfer the contents of the status register to the general purpose register .
Format :MRS{< Condition code >}Rd,CPSR}SPSR
MSR, General register transfer to status register transfer instruction , Transfer the contents of the general register to the status register .
Format :MSR{< Condition code >CPSR_f|SPSR_f,<#immed_8r>
; Switch to user level line program mode
ldr r0, =PSP_TOP
; Initialize thread stack
msr psp, r0
mov r0, #3
msr control, r0
10.B/BL/BX
All three are program jumps , but B Is pure jump , Will not return ,BL After the jump is executed, it will return to the original position , Used to execute subroutines .BX The instruction at the destination address of the jump can be either ARM Instructions , It can also be Thumb Instructions .
The format is :B/BL/BX Destination address
bx lr; Represents the return of a subroutine
11.PUSH/POP
Press data into / Pop up stack
; Is equivalent to r0,r1, r2, r3 Registers are passed as parameters into the subroutine stack
push {r0 - r3}
...
; Clear subroutine stack
pop {r0 - r3}
Logical operators
边栏推荐
- HEVC学习之码流分析
- Whale conference provides digital upgrade scheme for the event site
- Two ways to realize time format printing
- (vs2019 MFC connects to MySQL) make a simple login interface (detailed)
- Discrete device ~ diode triode
- 73b2d wireless charging and receiving chip scheme
- Necessary protection ring for weak current detection
- 在 KubeSphere 部署 Wiki 系统 wiki.js 并启用中文全文检索
- Apple motherboard decoding chip, lightning Apple motherboard decoding I.C
- OpenCV Learning notes iii
猜你喜欢

The difference between push-pull circuit drive and totem pole drive

Use a switch to control the lighting and extinguishing of LEP lamp

Oracle 19C download installation steps

Relation extraction model -- spit model

RF filter

Esp8266wifi module tutorial: punctual atom atk-esp8266 for network communication, single chip microcomputer and computer, single chip microcomputer and mobile phone to send data

Fabrication of modulation and demodulation circuit

Intra class data member initialization of static const and static constexpr

MySQL insert Chinese error

Embedded Software Engineer (6-15k) written examination interview experience sharing (fresh graduates)
随机推荐
Introduction of laser drive circuit
The best time to buy and sell stocks to get the maximum return
STM32 encountered problems using encoder module (library function version)
Relevant knowledge of DRF
多台三菱PLC如何实现无线以太网高速通讯?
And are two numbers of S
The solution of installing opencv with setting in pycharm
Software engineering - personal assignment - question review and personal summary
CodeBlocks integrated Objective-C development
Pychart connects to Damon database
[已解决]setOnNavigationItemSelectedListener()被弃用
2020-10-29
Stream analysis of hevc learning
Learning signal integrity from scratch (SIPI) -- 3 challenges faced by Si and Si based design methods
Relationship extraction --tplinker
What are the conditions for Mitsubishi PLC to realize Ethernet wireless communication?
Opencv learning notes II
三菱PLC若想实现以太网无线通讯,需要具备哪些条件?
How to Use Instruments in Xcode
js文件报无效字符错误