ARM data load and store instructions (I)

Publisher:闪耀之星Latest update time:2016-04-19 Source: eefocusKeywords:ARM Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Data load and store instructions are a type of instructions that ARM uses to transfer data between registers and memory.
 
Experimental purpose:
       Application of single register data transfer instructions and master of various displacement addressing modes
       Application of multi-register data transfer instructions and master of various displacement addressing modes
       Methods of single data copying and data block copying.
       Use various windows in the debugger to observe the changes of registers, memory, label addresses, machine instructions, etc. after completing each instruction operation.
1. Single register load and store instructions LDR|STR
      AREA Lab1,CODE
      ENTRY
START 
      ADR R1,SRC
       ADR R2,DST
COPY   
      LDR R0,[R1]
      STR R0,[R2]
      ADD R1,R1,#0x4
      ADD R2,R2,#0x4
      LDR R0,[R1]
      STR R0,[R2]
      ADD R1,R1,#0x4
      ADD R2,R2, #0x4
      LDR R0,[R1]
      STR R0,[R2]
      
STOP
      B STOP
       
      
SRC    DCB "one small!"
      ALIGN
DST    DCB "three big!"
      END
Program Description:
1.       The pseudo-instruction ADR stores the address of a register-related expression or a program-related expression into a register. In the example, it is equivalent to making R1 point to SRC and R2 point to DST, that is, initializing the address pointer.
2.       The function of DCB is to allocate a group of bytes of memory and define its content as a specified string. It can also be replaced by "=":
SRC = "one small!"
DST = "three big!"
 
Complete the following tasks
1. Read the program exp6_1.s and write out the function of the program. Set the base address of the code segment to 0x8000. Use AXD to debug the program step by step, observe the changes in the corresponding registers and memory after each step, and complete the table.
The opened process view window is as follows: register, disassembly, low lever symbols, memory
Serial number Execute Instructions Changes after instruction execution
    register Memory
    R0 R1 R2 PC 0x8040 0x8041 0x8042 0x8043 0x8044 0x8045 0x8046 0x8047 0x8048 0x8049
0   0x0 0x0 0x0 0x8000 0x74
t
0x68
H
0x72
r
0x65e
0x65e
0x20
_
0x62
b
0x69
i
0x67
g
0x21
!
1                              
2                              
3                              
4                              
5                              
6                              
7                              
8                              
9                              
10                              
2. The addressing mode used in the program is the zero-displacement mode in indirect addressing. Please change the program to the pre-displacement form and post-displacement form. (Draw a diagram to analyze various displacement addressing forms and design a program to verify.)
3. Use the multi-register transfer instruction to modify the program.
 
Answer:
1.       The function of the program is to transfer the source data at SRC in the memory to DST through the data transfer instruction.
2.       Pre- and post-addressing
Method 1
COPY LDR R0,[R1],#4
           STR R0,[R2],#4
           LDR R0,[R1],#4
           STR R0,[R2],#4
LDR R0,[R1],#4
           STR R0,[R2],#4
Method 2
   SUB R1,R1,#4
   SUB R2,R2,#4
   MOV R3,#1
CPY
   LDR R0,[R1,#4]!
   STR R0,[R2,#4]!
   CMP R3,#3
   ADD R3,R3,#1
   BNE CPY
Method 3
LDR R0,[R1]
           STR R0,[R2]
           LDR R0,[R1,#4]
           STR R0,[R2,#4]
LDR R0,[R1,#8]
           STR R0,[R2,#8]
3.Multi       -register transfer instruction
LDMIA   R1!,{R3-R5}
STMIA   R2!,{R3-R5}
 
 
I. Multi-register load and store instructions
       AREA Lab2,CODE
      ENTRY
START 
      LDR sp,=NUM
      LDMFD SP!,{R0-R4}
      ADD R4,R0,R1
      ADD R4,R4,R2
      ADD R4,R4,R3
      MOV R4,R4,LSR #2
      STR R4,[SP]
STOP
       B STOP
      
      AREA Dblock,DATA
NUM    DCD  0x12,0x34,0x56,0x78
      ENDProgram
description:
1.         Define a data area named Dblock2
       The function of the pseudo instruction DCD is to allocate a group of word memory and define its content. The allocated memory must be a multiple of 4. It can also be replaced by &.
NUM & 0x12, 0x34,0x56,0x78
Keywords:ARM Reference address:ARM data load and store instructions (I)

Previous article:ARM data processing instructions
Next article:ARM data load and store instructions (Part 2)

Recommended ReadingLatest update time:2024-11-16 22:00

KEIL for ARM comes with a sample program virtual serial port debugging
1. Install Keil for ARM first, you can refer to my previous blog post Keil uVision4 registration machine download and installation  2. Then double-click as shown below 3. Then use VSPD to virtualize 2 serial ports (com1, com2) 4. Then enter in the Kiel command line  MODE COM1 4800,0,8,1 ASSIGN COM1
[Microcontroller]
KEIL for ARM comes with a sample program virtual serial port debugging
Samsung 2440 ARM initialization
1. Use the initialization file that Samsung has already written 1. Create a project folder first 2. Create a project and save it in the new folder 3. Drag the INC and SRC folders in the INIT folder written by ARM Samsung into the new folder. 4. Create a C file, such as LCD1602.c, and write a void xmain() function or
[Microcontroller]
Samsung 2440 ARM initialization
ARM Software Programming
1. Interrupt handling process The interrupt processing flow of the ARM system is shown in Figure 1. There are five main interrupts in the system: timer interrupt, serial port input interrupt, serial port output interrupt, interface interrupt, and link interrupt. Figure 1: Flowchart of application processi
[Microcontroller]
ARM Software Programming
ARM9 Learning 1-Installation and Use of Keil uVision 4.14
1. Assembly language preparation ----- Installation of editor RealView MDK Keil uVision 4.14 1. First, double-click the welcome interface of Keil u Vision 4.14 2. After next, the interface for accepting the installation is displayed. 3. After next, the custom installation directory interface 4. After ne
[Microcontroller]
ARM9 Learning 1-Installation and Use of Keil uVision 4.14
Data communication method between ARM and DSP in embedded machine vision system
DSP has powerful computing and processing capabilities for digital signals and numerical algorithms, so it is widely used in signal acquisition and processing, but it does not have an advantage in task management, real-time control, human-computer interaction, etc. ARM microcontrollers have powerful control function
[Embedded]
Data communication method between ARM and DSP in embedded machine vision system
ARM Basic Knowledge
In addition to normal saving, after compiling correctly, choose to save as a .h file with the same name, and change the main function name in the h file to other names, such as xmain, or main1, etc., then the new project can call the function in the original project! 1. Project 1 first write LCD1602, and after compili
[Microcontroller]
Summary of issues related to PC, LR, SPSR, and CPSR registers when an ARM interrupt occurs
Q: How is the context saved when ARM enters IRQ interrupt from SVC mode? Answer: When saving the scene, when in svc mode, the cpsr register is written to the spsr_irq register in irq mode, not the spsr_svc in svc mode. In this way, if you restore in interrupt mode, write the content of the spsr_irq register to the cps
[Microcontroller]
Hardware Design of an Embedded Network Video Monitoring System
1. Introduction The monitoring system using embedded network technology is the latest development trend in the monitoring field. The embedded network monitoring system is a high-tech product that is a combination of the rapid development of electronic technology, computer technology, communication technology
[Microcontroller]
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号