ARM集成环境下把一段内存里的数据存到另一端内存
01 |
; |
02 |
; 代码演示 |
03 |
; |
04 |
;定义数据段 |
05 |
AREA p1Data, DATA, READWRITE |
06 |
buf1 dcd 1,2,3,4,5,6 ;定义字 |
07 |
buf2 dcw 1,2,3,4,5,6 ;定义半字 |
08 |
buf3 dcb 1,2,3,4,5,6 ;定义字节 |
09 |
str dcb "123456" , 0 ;定义字符串 |
10 |
align 4 |
11 |
buf4 space 256 ;分配256字节空间 |
12 |
|
13 |
|
14 |
|
15 |
AREA p1Code, CODE, READONLY |
16 |
|
17 |
ENTRY |
18 |
start |
19 |
;buf1 copy to buf4 |
20 |
ldr r0, =buf1 ;源基址 |
21 |
ldr r1, =buf4 ;目的基址 |
22 |
mov r2, #0 ;循环计数器 |
23 |
cploop |
24 |
ldr r3, [r0, r2, lsl#2] ;读出源数据字到r3,把r0+r2*4位置的值送入r3寄存器 |
25 |
str r3, [r1, r2, lsl#2] ;写入到目的缓冲区,把r3寄存器的值送入r1+r2*4位置处 |
26 |
cmp r2, #5 |
27 |
beq cpend |
28 |
add r2, r2, #1 |
29 |
b cploop |
30 |
cpend |
31 |
|
32 |
stop |
33 |
mov r0, #0x18 |
34 |
ldr r1, =0x20026 |
35 |
swi 0x123456 |
36 |
|
37 |
end |
有梦想就不会觉得苦.
Do you know what is the glittering life?