- 论坛徽章:
- 0
|
有个例子
.text
.global _start
.equ num, 20 ; Number of words to be copied???????????
_start:
ldr sp,=stack_top ; Set up the stack pointer (R13) to some memory
; reserved for this purpose
ldr r0,=src ; R0 = pointer to source block
ldr r1,=dst ; R1 = pointer to destination block
mov r2,#num ; R2 = number of words to copy
blockcopy:
movs r3,r2,lsr #3 ; R3 = number of eight-word multiples
beq copywords ; Do we have less than eight words to move?
stmfd sp!,{r4-r11} ; Save our working registers (R4-R11)
octcopy:
ldmia r0!,{r4-r11} ; Load 8 words from the source; update R0
stmia r1!,{r4-r11} ; and store them at the destination; update R1
subs r3,r3,#1 ; Decrement the counter (num. of 8-words)
bne octcopy ; and repeat if necessary
ldmfd sp!,{r4-r11} ; Restore original register contents
copywords:
ands r2,r2,#7 ; Number of words left to copy
beq done
wordcopy:
ldr r3,[r0],#4 ; Load a word from the source
str r3,[r1],#4 ; and store it at the destination
subs r2,r2,#1 ; Decrement the counter (num. of words)
bne wordcopy ; and repeat if necessary
done: ; Finished copying!
exit: swi 0x11
.data ; Read/write data follows
.align ; Make sure data is aligned on 32-bit
; boundaries
src: .word 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
.word 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
dst: .skip num * 4 ; Reserve 80 bytes (num 32-bit words)
.section .bss ; Uninitialised storage space follows
.align
stack: .skip 1024 ; Allow 1KB for the local stack
stack_top: ; The stack grows downwards in memory, so we
; need a label to its top
.end
我就是想问,这里的num怎么没有在.data里面定义??????
这样定义一个东西可以吗?????????
这种定义是不是常量或则是局部变量的意思???? |
|