会as语法的进来一下!!!
有个例子
.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里面定义??????
这样定义一个东西可以吗?????????
这种定义是不是常量或则是局部变量的意思????
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
先理解什么叫立即数再来学习汇编
.equ num, 20
这里并没有定义什么。只是在符号表里增加了一组对应值:num和20。在汇编时,将在所有使用num处填入20。