6. ARM addressing mode

Publisher:RainbowGardenLatest update time:2023-07-11 Source: elecfansKeywords:ARM Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The addressing mode is for the source operand.

6.1 Immediate addressing

  • The source operand is an immediate value

  • Immediate number: The number starting with the # sign in the opcode is the immediate number.

  • Immediate addressing: MOV R0, #0x300

  • Pseudo-instruction: LDR R0,=0x12345678

  • Notice:

    • The immediate data is 8-bit data storage, represented by

    • The immediate value 0xf200 is indirectly represented by 0xcf2, that is, the 8-bit F2 is rotated right by 24 bits (2 * 12) to obtain X = 0xf2; Y = 0xC

6.2 Register addressing

  • MOV R0,R1

  • The source operand is a register

6.3 Register shift addressing

  • Shift the source operand addressed by the register

  • MOV R0, R2, LSL, #3

  • After shifting R2 to the left by 3 bits, assign it to R0

6.4 Register indirect addressing

  • ARM consists of L/S structure, namely load/store

  • LOAD loads memory data into registers

  • STROE stores the data in the register into memory

  • instruction:

    • LDR R0, {R1} take out the value in {R1} and put it into R0

    • STR R0, {R1} Take out the value in R0 and put it into R1

    • {R1} means taking the data in the address stored in R1 and replacing it with C language, that is, *R1

1 MOV R1, #0x40000000

2 LDR R0, {R1}

3 STR R0, {R1}

5 //If the data represented by the data 0x40000000 in R1 is 0x55, then the value of R0 is 0x55


6.5 Base address indexed addressing

  • MOV R0, #44

  • MOV R1, #0x40000008

  • STR R0, [R1, #-4]

  • [R1, #-4] means the address value stored in R1 - 4

  • #-4 represents the offset

  • STR R0, [R1, #-4]!

  • ! means write-back, which is i-- in C language. The previous sentence first assigns the address value of R1 to R0, and then assigns the value in R0 - 4

  • The previous sentence is equivalent to STR R0,[R1], #-4

6.6 Multiple register addressing

  • STMIA R0!, {R1 - R3, R5}

  • Store the values ​​in R1 R2 R3 R5 in the address space starting from R0

  • The content in curly brackets represents the value in the register, and R0 corresponds to the memory address.

  • STM: Manipulate the values ​​of multiple memories

  • The corresponding command is LDMIA

  • I/D (increase/decrease) A/B (after/before)

  

 

6.7 Stack addressing

  • To perform stack operations, the stack register is R13, which is the SP register.

  • STMFD SP!, {R1-R3} push onto the stack, the register with the larger number is pushed onto the stack first, it has nothing to do with the writing order.

  • LDMFD SP!, {R1-R3} pop

  • Combination: F(FULL)/E(EMPTY) I/D

    • Generally written as FD, because the address space of ARM is full-decreasing.

    • Full stack: The stack pointer points to the last valid data item pushed

    • Empty stack: The stack pointer points to the next empty location to be pushed.

  • MOV SP, #0x40000010

  • STMFD SP!, {R1-R4}

  • That is, the value of R4 R3 R2 R1 is stored in 0x4000000c 0x40000008 0x40000004 0x40000000

6.8 Relative addressing

  • The jmp and call instructions used in 51

  • Relative addressing is a jump. Relative addressing is relative to the PC. Jump instruction: B BL BLX BX

  • B: jump instruction

  • BL: Jump instruction with return

  • BLX: Jump instruction with return and state switching

  • BX: Jump instruction with status switching


Keywords:ARM Reference address:6. ARM addressing mode

Previous article:7. ARM instruction set
Next article:5. Reduced instruction set and complex instruction set instruction formats

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号